By creating a batch file of Netsh commands you can automate the creation of DHCP scopes.
By creating a batch file of Netsh commands you can automate the creation of DHCP scopes. For example, the following batch file creates a scope 172.16.11.0 with address range .220 through .250, exclusion range .225 through .230, excluded single address .244, reserved address .133, and default gateway .1 on DHCP server 172.16.11.30:
REM -- Batch file to create a scope on a DHCP server
REM
REM -- Create scope 172.16.11.0 on DHCP server 172.16.11.30
netsh dhcp server 172.16.11.30 add scope 172.16.11.0 255.255.255.0 "Main Office"
REM
REM -- Assign address range 172.16.11.220 to 172.16.11.250 to new scope
netsh dhcp server 172.16.11.30 scope 172.16.11.0 add iprange 172.16.11.220 172.16.11.250
REM
REM -- Exclude address range 172.16.11.225 through 172.16.11 230 from new scope
netsh dhcp server 172.16.11.30 scope 172.16.11.0 add excluderange 172.16.11.225 172.16.11.230
REM
REM -- Exclude single address 172.16.11.244 from new scope
netsh dhcp server 172.16.11.30 scope 172.16.11.0 add excluderange 172.16.11.244 172.16.11.244
REM
REM -- Reserve address 172.16.11.133 for mail server
netsh dhcp server 172.16.11.30 scope 172.16.11.0 add reservedip 172.16.11.133 0003FF54888C
REM
REM -- Configure scope option 003 to assign default gateway of 172.16.11.1 to clients
netsh dhcp server 172.16.11.30 scope 172.16.11.0 set optionvalue 003 IPADDRESS 172.16.11.1This sample batch file can also be found in my book Windows Server 2008 Server Core Administrators Pocket Consultant from Microsoft Press.
No comments:
Post a Comment