- Export-Dhcp Server
- Syntax
- Description
- Examples
- Example 1: Export all DHCP configurations
- Example 2: Export the specified scopes
- Example 3: Export specified scopes and their leases
- Example 4: Export the specified scopes and DHCPv6 server level configuration
- Example 5: Export the specified scopes, their leases, and DHCPv6 server level configuration
- Example 6: Export scopes specified in a file
- Parameters
- Миграция DHCP сервера на Windows Server 2016
- Миграция DHCP сервера на Windows Server 2012
- Миграция DHCP сервера с Windows 2008 на Windows Server 2012
- Перенос DHCP с Windows Server 2003 на Windows 2012
- Перенос базы DHCP из Windows Server 2003 в Windows 2008
- DHCP экспорт импорт
- Перенос базы DHCP c Windows Server 2003 на 2008
- DHCP Server Migration: Migrating the DHCP Server Role
- Migrating DHCP Server to the destination server
- To migrate DHCP Server to the destination server
- Migrating DHCP Server from the source server
- To migrate DHCP Server from the source server
- Destination server final migration steps
Export-Dhcp Server
Exports the DHCP server service configuration and lease data.
Syntax
Description
The Export-DhcpServer cmdlet exports the Dynamic Host Configuration Protocol (DHCP) server service configuration, and optionally lease data, to the specified file.
If you specify the ScopeId or Prefix parameter,only the specified scopes or prefixes and all server level settings are exported.
If you specify neither ScopeId or Prefix, the DHCP server service configuration including all scopes, v4 and v6 and optionally the lease data, is exported.
If you specify the Leases parameter, the lease data is also exported in addition to configuration data.
Examples
Example 1: Export all DHCP configurations
This example exports all of the DHCP server, DHCPv4 and DHCPv6, configurations including scopes present on the DHCP server service to the specified export file in XML file format.
Example 2: Export the specified scopes
This example exports the scopes 10.10.10.0 and 10.20.20.0 present on the DHCP server service to the specified export file in XML file format. The DHCPv4 server level configuration is also exported to the specified file.
Example 3: Export specified scopes and their leases
This example exports the scopes 10.10.10.0 and 10.20.20.0 present on the DHCP server service to the specified export file in XML file format. This includes the leases present in the specified scopes. The DHCPv4 server level configuration will also be exported to the specified file.
Example 4: Export the specified scopes and DHCPv6 server level configuration
This example exports the specified scopes 2001:4898:7020:1020:: and 2001:4898:7020:1030:: present on the DHCP server service to the specified export file in XML file format. The DHCPv6 server level configuration is also exported to the specified file.
Example 5: Export the specified scopes, their leases, and DHCPv6 server level configuration
This example exports the specified scopes 2001:4898:7020:1020:: and 2001:4898:7020:1030:: present on the DHCP server service to the specified export file in XML file format. This includes the leases present in the specified scopes. The DHCP server level configuration is also exported to the specified file.
Example 6: Export scopes specified in a file
This example exports a list of scopes specified in file named ScopeList.txt to the specified export file in XML file format. The Import-Csv cmdlet returns the objects that contain the scope IDs output and pipes the objects into this cmdlet, which exports the specified scopes.
The file named ScopeList.txt should contain the following format:
Parameters
Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet. The default is the current session on the local computer.
Type: | CimSession |
Aliases: | Session |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the DNS name, or IPv4 or IPv6 address, of the target computer that runs the DHCP server service.
Type: | String |
Aliases: | Cn |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the name of the file to which the data will be exported. If the complete file path is not specified, the file is created in the current working directory. If there is an existing file by the same name, an error is returned.
Type: | String |
Position: | |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies that, if there is a file that already exists with the specified name, the file is overwritten.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies that IP address leases is also exported.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies one or more subnet prefixes of the IPv6 scopes which are exported.
Type: | IPAddress [ ] |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the scope identifiers, in IPv4 address format, which are exported.
Type: | IPAddress [ ] |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Миграция DHCP сервера на Windows Server 2016
Процедура миграция службы DHCP со всеми настройками со старого сервера на новый под управлением Windows Server 2016 довольно проста. Если старый сервер DHCP работает под управлением Windows Server 2008 / R2 или Windows Server 2012 / R2, вы можете напрямую перенести настройки, зоны и резервации DHCP.
Но гораздо проще и быстрее установить данную роль вместе с инструментами для ее управления (консоль DHCP и модуль PowerShell для работы с сервером DHCP) с помощью PowerShell.
Затем нужно создать локальные группы безопасности для управления сервером DHCP (группы DHCP Administrators и DHCP Users):
Чтобы включить параметры безопасности DHCP и связать их с созданными группами безопасности, перезапустите службу DHCP-сервера:
Авторизуйте новый сервер DHCP в домене Active Directory:
Add-DhcpServerInDC host1.contoso.com 192.168.10.35
Однако после установки роли DHCP и выполнения первичных настроек, при попытке подключится к серверу через Server Manager появится предупреждение о том, что требуется дополнительная донастройка роли (хотя по факту мы ее уже сделали). Убрать это предупреждение не поможет даже перезагрузка сервера.
Чтобы исправить эту проблему, нужно изменить ключ в реестре, отвечающий за статус настройки роли:
Set-ItemProperty –Path registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ServerManager\Roles\12 –Name ConfigurationState –Value 2
В Windows Server 2012 появились специальные командлеты PowerShell, позволяющие импортировать / экспортировать любые настройки DHCP-сервера. Microsoft максимально упростила процедуру миграцию, которую можно провести с помощью всего двух команд PowerShell: Export-DhcpServer и Import-Dhcpserver, которые могут быть выполнены удаленно с одного сервера (например, с того, куда планируется выполнить перенос службы):
Создайте каталог c:\dhcp и выполните следующую команду для выполнения экспорта настроек старого сервера DHCP в XML файл с именем OldDHCPConf.xml
Теперь можно выполнить импорт настроек из полученного файла на новый сервер
Все готово! Откройте консоль DHCP и проверьте, что все зоны DHCP, резервации, арендованные IP адреса были перенесены успешно.
Если вы создаете отказоустойчивую конфигурацию DHCP с использованием DHCP Failover, конфигурацию DHCP-сервера нужно импортировать также и на второй сервер
После завершения миграции сервера DHCP не забудьте повторно настроить агентов DHCP Relay (IP Helper) на сетевых маршрутизаторах и коммутаторах 3 уровня.
Миграция DHCP сервера на Windows Server 2012
Сегодня поговорим о таком актуальном вопросе, вызванной переходом на новую версию серверной ОС от Microsoft, как миграция старого dhcp сервера на новую платформу Windows Server 2012.
Обычно в продуктивной службе DHCP настроено множество параметров, в том числе огромные списки dhcp резерваций для клиентов (это всевозможные принтера, сендеры, компьютеры), поэтому о ручном переносе DHCP на новый Windows Server 2012 думать даже не хочется. К счастью существует возможность экспорта/импорта конфигурации DHCP сервера.
Нас интересуют два сценария переноса DHCP со старого сервера на Windows Server 2012:
1) Миграция DHCP сервера с Windows 2008/2008 R2
2) Миграция DHCP сервера с Windows 2003/ 2003 R2
Разберем оба эти сценария более подробно.
Миграция DHCP сервера с Windows 2008 на Windows Server 2012
Предположим, у нас имеется старый сервер с развернутой ролью DHCP, работающий под управлением Windows Server 2008 / 2008 R2 (пусть его имя srv-dhcp2008) и новый сервер с Windows 2012 (srv-dhcp2012), на который планируется осуществить перенос службы DHCP со всеми настройками.
На новом сервере с Windows Server 2012 установим роль DHCP с помощью команд Powershell:
Обратите внимание на параметр «IncludeManagementTools«, без которого роль DHCP будет установлена, но без соответствующей консоли управления.
Следующий шаг – авторизация нового DHCP сервера в Active Directory. Эту операцию также выполним с помощью Powershell :
В Windows Server 2012 появились специальные PowerShell командлеты, позволяющие осуществить импорт/экспорт любых параметров DHCP сервера. Отметим, что Microsoft максимально упростило всю процедуру, и нам необходимо будет выполнить всего две команды PowerShell: Export-DhcpServer и Import-Dhcpserver, которые могут работать и в удаленном режиме.
Итак, для экспорта настроек DHCP сервера, всех зон и резерваций с сервера под управление Windows Server 2008/R2, в консоли powershell на новом сервере (srv-dhcp2012) выполните следующую команду:
Конфигурация старого сервера экспортируется в XML формате в файл w2008dhcpconfig.xml. Отключите службу DHCP на сервере srv-dhcp2008:
Затем запускаем команду импорта:
Удостоверимся, что все dhcp зоны, резервации и мигрированы на новый сервер.
Если нужно импортировать только часть dhcp-зон, команда импорта будет выглядеть так:
Перенос DHCP с Windows Server 2003 на Windows 2012
К сожалению, прямой перенос настроек базы DHCP из Windows 2003 в Windows Server 2012 невозможен, т.к. Powershell-модуль экспорта не совместим со старыми версиями Windows Server, а команда netsh dhcp не поддерживается в Windows 2012 (функционал netsh dhcp был перенесен в PoSh ), так что в этом случае придется сначала перенести базу DHCP на Windows 2008, а затем уже с помощью Powershell мигрировать ее в Windows Server 2012. Как мигрировать базу из Windows 2003 в Windows 2008 R2 описано ниже.
Перенос базы DHCP из Windows Server 2003 в Windows 2008
Допустим, у нас есть DHCP сервер, работающая под управлением ОС Microsoft Windows Server 2003. Экспортируем базу данных DHCP в бинарный файл командой:
В результате, в корне диска C:\ появится бинарный файл dhcp_conf2003.dat, содержащий все настройки старого DHCP сервера. Для предотвращения dhcp конфликтов в сети, остановим службу DHCP на старом сервере:
Затем зайдем на сервер с Windows Server 2008 (на котором предварительно развернутся роль DHCP сервера, авторизованная в домене) и импортируем конфигурацию со старого сервера:
После этого нужно перезапустить службу DHCP на новом сервере с Windows 2008:
DHCP экспорт импорт
Перенос базы DHCP c Windows Server 2003 на 2008
Предварительно:
1) На Server2 установить службу DHCP. (Administrative Tools > Server Manager > Roles > Add Role > DHCP Server
2) Не авторизовать на этапе установки.
Русский будет содержать следующие классы:
«Класс маршрутиз. и удал. доступа по умолчанию» «Пользовательский класс для клиентов удаленного доступа» 525241532e4d6963726f736f6674 0 b
«Класс BOOTP по умолчанию» «Пользовательский класс для BOOTP-клиента» 424f4f54502e4d6963726f736f6674 0 b
«Параметры Microsoft Windows 2000» «Параметры, зависящие от поставщика, для клиентов Windows 2000» 4d53465420352e30 1 b
«Параметры Microsoft Windows 98» «Параметры, зависящие от поставщика, для клиентов Windows 98» 4d534654203938 1 b
«Параметры Microsoft» «Параметры, зависящие от поставщика и применимые для клиентов Windows 98 и Windows 2000» 4d534654 1 b
Английский:
«Default Network Access Protection Class» «Default special user class for Restricted Access clients» 4d5346542051756172616e74696e65 0 b
«Default Routing and Remote Access Class» «User class for remote access clients» 525241532e4d6963726f736f6674 0 b
«Default BOOTP Class» «User class for BOOTP Clients» 424f4f54502e4d6963726f736f6674 0 b
«Microsoft Windows 2000 Options» «Microsoft vendor-specific options for Windows 2000 Clients» 4d53465420352e30 1 b
«Microsoft Windows 98 Options» «Microsoft vendor-specific options for Windows 98 Clients» 4d534654203938 1 b
«Microsoft Options» «Microsoft vendor-specific options applicable to Windows 98 and Windows 2000 Clients» 4d534654 1 b
с. Написать скрипт и выполнить на Server1 (в данном примере его ip 192.168.0.12)
Пример скрипта:
(для создания, открыть Блокнот, по данному примеру написать скрипт и сохранить в расширении *.bat)
netsh Dhcp Server 192.168.0.12 Delete Class «Класс маршрутиз. и удал. доступа по умолчанию» «Пользовательский класс для клиентов удаленного доступа» 525241532e4d6963726f736f6674 0 b
netsh Dhcp Server 192.168.0.12 Delete Class «Класс BOOTP по умолчанию» «Пользовательский класс для BOOTP-клиента» 424f4f54502e4d6963726f736f6674 0 b
netsh Dhcp Server 192.168.0.12 Delete Class «Параметры Microsoft Windows 2000» «Параметры, зависящие от поставщика, для клиентов Windows 2000» 4d53465420352e30 1 b
netsh Dhcp Server 192.168.0.12 Delete Class «Параметры Microsoft Windows 98» «Параметры, зависящие от поставщика, для клиентов Windows 98» 4d534654203938 1 b
netsh Dhcp Server 192.168.0.12 Delete Class «Параметры Microsoft» «Параметры, зависящие от поставщика и применимые для клиентов Windows 98 и Windows 2000» 4d534654 1 b
netsh Dhcp Server 192.168.0.12 Add Class «Default Routing and Remote Access Class» «User class for remote access clients» 525241532e4d6963726f736f6674 0 b
netsh Dhcp Server 192.168.0.12 Add Class «Default Network Access Protection Class» «Default special user class for Restricted Access clients» 4d5346542051756172616e74696e65 0 b
netsh Dhcp Server 192.168.0.12 Add Class «Default BOOTP Class» «User class for BOOTP Clients» 424f4f54502e4d6963726f736f6674 0 b
netsh Dhcp Server 192.168.0.12 Add Class «Microsoft Windows 2000 Options» «Microsoft vendor-specific options for Windows 2000 Clients» 4d53465420352e30 1 b
netsh Dhcp Server 192.168.0.12 Add Class «Microsoft Windows 98 Options» «Microsoft vendor-specific options for Windows 98 Clients» 4d534654203938 1 b
netsh Dhcp Server 192.168.0.12 Add Class «Microsoft Options» «Microsoft vendor-specific options applicable to Windows 98 and Windows 2000 Clients» 4d534654 1 b
(Всё это нагляднее видно если скопировать в Блокнот и отключить перенос по словам)
DHCP Server Migration: Migrating the DHCP Server Role
Applies To: Windows Server 2008, Windows Server 2012 R2, Windows Server 2012
Complete the following procedures to migrate a DHCP Server.
Migrating DHCP Server to the destination server
Membership in Domain Administrators or equivalent is the minimum required to complete these procedures. Review details about how to use the appropriate accounts and group memberships at Run a program with administrative credentials (https://go.microsoft.com/fwlink/?LinkId=131210).
To migrate DHCP Server to the destination server
If it is not already installed, install DHCP Server on the destination server, as previously described in the “Prepare the destination server” section in DHCP Server Migration: Preparing to Migrate.
If it is running, stop the DHCP Server service by running the following command:
If you are unsure whether the service is running, you can check its state by running the following command:
Migrating DHCP Server from the source server
Follow these steps to migrate DHCP Server from the source server.
To migrate DHCP Server from the source server
Open a Windows PowerShell session with elevated user rights. To do this, click Start, click All Programs, click Accessories, open the Windows PowerShell folder, right-click Windows PowerShell, and then click Run as administrator.
Load Windows Server Migration Tools into your session.
If you opened the current session by using the Windows Server Migration Tools shortcut on the Start menu, skip this step, and go to step 3. Only load the Windows Server Migration Tools snap-in in a session that was opened by using some other method, and into which the snap-in has not already been loaded. To load Windows Server Migration Tools, type the following, and then press Enter.
Collect data from the source server by running the Export-SmigServerSetting cmdlet as an administrator. The Export-SmigServerSetting cmdlet parameters can collect all source DHCP server data in a single file (Svrmig.mig). Or, the Export-SmigServerSetting cmdlet can be run multiple times, with each iteration using one or more parameters to collect and store data in multiple Svrmig.mig files. For more information, see DHCP Server Migration: Preparing to Migrate. Before you run this command, review the following:
When you run the command in step 4, you are prompted to provide a password to encrypt the migration store data. You must provide this same password to import from the migration store.
The path parameter can be an empty or nonempty directory. The actual data file in the directory (Svrmig.mig) is created by the Export-SmigServerSetting cmdlet. Therefore, the user does not have to specify a file name.
If the path is not a shared location that the destination server can read from, you must manually copy the migration store to the destination server or a location that the destination server can access.
If a migration store location already exists and you want to rerun the Export-SmigServerSetting cmdlet, you must move the Svrmig.mig file from that location and store it elsewhere, rename or first delete the migration store.
You can perform both IP and DHCP Server migration at the same time from a Windows PowerShell prompt by using the Export-SmigServerSetting cmdlet combined with the IPConfig switch, on a single command line.
Additional command line parameter information:
-Users and -Group parameters
The -Users parameter must be specified only if the DHCP Administrators group includes local users. Otherwise, you can use the -Group parameter and all members of DHCP administrators will be migrated. Administrator group members can include domain users.
If the source server is a domain controller, but the destination server is not, Domain Local groups are migrated as local groups, and domain users are migrated as local users.
The -IPConfig parameter collects IP information when it is used with the Export-SmigServerSetting cmdlet on the source server; the -IPConfig parameter applies settings when the Import-SmigServerSetting cmdlet is used on the destination server.
If the source DHCP Server has multiple network adapters and the DHCP server service is bound to more than one network adapter and serving IP addresses on different subnets, the destination DHCP Server must also have multiple network adapters so that it can serve the same subnets as the source DHCP Server. For more information, see Migrate IP Configuration to Windows Server 2012. Because IP configuration details will be used later when importing IP configuration settings to the destination server, it is a best practice to save the IP configuration settings by using the following command:
The Import-SmigServerSetting cmdlet requires you to map the source physical address to the destination physical address.
The destination server can be assigned the same static IP address as the source server, unless other roles on the source server must continue to run on it. In that case, the static IP address of the destination server can be any unallocated static IP address in the same subnet as the source server.
On the source server, run the Export-SmigServerSetting cmdlet, where is the path that will contain the Svrmig.mig file after this step is completed. An example of the path is \\fileserver\users\username\dhcpstore.
For more information about how to export IP configuration settings, see Migrate IP Configuration to Windows Server 2012.
On the source server, delete the DHCP authorization for the source DHCP server by running the following command, where Server FQDN is the fully qualified domain name (FQDN) of the DHCP server and Server IPAddress is the IP address of the server. The command parameters are case-sensitive and must appear exactly as shown.
Destination server final migration steps
Return to the destination server and follow these steps to complete the migration.
Before you use the Import-SmigServerSetting cmdlet to import the DHCP server settings, be aware of the following conditions:
You can either use a single command line with all the parameters to import DHCP settings (as when you export data from the source server) or you can use the Import cmdlet multiple times to import data one parameter at a time.
If you decide to run the Import-SmigServerSetting cmdlet separately to import the IP settings, see Migrate IP Configuration to Windows Server 2012. Use the source IPSettings.txt file, referred to in step 3 of the previous procedure. You will map the source physical addresses to the destination physical addresses in step 3 of this procedure.
If you will be importing role and IP settings separately, you should import IP settings first to avoid any IP conflicts. You can then import the DHCP role.
If the DHCP Administrators group includes local users, then use the -Users parameter combined with the -Group parameter to import local users into the DHCP Administrators group. If it only contains domain users, then use only the -Group parameter.
|
---|