Ask Your Question
0

Automatic proxy setup on specific networks

asked 2015-05-06 10:01:35 -0600

mithrial gravatar image

My university requires me to use a proxy when connected to their Wifi.

Is there a way to configure a proxy that is automatically used when connected to specific networks? I couldn't find such an option in Network Manager.

Android has this option in its Wifi settings.

I'm using Cinnamon on F21 if that's important.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-05-10 23:51:36 -0600

Fahad Alduraibi gravatar image

If the IP range used at your school is different from your other networks then you can use PAC (Proxy auto-config) script, and set you browser to use it, also you can it as general proxy if your DE has such option, in KDE there is an option under Network Settings. In firefox you can set the path under Connections Settings: "Automatic proxy configuration URL". And i think the format for the file URL is something like this file://[path]/proxy_script.pac

The script simply checks if your IP matches the school IP range, it true then use a proxy otherwise it is a direct connection. Here is an example of such file:

function FindProxyForURL(url, host)
{ 
    if (isInNet(myIpAddress(), "192.168.1.0", "255.255.255.0") ||
        isInNet(myIpAddress(), "192.168.2.0", "255.255.255.0"))
    {
        return "PROXY proxy1.university.edu:8080; PROXY proxy2.university.edu:8080; DIRECT";
    }
    else
    {
        return "DIRECT";
    }
}
  • Don't change the function name, that is fix.
  • In the if statement isInNet will check if your machine IP is the specified range or not, here I used to ranges with 'or' || you can have only one or more to cover all ranges used bu your school.
  • If your IP matches any of the ranges it will return the proxies in the list, so your machine will try the first proxy if it fails will try the second. The third item 'DIRECT' is needed in case you are at a network that doesn't use a proxy but use similar addressing as your school so both proxies will fail and it will use direct connection.

Check wikipedia for more info: http://en.wikipedia.org/wiki/Proxy_au...

edit flag offensive delete link more

Comments

Thank you for the answer. With the addon FoxyProxy for Firefox it is really easy to setup the proxy with two clicks. But this configures the proxy only for Firefox. I also use Chrome and yum, dnf and several other programs (curl, wget, ...) and they all should respect the proxy setting.

On the console, I can do export http_proxy="http://proxy" and the programs are using it, but this is not automatically executed, and also not in sudo-environment.

mithrial gravatar imagemithrial ( 2015-05-12 08:38:12 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-05-06 10:01:35 -0600

Seen: 2,142 times

Last updated: May 06 '15