For some reaon I can't connect the internet via the school proxy. This only applies to apt-get, Firefox with automatic proxy detection works just fine. I already tried setting up the proxy in /etc/apt.conf.d/01-proxy and as export in my bash.rc, but neither of them worked.

  • Why don’t you set the proxy in Firefox preferences?
    – AliN
    Mar 6, 2013 at 21:53
  • As I said, it works in Firefox, but apt-get for example does not work, which is quite annoying.
    – Tom
    Mar 8, 2013 at 5:54

1 Answer 1


Open /etc/apt/apt.conf, or create it if it doesn't exist. Add the following code:

Acquire::http::proxy "http://username:password@proxyserver:port/";
Acquire::https::proxy "https://username:password@proxyserver:port/";
Acquire::ftp::proxy "ftp://username:password@proxyserver:port/";

To do this automatically on network startup, create a file called "zproxy" (or something along those lines) containing the following contents:


if [ "`sudo iwlist eth1 scanning | grep mySSID`" ]
    echo 'Acquire::http::proxy "http://username:password@proxyserver:port/";' > /etc/apt/apt.conf
    echo 'Acquire::https::proxy "https://username:password@proxyserver:port/";' >> /etc/apt/apt.conf
    echo 'Acquire::ftp::proxy "ftp://username:password@proxyserver:port/";' >> /etc/apt/apt.conf
    echo '' > /etc/apt/apt.conf

Replace mySSID with the SSID of your school's network, and "username:password@proxyserver:port" with the correct proxy settings. Put the file in /etc/network/if-up.d/ and mark it executable using

~$: sudo chmod +x /etc/network/if-up.d/zproxy

The bash script will run every time you connect to the network, and either append your proxy settings to /etc/apt/apt.conf or clear the file entirely.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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