Specific static IP settings on different WiFi

I've been trying to set a static IP address for myself. My router details are as following:

Wireless LAN adapter Wi-Fi:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::4c77:ef95:76:961b%13
   IPv4 Address. . . . . . . . . . . : 192.168.1.16
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.1.1

I set the static IP address to 192.168.1.50. However, since I go to school and connect to my own access point I set up there, the IP it gives me is 172.168.1.2 (without a static IP). My question is, can I configure my Wifi adapter to set a static IP address only if I'm connected to my home network?


Solution 1:

I am assuming you're on Windows. If not then please correct. If you go into:

Network and Sharing Centre > Right click Wireless adapter > Properties > Select IPv4 > Properties.

In there configure your primary network settings under the general tab (probably obtain IP automatically) and under Alternative specify the information related to your other network.

Hope this helps

EDIT: So using alternative IP. Generally speaking you would configure your alternative configuration to specify settings when a DHCP server is not present (and cannot collect an IP automatically). If this is the case for you then set the primary to collect an IP automatically (for your school network) and assign manual configuration to alternative when at home.

If, however, this doesn't work you can probably assign both networks manually, but this would depend how your school network runs. I assume you won't be able to specify a manual connection if there are several hundred systems on the network. Be aware though, as pointed out below, once you start specifying static network configurations you won't be able to use your system anywhere else without resetting the network.

Solution 2:

Depends on what you mean.

If you mean, can I set myself up with a static IP at all? The answer is yes, always.

If what you mean is: can I set up myself to have always the same IP address, the answer is no: the reason is that you will have different subnets in different places. You have 192.168.1.0/24 at home, but 172.168.1.0/24 at school. Next time you go to an Internet cafè, you may find a subnet 192.168.0.0/24, or 10.10.0.0, and so on. Having the same IP address on these different subnets makes it impossible to use them, since the number you chose for yourself, 192.168.1.50, belongs to your home subnet but does not belong to any other subnet mentioned above.

This is the reason why most people do not use static IPs on wifi; the most common use for static IPs is in devices which cannot be moved, so they belong by definition always to the same network: dekstops, servers, routers, printers, TVs, and so on.

Solution 3:

It depends on your router/ap if it supports this for not, but you should be able to DHCP reservation using the MAC address for your wireless card and assigning it an IP (192.168.1.50 in this case).

Solution 4:

my personal tool for this issue:

https://github.com/xzer/wlanprofilemanager

it allows you to define static ip or dhcp on different SSID, and to be configured automatically.

Solution 5:

Here's a way to have static IP on one SSID but not others. The basic idea is that you create a Windows Task Manager task to run when you connect to a new network, which then runs a batch file that checks which SSID you've connected to. If it detects the special SSID it sets static IP and otherwise it sets dynamic IP.

If you have more than one SSID with different static IP settings, you can generalize this.

Detailed instructions:

  1. Create wlanconnect.bat in \users\YourUserName with the following contents:
    netsh wlan show interfaces | findstr /R /C:"SSID *: SPECIALSSID$" if errorlevel 1 goto notAtHome netsh interface ip show address "Wi-Fi" | findstr /R /C:"DHCP enabled: *No" if not errorlevel 1 goto end netsh interface ip set address "Wi-Fi" static 192.168.1.223 255.255.255.0 192.168.1.1 rem netsh interface ip set dns "Wi-Fi" static 8.8.8.8 goto end :notAtHome netsh interface ip show address "Wi-Fi" | findstr /R /C:"DHCP enabled: *Yes" if not errorlevel 1 goto end netsh interface ip set address "Wi-Fi" dhcp rem netsh interface interface ip set dns "Wi-Fi" dhcp :end
    Here, replace SPECIALSSID with the SSID you want the static IP for, and replace 192.168.1.223 255.255.255.0 192.168.1.1 with your static IP, your subnet mask and your gateway. I have my DNS set to 8.8.8.8/8.8.4.4 for all connections. If you want to have static DNS settings just for your special SSID, remove the rem before the two netsh ... dns commands.

  2. Start Task Manager (win-R, taskschd.msc, enter)

  3. Click on Create Task

  4. Under Name put: Toggle Static IP

  5. Click Change User or Group, type in SYSTEM, and click OK

  6. Switch to Conditions tab and uncheck Start the task only if computer is on AC power

  7. Switch to Triggers tab and click on New...

  8. Under Begin the task choose On an event

  9. Under Log choose Microsoft-Windows-NetworkProfile/Operational

  10. Under Source choose NetworkProfile

  11. Under Event ID put 10000

  12. Click OK

  13. Switch to Actions tab and click on New...

  14. Under Program/script browse to your \users\YourUserName\wlanconnect.bat file

  15. Press OK and OK again. You will be prompted for your password.