Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Why don’t you set the proxy in Firefox preferences? – AliNa Mar 6 '13 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 '13 at 5:54

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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