Configuring a Static IP Behind a proxy in CentOS
15, May 2012
Should you find yourself spinning up a fresh install of CentOS and need to set a static IP, or find your way out from behind a proxy, here's how to do so.
First, let's tell the system to use a static IP address, open /etc/sysconfig/network-scripts/ifcfg-eth0 and change it to look like the following:
DEVICE="eth0" HWADDR="LEAVE ALONE" IPADDR=your_desired_ip NETMASK=your_netmask GATEWAY=your_gateway NM_CONTROLLED="yes" ONBOOT="yes" BOOTPROTO=static
If you want to use a specified DNS server to handle all your traffic, edit /etc/resolve.conf and change it to look like this:
nameserver xxx.xxx.xxx.xxx nameserver yyy.yyy.yyy.yyy
That's all it takes. We're now ready to restart the network interface to bring connect to the internet:
If you are behind a proxy, then there's a couple extra things that you have to do. You need to set your bash enviroment variables. These are used by most command line programs that need to access the internet, such as YUM, wget, curl, and others. All these different programs need to be informed of the proxy. To do so, edit ~/.bashrc and add the following:
export http_proxy=http://yourproxy.com:port export https_proxy=http://yourproxy.com:port
Once done, you need to reload your bashrc configuration file for the shell to become aware of the changes:
You only need to do this once, as the next time you log into the machine, your bashrc file will autmatically be loaded with the new values in it.
Everything should be taken care of now, run a
to make sure by pulling in all the updates to the system - which obviouslly requires internet.
Have Something to Say?
Questions? Comments? Concerns? Let me know what you’re thinking.