You are here

Windows commands to manage IP addresses

2 posts / 0 new
Last post
KG7LMI
KG7LMI's picture
Windows commands to manage IP addresses
I sent a lot of time today going back and forth on the IP address for my laptop while upgrading multiple nodes (using tftp). Rather than continue to flog at retyping the addresses in the Ethernet properties dialog box, I quickly hacked up 2 command (batch) files: one to set the static parameters for tftp and one to set everything back to DHCP. These are far from elegant, but they get the job done. The single parameter is the interface name, e.g. "Ethernet 3", "Local Area Connection", etc.

File if-static.cmd:
:: set interface parameters for Ubiquiti TFTP firmware upload
:: Usage if-static "Interface", e.g. "Ethernet 3"
:: run as administrator
netsh interface ip set address name=%1 static 192.168.1.254 255.255.255.0 192.168.1.20
netsh interface ip set dns %1 static 9.9.9.9
netsh interface ip show config %1

File if-dhcp.cmd:
:: Usage if-dhcp "Interface", e.g. "Ethernet 3"
:: run as administrator
netsh interface ip set address %1 dhcp
netsh interface ip set dns %1 dhcp
netsh interface ip show config %1
 

As noted, be sure to run these from an elevated command prompt, even if you are in the administrator group.

Enjoy.

Rob
 
KX5DX
ipconfig /flushdns
Another handy command when switching between nodes... and localnode resolution fails:
ipconfig /flushdns

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer