up vote 9 down vote favorite
6
share [g+] share [fb]

Moving my LapTop between work and home I need to change my internet proxy settings. Is there any build in way for windows 7 to change these settings based on my currently active network?

link|improve this question
1  
Owh I'd so like my laptop to do the same, just too lazy to look for the answer :-( – Ivo Flipse Sep 24 '09 at 6:15
feedback

3 Answers

You could set this up with a PAC (Proxy Auto Configuration script). They're small scripts written in Javascript that let you specify various connection rules. Most modern desktop web browsers can read them with no problem, I have the same one set up in both Internet Explorer and Firefox.

This is an example of a PAC file that checks which network you're on by checking what IP address range you've picked up. In this example all client PCs in your company are given an IP address in the 10.10.* range by DHCP and access the internet via the proxy server proxy.companyname on port 81.

//Turn debug mode on by setting debug variable to any non-empty string
//Note that "" is an empty string, and that "0", "1" & "test" are not empty strings.


function FindProxyForURL(url, host)
  {
    var ip = myIpAddress();
    var debug = "";

    if(debug)
    {
        alert("proxy.pac IP=" + ip + "  HOST=" + host + "  URL=" + url);
    }

      // All client PCs on the internal network will have a 10.10.x.x address, check if I have this
     if (shExpMatch(ip, "10.10.*"))
     {
             if(debug)
          {
                 alert("Proxy for " + url);
             }
     return "PROXY proxy.companyname:81";
     }

     // If you have a different IP then this isn't the company network
     else 
     {
             if(debug)
          {
      alert("You are not at CompanyName so going direct for " + url);
             } 
            return "DIRECT";
     }

  }

The script also has a debug mode that you can use to test that it is working and which mode (PROXY or DIRECT connect) it thinks your current connection should be.

You could also make a more complex script that checks things like if the server you're connecting to is on your internal company network (and thus wants a DIRECT connection, even though your PC is currently on the company network) this is where you'd put anything you normally put in IE's proxy exceptions box, by expanding it like so:

//Turn debug mode on by setting debug variable to any non-empty string
//Note that "" is an empty string, and that "0", "1" & "test" are not empty strings.


function FindProxyForURL(url, host)
  {
    var ip = myIpAddress();
    var debug = "";

    if(debug)
    {
        alert("proxy.pac IP=" + ip + "  HOST=" + host + "  URL=" + url);
    }

    // Detect if trying to connect to internal/intranet host
    if(isPlainHostName(host) || dnsDomainIs(host, "intranet.companyname"))
    {
 if(debug)
 {
            alert("Direct for " + url);    
     }
    return "DIRECT";   
    }

    // Detect if trying to connect to URLs on the internal network via internal DNS suffix or IP address
    if(shExpMatch(url, "*.companyname") || shExpMatch(host, "10.100.*"))
    {
 if(debug)
 {
     alert("Direct for " + url);
 } 
        return "DIRECT";    
    } 

     // All client PCs on the internal network will have a 10.10.x.x address, check if I have this
     if (shExpMatch(ip, "10.10.*"))
     {
             if(debug)
          {
                 alert("Proxy for " + url);
             }
     return "PROXY proxy.companyname:8080";
     }

     // If you have a different IP then this isn't the company network
     else 
     {
             if(debug)
          {
      alert("You are not at CompanyName so going direct for " + url);
             } 
            return "DIRECT";
     }

  }

Use this file by saving it somewhere on your PC's C drive as something like proxy.pac, then for Internet Explorer, go to Tools -> Options (or Control Panel -> Internet Options) then click the Connections tab, click the LAN Settings button. Now take the tick out of the "Use a proxy server" box at the bottom, and instead put a tick in "Use automatic configuration script" and type in the address of your PAC file using a file:// URL like file://C:/proxy.pac.

IE proxy settings

Alternatively for Firefox go to Tools -> Options, click the Advanced tab, click the Network tab, click the Settings button, click the "Automatic proxy configuration URL" setting, again using a file:/// URL (note that in Firefox there are 3 slashes after the colon, eg file:///C:/proxy.pac.

Firefox proxy settings

link|improve this answer
That's pretty cool until you get onto another public wireless network using the same private IP range as I happen to use at my house. :) – dannysauer Dec 11 '11 at 2:37
feedback

Use Free IP Switcher 1.0

alt text

Description:

Whenever mobile user moves to different network, has to change particular IP address, gateway address, subnet mask, proxy server and default printer, etc., to particular network environment. In order to do it, he has to remember TCP/IP settings information of every network. Also, he has to reboot the computer to apply it to the system and to access the Internet.

Don't waste your time reconfiguring computer network settings every time you change your location. Free IP Switcher is a perfect solution for you. It switches between preconfigured network settings with a single click and without any reboot. With Free IP Switcher you can automatically change all network settings on your pc: IP address, network masks, default gateway, DNS server, wins server, proxy settings, default printer and more.

Features:

  • Switch IP network settings "on the fly" without restarting
  • Switch Internet Explorer proxy-server settings
  • Switch your default printer
  • Switch your computer name and workgroup
  • Import current network settings to the setting
  • System-tray icon support, auto-start with windows
  • 100% Spyware FREE, NOT contain any Spyware, Adware or Viruses
link|improve this answer
1  
I can't believe that something as useful as network configuration profiles has not already been made part of Windows 7. Ubuntu has it, Mac OS X has it . . . – dreamlax Sep 24 '09 at 7:40
I know Dell made such a tool for my Latitude, but I disliked it :-( – Ivo Flipse Sep 24 '09 at 8:20
The download version do not work for Windows / – Hakan Forss Sep 26 '09 at 10:38
feedback

You have other (paid) alternatives to switching network configurations, like Mobile Net Switch or NetSetMan

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.