Here we will examine how to set proxy settings in RHEL 5 or 6. This will also work for centOS 5 and 6 as well as most versions of Fedora.
We will cover the following three topics:
- Setting the proxy via Gnome GUI
- Setting the proxy via command line
- Configuring YUM to use our proxy
Setting the proxy via Gnome GUI (Linux Control Panel Applet)
From your desktop click System > Preferences > Network Proxy
This will bring up the following dialog box.
Most companies that run a proxy server will offer an auto configuration URL. This URL usually leads to a “proxy.pac” or “wpad.dat” on a web server. This is the preferred way of offering a proxy configuration since it allows flexibility to the system administrator to dynamically change your settings.
If you have been provided an auto configuration URL you can enter it here. If no URL has been provided check the “Manual proxy configuration” and enter the hostname and port for each protocol.
Learn more about WPAD (Web Proxy Autodiscovery Protocol) you can start with an overview at the WPAD WikiPedia Page.
Linux proxy settings differ from the way Windows handle’s proxy settings. In Windows if you set the proxy in Internet Explorer then it is a system wide setting. In Linux you will still need to tell other applications about your new proxy settings, including your browser.
Open Firefox (default web browser for RHEL) and select Preferences > Network > Connections.
Select the radio box that says “Use system proxy settings”.
Optionally you can also enter the same auto configuration URL you used above in the “Automatic Proxy Configuration URL” box in the above screen. Another option is to set the proxy manually in the browser as well.
Setting the proxy via command line
In order to use HTTP/HTTPS proxy settings via the command line you will need to set the http_proxy environmental variable. The auto configuration URL you used above will not work when setting an environmental variable.
YOU MUST USE THE DIRECT FQDN FOR THE PROXY FOLLOWED BY THE PORT NUMBER.
You can set this via the command line like so:
[savona@devel ~]$ http_proxy=http://webserv.domain.com:8080
To confirm the variable is set correctly you can use the “echo” command:
[savona@devel ~]$ echo $http_proxy
http://webserv.domain.com:8080
Remember that if you set the variable via the command like described above it is only valid for the current shell. If you open a new shell, or logout the variable will be unset. To make this setting available in all future shell instances we can export the variable via the .bash_profile file.
Setting the proxy to be available in all shell instances.
NOTE: The .bash_profile file is a hidden file in your home directory. In your favorite editor open the .bash_profile file for editing.
(example: vi ~/.bash_profile)
Add the following lines to the end of the file:
http_proxy=http://webserv.domain.com:8080
export http_proxy
NOTE: This must be done for each individual user, including root.
Configuring YUM to use a proxy
To configure “yum” to use the HTTP / HTTPS proxy you will need to edit the /etc/yum.conf configuration file. Open /etc/yum.conf in your favorite editor and add the following line.
proxy=http://webserv.domain.com:8080
Save and close the file, then clear the cache used by yum with the following command:yum clean all
If your proxy requires authentication, you can configure yum to use proxy authentication by adding/changing the following lines in /etc/sysconfig/rhn/up2date:
enableProxy=1
enableProxyAuth=1
proxyPassword=UserPassword
proxyUser=UserName
httpProxy=http://webserv.domain.com:8080
Recommended Articles:
How to use wget with a proxy server
How to set the http_proxy variable in Linux
Leave a Reply Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
13 Comments
Join Our Newsletter
Categories
- Bash Scripting (17)
- Basic Commands (50)
- Featured (7)
- Just for Fun (5)
- Linux Quick Tips (98)
- Linux Tutorials (65)
- Miscellaneous (15)
- Network Tools (6)
- Reviews (2)
- Security (32)
I'm using Linux Oracle (redhat) and after configuring the proxy on Firefox, i've tried to configure it on shell but it just don't work.
Firefox is working fine with the exactly proxy, but I can't ping or connect YUM...
@Daniel - Did you follow the directions above?
It should work without issue. Are you actually able to telnet to the proxy servers port from the command line and get a connection directly from the commandline? telnet proxy_server_IP PORT_Number.
Example: telnet host port
If that works ensure you have http_proxy exported and try to get a file from a webserver on the internet via the wget command.
Example:
wget http://some_site/some_file
If you are able to get the file via "wget" you know the environment variable http_proxy is set and the proxy is taking requests from your host via the commandline.
Hey how about if we have authentication on the proxy?
Another wrinkle: suppose you're using your DHCP server to publish the prxy/WPAD information usingthe fairly well-known DHCP option 252? This doesn't seem to get set anywhere in Network Manager or in the GNOME Proxy configuration. Any ideas?
@Thomas - WPAD (Web Proxy Autodiscovery Protocol) is only meant to inform browsers of proxy settings. It is basically written by MicroSoft, and as we all know MS uses the proxy setting in the browser as the system proxy as well.
http://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol
In order to configure yum behind a proxy, we set:
/etc/yum.conf
proxy=http://:/
proxy_username=
proxy_password=
/etc/sysconfig/rhn/up2date
enableProxy=1
httpProxy=http://:
enableProxyAuth=0
(or if user and passwd are necesary)
enableProxyAuth=1
proxyPassword=
proxyUser=
/etc/rhsm/rhsm.conf
proxy_hostname =
proxy_port =
(if necesary)
proxy_user =
proxy_password =
@Savona: After searching around some more, it looks like what I'm wanting to do isn't possible with the current state of Linux Network Manager and WPAD.
https://mail.gnome.org/archives/networkmanager-list/2013-June/msg00077.html
Ummm, no? While it's true that Windows tends to use the OS-level proxy information as the browser proxy (not the other way around), If you read the draft spec, the proxy information is supposed to be updated every time the network configuration on the client undergoes a change. This is at the OS level. I'm suspecting that the Linux Network Manager stack simply ignores the proxy information at this point, so it doesn't get distributed down to the application level.
http://tools.ietf.org/html/draft-ietf-wrec-wpad-01
Oh, and reps from SUN, RealNetworks and Intomi were also on this draft. So, sweeping generalizations aside, I thought WPAD had better adoption at this point.
how to set proxy in backtrack client computer !
Network Manager stack simply ignores the proxy information at this point, so it doesn't get distributed down to the application level.
Mujhe proxy IP banana sikhana h plz help
I am sorry, I used google translate but still don't know how I can help.