Recommended Posts

At home I use a static IP (Router doesn't have DHCP reservations :() when when I connected to my school's Wifi it obviously didn't work as that network uses a different subnet than at home, so I had to change it to DHCP. When I got back home I lost my static IP and had to change it back.

Is there a way to make this process easier? Is there a way to do this in Windows, if not is there a third party program that can do this?

I am using Windows 7, but I would like to know if it can be done in older versions...

Link to comment
https://www.neowin.net/forum/topic/934898-change-ip-settings-based-on-ssid/
Share on other sites

  • 2 weeks later...

Well any even somewhat modern router should support reservations. If your doesn't then you have a few options.

1) Get a new modem/router that does

2) Run a different dhcp server on your network, turn the one on your modem/router off <- this can provide many other dhcp options that even routers with reservation support don't. Any windows server OS will have dhcp server, or can just use free one from BIND DHCP or simple windows program like http://tftpd32.jounin.net/

3) Just use a simple netsh command to change your interface between dhcp and static. Put in simple batch file, or get fancy with it and make it a autoIT script or something. Save the commands in different files depending on what you want, then just click the file that has whatever settings you want in it.

http://support.microsoft.com/kb/257748

How to Use the NETSH Command to Change from Static IP Address to DHCP in Windows 2000

Yeah I know its says win 2k, but work same on xp, vista, w7, etc. W7, Vista would have to run as elevated.

I have disabled IPv6 since have no need for it, and have renamed interface from default to LAN for easier access with scripts, etc.

You can also set dns to static or dhcp like this

netsh interface ip set dns "Local Area Connection" static 192.168.0.200

So as you can see settings are dhcp currently

**********

Microsoft Windows [Version 6.1.7600]

Copyright © 2009 Microsoft Corporation. All rights reserved.

C:\Windows\system32>ipconfig /all

Windows IP Configuration

Host Name . . . . . . . . . . . . : w7-test

Primary Dns Suffix . . . . . . . :

Node Type . . . . . . . . . . . . : Hybrid

IP Routing Enabled. . . . . . . . : No

WINS Proxy Enabled. . . . . . . . : No

DNS Suffix Search List. . . . . . : local.lan

Ethernet adapter Lan:

Connection-specific DNS Suffix . : local.lan

Description . . . . . . . . . . . : Intel® PRO/1000 MT Desktop Adapter

Physical Address. . . . . . . . . : 08-00-27-06-36-9B

DHCP Enabled. . . . . . . . . . . : Yes

Autoconfiguration Enabled . . . . : Yes

IPv4 Address. . . . . . . . . . . : 192.168.1.206(Preferred)

Subnet Mask . . . . . . . . . . . : 255.255.255.0

Lease Obtained. . . . . . . . . . : Monday, September 13, 2010 2:54:14 PM

Lease Expires . . . . . . . . . . : Sunday, September 19, 2010 2:54:18 PM

Default Gateway . . . . . . . . . : 192.168.1.253

DHCP Server . . . . . . . . . . . : 192.168.1.4

DNS Servers . . . . . . . . . . . : 192.168.1.4

192.168.1.253

NetBIOS over Tcpip. . . . . . . . : Enabled

C:\Windows\system32>netsh interface ip set address "Lan" static 192.168.1.220 255.255.255.0 192.168.1.253 1

C:\Windows\system32>netsh interface ip set dns "Lan" static 4.2.2.2

C:\Windows\system32>ipconfig /all

Windows IP Configuration

Host Name . . . . . . . . . . . . : w7-test

Primary Dns Suffix . . . . . . . :

Node Type . . . . . . . . . . . . : Hybrid

IP Routing Enabled. . . . . . . . : No

WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Lan:

Connection-specific DNS Suffix . :

Description . . . . . . . . . . . : Intel® PRO/1000 MT Desktop Adapter

Physical Address. . . . . . . . . : 08-00-27-06-36-9B

DHCP Enabled. . . . . . . . . . . : No

Autoconfiguration Enabled . . . . : Yes

IPv4 Address. . . . . . . . . . . : 192.168.1.220(Preferred)

Subnet Mask . . . . . . . . . . . : 255.255.255.0

Default Gateway . . . . . . . . . : 192.168.1.253

DNS Servers . . . . . . . . . . . : 4.2.2.2

NetBIOS over Tcpip. . . . . . . . : Enabled

C:\Windows\system32>netsh interface ip set address "Lan" dhcp

C:\Windows\system32>netsh interface ip set dns "Lan" dhcp

C:\Windows\system32>ipconfig /all

Windows IP Configuration

Host Name . . . . . . . . . . . . : w7-test

Primary Dns Suffix . . . . . . . :

Node Type . . . . . . . . . . . . : Hybrid

IP Routing Enabled. . . . . . . . : No

WINS Proxy Enabled. . . . . . . . : No

DNS Suffix Search List. . . . . . : local.lan

Ethernet adapter Lan:

Connection-specific DNS Suffix . : local.lan

Description . . . . . . . . . . . : Intel® PRO/1000 MT Desktop Adapter

Physical Address. . . . . . . . . : 08-00-27-06-36-9B

DHCP Enabled. . . . . . . . . . . : Yes

Autoconfiguration Enabled . . . . : Yes

IPv4 Address. . . . . . . . . . . : 192.168.1.206(Preferred)

Subnet Mask . . . . . . . . . . . : 255.255.255.0

Lease Obtained. . . . . . . . . . : Monday, September 13, 2010 3:05:14 PM

Lease Expires . . . . . . . . . . : Sunday, September 19, 2010 3:05:14 PM

Default Gateway . . . . . . . . . : 192.168.1.253

DHCP Server . . . . . . . . . . . : 192.168.1.4

