19 December 2017
Change Windows network IP address using console
The’s a way to change network configuration using Windows console, with this option you can set a new IP addess or switch bettwen static and dhcp, Another interesting point of this is that you can do the same remotely using PsExec , I wrote a post time ago axplanating how it works, you can found just here.
First of all we need to know the name of desired interface, to do this we can execute the following command
1 |
netsh interface ipv4 show config |
After this we are able to change the interface configuration using this command
1 |
netsh interface ipv4 set address name="YOUR INTERFACE NAME" static IP_ADDRESS SUBNET_MASK GATEWAY |
For example:
1 |
netsh interface ipv4 set address name="Ethernet" static 192.168.1.13 255.255.255.0 192.168.1.1 |
Or if you want to change an static ip to dhcp you can use:
1 |
netsh interface ipv4 set address name=”Ethernet” source=dhcp |
You can define a new DNS servers too, this command is for primary one:
1 |
netsh interface ipv4 set dns name="Ethernet" static 8.8.8.8 |
And this will change the secondary:
1 |
netsh interface ipv4 set dns name="Ethernet" static 8.8.4.4 index=2 |
To set DNS using DHCP we will use:
1 |
netsh interface ipv4 set dnsservers name"Ethernet" source=dhcp |
That’s all, hope you’ll find this useful