February 9, 2007

Windows 2003 - Move dhcp scopes

How to move a dhcp scope from one windows 2003 server to another.

1. Export SCOPES from original server ( scopes 10.1.1.1 and 10.2.2.2 )
netsh dhcp server export scopes.txt 10.1.1.1 and 10.2.2.2

2. Import scopes on new server
netsh dhcp server import scopes.txt all

3. Change DHCP scope options
for %i in (10.1.1.1 10.2.2.2 ) do netsh dhcp server \servername scope %i set optionvalue 006 IPADDRESS new_dns_ip new_dns2_ip ( DNS )

for %i in (10.1.1.1 10.2.2.2 ) do netsh dhcp server \servername scope %i set optionvalue 044 IPADDRESS new_wins_ip new_wins2_ip ( WINS )

4. Disable scopes on old server
for %i in (10.1.1.1 10.2.2.2 ) do netsh dhcp server \servername scope set state 0

5. Enable scopes on new server
for %i in (10.1.1.1 10.2.2.2 ) do netsh dhcp server \servername scope set state 0

6. Delete scopes on old server ( BACKUP FIRST !!! )
for %i in (10.1.1.1 10.2.2.2 ) do netsh dhcp server \servername delete scope %i