Friday, January 9, 2009

Using Netsh to configure IP settings

To get the IP automatically using DHCP use this command:
netsh int ip set address
"local area connection" dhcp

To get the DNS server address automatically:
netsh int ip set dns
"local area connection" dhcp

local area connection can have any name. Just look in your control panel>Network Connections for the correct name.

To set a static IP address use this command:
netsh
interface ip set address "Local Area Connection" static ipaddr subnetmask gateway metric

NOTE: Replace ipaddr with the static IP address, subnetmask with the subnet mask, gateway with the default gateway and, if necessary, metric with the appropriate metric.

The following example changes the interface "Local Area Connection" to a static address of 192.168.0.10 with a subnet mask of 255.255.255.0, and the interface has a default gateway of 192.168.0.1 with a metric of 1:

netsh interface ip set address "Local Area Connection" static 192.168.0.10 255.255.255.0 192.168.0.1 1
 

To change the DNS server address use:
netsh int ip set dns
"local area connection" static 192.168.0.254 primary

To add more DNS server addresses entries use:
netsh int ip add dns
"local area connection" 192.168.1.254

 

No comments:

Post a Comment