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:


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 yyy.yyy.yyy.yyy

That's all it takes. We're now ready to restart the network interface to bring connect to the internet:

/etc/init.d/network restart

Proxy Configuration

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=
export https_proxy=

Once done, you need to reload your bashrc configuration file for the shell to become aware of the changes:

source ~/.bashrc

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

yum update

to make sure by pulling in all the updates to the system - which obviouslly requires internet.


This space intentionally left blank.

Have Something to Say?

Questions? Comments? Concerns? Let me know what you’re thinking.

  • You can use Markdown formatting here.