Joined: 02 Feb 2004
|Posted: Thu Nov 23, 2006 9:37 am Post subject: HOWTO: Automatically set proxies based on network
|If you have to change locations a lot with your laptop (different companies, different networks, different proxy settings), this tip is for you:
A lot of programs can get their proxy settings from environment variables (http_proxy, ftp_proxy etc.). Amongst them are Gaim, wget, Google Earth, portage and Firefox/Thunderbird with this extension.
To automatically set these variables based on the network, follow these steps (this assumes that you use dhcpcd as your dhcp client):
- Create a directory /etc/proxy.d
- for each network, you want a proxy set, create a file in this directory with the ip address of the network, like /etc/proxy.d/126.96.36.199
create a file /etc/proxy.d/noproxy
create the following script /etc/dhcpc/dhcpcd.exe (it has to have that name, even it is not a binary) and make it executable
if [ "$2" = "new" ]
if [ -r /etc/proxy.d/$NETWORK ]
ln -sf /etc/proxy.d/$NETWORK /etc/profile.d/proxy.sh;
ln -sf /etc/proxy.d/noproxy /etc/profile.d/proxy.sh;
Now everytime you get a new ip address, your proxy settings change. If you move locations without rebooting, you have to log out and back in to get the new profile.