In my work I have to connect to various equipment that uses different IP addresses in order to configure and monitor them. To make it easier for myself I have made a couple of script files so that I can change the IP address easily.
The first step before we can create the script file is finding the network adapter name. Don't worry. All we need is included in the Windows system.
Running the following command gives us an output like the below picture shows.
netsh interface show interface
As you can see the interface name is called "Local Area Connection". This name is important to us. We are going to use that to target the interface in our script file.
Alternatively we can use the following command to get the same and additional information.
netsh interface ip show addresses
The content of the file we need to make is quite simple. Let's say we want to use the static IP address 172.16.0.1/255.255.0.0, then the content of the file will be as follows:
netsh.exe interface ip set address name="Local Area Connection" static 172.16.0.1 255.255.0.0
On the other hand if we want to revert to a DHCP assigned IP address, then the following content will be needed:
netsh.exe interface ip set address name="Local Area Connection" dhcp
It will be quite easy to adopt this command to any IP address you might want to use.
Happy computing :-)