DNS Servers . . . . . . . . . . . : 192.168.1.4

192.168.1.253

NetBIOS over Tcpip. . . . . . . . : Enabled

****************

4) Use some 3rd party tool that does same thing as 3 - but prob cost you money ;)

I was thinking a batch file could work, I could enter the commands once and run it as needed. Easier than typing in IP Settings over and over. Can you change the SSID from the command line too? That way I could just run the batch file instead of running it and switching networks the normal way.

As for the third party utility, that's why I made this thread to ask if anyone know any, but if not a batch file should be fine. Thanks....

If you manage to find another cheap wireless router somewhere, just plug it in to the network port on your old router, set it up and you should not have any problems at all since that new one will take over the DHCP stuff.

"Can you change the SSID from the command line too?"

Huh??

Not understanding why you would need to do this -- normally you bounce between wireless networks you set it up to auto connect to all of them.. So you should not have to tell it connect, just change if your ip is dhcp or static.

edit: But sure since vista you have been able to do all kinds of stuff with your wireless network from netsh

http://technet.microsoft.com/en-us/library/cc755301%28WS.10%29.aspx

  On 22/09/2010 at 03:46, offroadaaron said:

Yup there is and it's already been quoted!

Yes, quoted in bold saying that it's not an option...
  On 22/09/2010 at 03:46, offroadaaron said:
GET ANOTHER ROUTER!? I don't care about your excuse that you cannot get another one, because you can. <FULL STOP>

I can get another one, I already have another one, but I am using this one and that's final. It's something I have no control over.

Even if I had another router, I still would like to be able to change my IP Settings using a batch file because there are other situations where it can come in handy...

  On 22/09/2010 at 22:37, mpg187 said:

I can get another one, I already have another one, but I am using this one and that's final. It's something I have no control over.

Well then bad luck.

  On 22/09/2010 at 22:37, mpg187 said:

Even if I had another router, I still would like to be able to change my IP Settings using a batch file because there are other situations where it can come in handy...

Worst idea ever.

Personally I don't think think this thread is going to go anywhere as the solution has been provided but you are not willing to accept it. Building a batch file will is not scalable at all.

Yeesh, why are guys all up in this guys grill?

There's lots of reasons you might want to change IP and other network settings based on which network you're on - it's a very useful feature. It's stupid that people are just repeatedly yelling GET A NEW ROUTER without trying to be helpful ? again, I can think of a ton of reasons that getting a new router is unworkable.

Anyway, Mac OS X has this feature built-in (it's called "Locations"), but the switching isn't automatic.

post-330164-12852322046265.png

I haven't used any such software on Windows, but a Google search found a program called Mobile Net Switch - it may be what you're looking for.

I'm not sure if Windows 7 has locations in Mac OS X, I know it has some sort of location-awareness where it decides which Firewall rules to use (Home/Work/Public) but not sure if this can be extended to IP Address configuration. I know that in XP/Vista/7 etc. in the TCP/IP configuration there is an 'Alternate Configuration' where you can specify a Static IP if the DHCP fails. It might take a bit longer for things to work when you connect at home (wait for DHCP to fail) but you won't have to reconfigure.

Or why not just use DHCP at home? Why do you need a static address? If you need to forward ports, most software supports UPnP (or maybe your router is so rubbish that it doesn't to UPnP just as it doesn't do IP Address Reservations and you should get a new router as others suggest).

Or if you need to keep this router, get a second router (it doesn't need to be wireless) with DHCP enabled, plug it into the network, and turn off DHCP on the rubbish router.

Routers are not expensive, I hope that you don't want to get a new one just for cost reasons.

"Building a batch file will is not scalable at all. "

How many different connections do you think he would have?

You only need 1 command to set interface to dhcp.

Then one command per static settings or combo of dhcp and static dns - so 1 per location. Or 1 for static dns if you want, you could have 1 for opendns, one for googledns one for 4.2.2.2 if you wanted, etc. We are talking simple commands in one line here -- once you have command down, it would take 2 seconds to edit it for new IP, dns, etc.

Unless you are talking hundreds or thousands of locations that need specific static settings -- a netsh command is a pretty simple solution to his problem if you ask me. And could scale very nicely for say even 20 or 30 locations.

Just different commands in batch files in a folder.. Name the files per location --> Click on one for the location your currently at. Easy, Simple can have as many files as you have locations. So just not understanding your not scalable comment??

Maybe I misunderstood -- but thought he was talking about easy way to change his 1 computer.. Not something your going to roll out to hundreds of users, etc.

  • 1 month later...
  • 2 weeks later...
  On 23/09/2010 at 02:11, offroadaaron said:

Well then bad luck.

Worst idea ever.

Personally I don't think think this thread is going to go anywhere as the solution has been provided but you are not willing to accept it. Building a batch file will is not scalable at all.

What is the worst idea ever?
  On 23/09/2010 at 08:59, iKenndac said:
There's lots of reasons you might want to change IP and other network settings based on which network you're on - it's a very useful feature. It's stupid that people are just repeatedly yelling GET A NEW ROUTER without trying to be helpfu
Thank you!!!

Somewhat old thread has reared it's ugly head.

But anyway, would turning off DHCP on your current router / modem be an option?

If you can turn off DHCP you could then make use of the Alternative Configuration tab of the IPv4 properties of your Wireless NIC.

The Alternative Configuration tab is available from Windows XP onwards and allows you to specify the IP Address settings to use when a DHCP server cannot be contacted. To be able to see the Alternative Configuration tab you need to set your IPv4 settings to Obtain an IP Address automatically. Doing this would save having to have a batch file and remembering to run it, but it might make managing your home network slightly more annoying depending on how many devices you have connected and how many guests you have who connect to it occasionally.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.