How to Configure Proxy Settings in Linux


Here are two ways to configure Linux to recognize a proxy server or proxy configuration file.

Operating System Level

Personal kneeling in stone tunnel, photo credit jondoe via flickr

photo credit: jondoe

Use the following commands to configure your proxy for http and ftp traffic on the command line
export http_proxy=http://<proxy host or IP>:<proxy port >
export ftp_proxy=http://<proxy host or IP>:<proxy port >

If your proxy requires login/authentication, you can use the format:
export http_proxy=http://username:password@:<proxy host or IP>:<proxy port >

To have this applied every time you log in, place these lines in your .bashrc in your home (~) directory.
export http_proxy=http://<proxy host or IP>:<proxy port >
export ftp_proxy=http://<proxy host or IP>:<proxy port >

System-Wide Proxy Settings can be set in your Network Settings

For GNOME, go to Computer->Desktop Preferences->Network Proxy
For KDE desktop manager, you can get to the network proxy settings under System Settings > Network Settings > Proxy

In the setting you can configure either by your proxy server and port, by the network, or a file via a URL/file location (e.g. http://myproxyserver:port/proxyfile.pac) .

These setting work with most other applications (e.g. other browsers like Chrome, OS commands).

Program/Application Level

Some applications and commands will not pick up the system wide proxy settings, so you have to configure each program you use. Below are some common examples.

Firefox

Occasionally, Firefox does not pick up the operating system proxy setting.
You can manually set up the Firefox proxy in Options menu. Go to Options > Advanced > Settings.

Fedora – Yum Package Manager

yum proxy settings can be found in the file system at
/etc/yum.conf

Add a line to the file with the following information:
proxy=http://<proxy IP>:<proxy port >
The next time you run yum, it will pick up that proxy.

For Ubuntu

Here is a similar how to article on configuring proxy settings in Ubuntu covering Synaptic Package Manager, Gnome, apt-get, and Firefox.

About these ads

3 thoughts on “How to Configure Proxy Settings in Linux

  1. Pingback: Proxy Servers | Linux Academy

    • hi frostwong, that’s an awesome question with several answers.

      First we have to understand http_proxy and ftp_proxy are *environment variables* used by the shell (e.g. bash, sh) that can be set on the local user level and global level. The variables are an easy way to share configuration settings between multiple Linux applications and processes. The export command sets those variables.

      You could set the shell environment variables using the export command in various files such as ~/.bash_profile or ~/.profile or /etc/profile (the exact names of these files may vary with the Linux distribution). By adding those export statements to the profile files, the variables will be set up for your local user session or all global sessions.

      Remember some applications like the Fedora yum package manager store their own proxy settings in an application file, so you can modify the setting in that application’s configuration file.

      Learn more about environment variables and other system configuration files here: https://wiki.archlinux.org/index.php/environment_variables
      The article explains them from a general Linux perspective.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s