Learn how to configure proxy in Linux flavors like RHEL, SUSE, OEL, CentOS, Ubuntu etc.
One of the basic task after building a new system in your environment is to setup proxy to enable internet access on server. In this tutorial we will walk you through step by step how to configure internet proxy in major Linux flavors like RHEL, Suse, OEL, CentOs, Ubuntu etc. Without further delay lets jump in –
How to setup proxy in Linux using shell variables
Typically you can setup internet proxy details using shell variable
http_proxy. Syntax is below –
# export http_proxy=http://username:password@proxy-servername:port/
For example, lets consider below proxy server details which we need to configure.
- Proxy server : kerneltalks-proxy.com
- Port : 8081
- Username : shrikant
- Password : @Fnr5*r$9Lp
Above proxy uses authentication so we can define it as –
root@kerneltalks # export http_proxy=http://shrikant:@Fnr5*r$9Lp@kerneltalks-proxy.com:8081/
If you do not have authentication at proxy then it can be defined as :
root@kerneltalks # export http_proxy=http://kerneltalks-proxy.com:8081/
Above proxy configuration is for the current user only. To configure proxy for all users on system, just add above command entry into
/etc/profile file on your system and it will be applicable/available to all users on system.
How to setup proxy using yast in SUSE Linux
yast is configuration manager native to SUSE Linux which gives nice text based GUI in PuTTY terminal! If you are used to it, you can configure proxy from yast as well.
Navigate to Network Services -> Proxy
Enable Proxy using tab. It will allow you to fill in details below like server details, authentication etc. Fill in details and you can test configuration by selecting
Test Proxy Settings. After successful testing select
You can even mentioned hostnames, IPs under
No Proxy Domainsso that they can be connected bypassing proxy. This is very much helpful when you have internet and local network repos configured under zypper. By adding FQDN / IPof local patching server under
No Proxy Domain you can reach local patching server while proxy is enabled.
You will be presented with notice “It is recommended to relogin to make new proxy settings effective.” Relogin and test internet access.
How to setup proxy in RHEL using GUI
In RHEL, navigate to Application -> System Tools -> Settings -> Network
Select Network Proxy and then Manual method.
Here fill in proxy server details along with port and you are good to go. Add hostnames or IPs in
Ignore Hosts so that they can be connected bypassing proxy. This is helpful when you have repo from local server and internet configured under yum. By entering local patching server FQDN/ IP in
Ignore Hostsyou can use local patching server in YUM while proxy is enabled serverwide.
How to ignore proxy for local patching server in Linux
As I mentioned couple of times above, here is particular case you may face on your system. You have repo manager like zypper is configured with repo from internet and also from local patching server (with FQDN). Its same as ‘No proxy for‘ or ‘Bypass proxy server for local addresses‘ setting in Windows.
Now when you enable proxy, internet repo works (via proxy) and local patching server repo wont work. Since it tries to reach local patching server over internet and couldnt do it (via proxy). If you disable proxy, your local patching repo will work and internet repo wont.
In such case, you need a local repo to bypass proxy and internet repo should go through proxy. Here you can define local server FQDN/IP in
Ignore Hosts or
No Proxy Domains as I explained earlier.
From CLI, you can edit file
/etc/sysconfig/proxy add entry in below line –
## Type: string(localhost)
## Default: localhost
# Example: NO_PROXY="www.me.de, do.main, localhost"
NO_PROXY="localhost, 127.0.0.1, patchingsvr.kt.com"
patchingsvr.kt.com makes proxy bypass for this local server. Above sample file is from SUSE Linux.