IP Config and Routing On Windows in Command Line
IP Config and Routing On Windows in Command Line
Local Area connection Configuration using netsh utility and IP static routing in
Windows command line
Prepared By
Vignesh Ramachandran
Engineer – Server Management
Email ID:‐ [email protected]
Command to Configure IP address, WINS address and DNS address to the interface Named NIC
(Default name is Local Area Connection)
Syntax:
netsh interface ip set address name=”<NIC card Name>” source=<static> or <dhcp> <Ip address>
<subnetmask> <gateway> <metric value>
Configuring Static IP
netsh interface ip set address NIC static 192.168.1.197 255.255.255.0 192.168.1.1 1
or
netsh interface ip set address name= NIC source=static addr=192.168.1.197 mask=255.255.255.0
gateway=192.168.1.1 gwmetric=1
Configuring DHCP
netsh interface ip set address NIC dhcp
or
netsh interface ip set address name=NIC source=dhcp
Configuring Primary DNS Address
netsh interface ip set dns name= NIC source=static addr=192.168.1.254 primary
Or
netsh interface ip set dns NIC static 192.168.1.254 primary
Obtain DNS address automatically
netsh interface ip set dns name= NIC source=dhcp
Or
netsh interface ip set dns NIC dhcp
Configuring WINS Address
netsh interface ip set wins name= NIC source=static addr=192.168.1.254
Or
netsh interface ip set wins NIC static 192.168.1.254
Obtain WINS address automatically
netsh interface ip set wins name= NIC source=dhcp
Or
netsh interface ip set wins NIC dhcp
Static IP Route
Adding a IP route
Syntax:
Route add <destination n/w> mask <destination n/w subnet mask> <gateway IP> metric <integer value>
if <interface number>
route add 192.168.2.0 mask 255.255.255.0 192.168.1.2 metric 3 if 1
Displaying the route table
route print
Changing the IP route
route change 192.168.2.0 mask 255.255.255.0 192.168.1.3 metric 2 if 1
Deleting the IP route
route delete 192.168.2.0