Batch files to switch between DHCP and Static IP

I made these batch files to switch between Static IP and DHCP in Windows. I use them because I use my laptop’s Wireless at school, and wired to program our robot, but at home I use the Wired.

To use them, just paste the commands in notepad and save as a .bat (EG: “cRIO Mode.bat” or “Internet Mode.bat”)

cRIO / Static IP Mode:

@echo off
netsh interface ip set address name="Local Area Connection" static 10.23.34.6 255.0.0.0 10.23.34.4 1
pause

NOTE: You need to change the addresses to your team number. We are 10.23.34.*, but you probably aren’t!

DHCP Mode:

@echo off
netsh interface ip set address "Local Area Connection" dhcp
pause

~DtD
PS> If you typically use a static IP when not talking to your robot, and you need to configure DNS servers too, then use these commands:

netsh interface ip set dns "Local Area Connection" static 208.67.222.222
netsh interface ip add dns "Local Area Connection" 208.67.220.220 index=2

That sets it to use OpenDNS…

1 Like

Thanks,

Been switching 4 times a day.

PGR

No problem, glad sombody else found it useful!

~DtD

Helps with more than just robotics. I have to switch all the time for various reasons. This will make life so much easier. Thanks.

I got tired of switching back from static to DHCP…

I found a way to set the router to hand out DHCP addresses at 10.XX.XX.6 so your laptop doesn’t have to switch to static.

DHCP router settings can be a problem if you have many laptops that are all trying to program and connect to the router at the same time.

Just a tip. If you try to do this with Windows 7 (and I believe Vista as well) the syntax will be slightly different.

netsh interface ip ....

becomes

netsh interface ipv4 ....

due to support for IPV6 addresses.

netsh /?

gives help info.

Just so you are aware, you only need to be 10.x.x.6 if you want to be the Dashboard machine.

You can download and/or run using any 10.x.x.* address. The Dashboard.VI even has a forwarding address to redirect that data to another machine.

We setup our wireless router to give out 10.x.x.50 and above IP addresses, so we can still DHCP setup.

10.x.x.1 Wireless Bridge on Robot
10.x.x.2 CRIO
10.x.x.3 Reserved
10.x.x.4 Wireless Router
10.x.x.5 Driver Station/Classmate
10.x.x.6 Development System

Last year a PC instead of the Classmate with an address of 10.x.x.6 could be used as a Dashboard display machine.

In general, I have noticed that the cRIO and friends are MUCH less finicky about what thier IPs are and such. We only used static for reimaging the cRIO. I have tested numerous network configurations, and both Windriver and the Driver Station (Updated One) seem to always find it.

EG: One of the configs I did was:
cRIO <-> WiFi Brick (The black one)

WiFi Router (One with the blue spoiler) <-> Internet

My dev laptop and Driver Station connected to WiFi router over WiFi. (DS needs to be updated or this fails, set up WiFi network in Developer)

If you do use WiFi with the Classmate, I HIGHLY advise you delete the WiFi profile before competition, the Classmate did not like it with WiFI attempting to work and connection over LAN.

~DtD

I use WinXP Professional at home and office. Although I have the same ISP at both, I am required to change the IP address depending on where I am.

I need one script or batch file that I can run under WinXP that will automatically change my IP from:

172.16.10.23 to 192.168.11.8

Then another script that will change it back.

Hopefully a simple problem if you know how!
Thanks

Yes, it should be simple. Just use the first command. I belive 10.23.34.6 is the ip address, and 10.23.34.4 is the gateway.

Just put in your addresses!

~DtD