Set IP Address / DNS / Route in CMD

I know once in a while we all have to use our CMD skill to set some stuff up in machines. So here is some command to get windows machine online via CMD.

****First you need to locate the name of the network interface

netsh interface ipv4 show interfaces

***Assume that you want to setup a static IP such as below

  • IP:172.28.5.10
  • sub:255.255.255.0
  • GW: 172.28.5.1

netsh interface ip set address name=”Local Area Connection” static 172.28.5.10 255.255.255.0 172.28.5.1 1

Note that ” local area connection” is the one I found when I ran very first command and “1” in the end is the metric for route.

If you want to forget about the static rout and want to get DHCP,

netsh interface ip set address name=”Local Area Connection” dhcp

****Now if you want to set a static DNS,

netsh interface ip set dns name=”Local Area Connection” static 8.8.8.8

Second DNS

netsh interface ip add dns name=”Local Area Connection” 8.8.4.4 index=2

Again if you want to get DNS via DHCP

netsh interface ip set dnsservers name=”Local Area Connection” source=dhcp

DONE,your PC will be one line!!. Yes of course you need to plug the network cable 🙂