How to configure network settings in CentOS (from dhcp to static)

It’s a bit different from what we’re used to do in Ubuntu, here are the instructions, assuming our network interface is eth0:

  1. Take a backup from the “/etc/sysconfig/network-scripts/ifcfg-eth0” file, e.g. by the following command: “cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.bak”
  2. Open the “/etc/sysconfig/network-scripts/ifcfg-eth0” file for editing using vi or similar and do the following:
    1. change BOOTPROTO from “dhcp” to “static”
    2. Add the following lines replacing the “X” with your values:
      1. IPADDR=XXX.XXX.XXX.XXX
      2. NETMASK=XXX.XXX.XXX.XXX
      3. GATEWAY=XXX.XXX.XXX.XXX
      4. DNS1=XXX.XXX.XXX.XXX
        Note: You can add more “DNS1” entries to add additional DNS servers
  3. Restart the network:
    “/etc/init.d/networking restart”

That’s it! Enjoy!

Source: http://www.howtoforge.com/linux-basics-set-a-static-ip-on-centos

About SoCRaT

Software Engineer, OSS & Linux Geek
This entry was posted in Linux and tagged , , , , , , , . Bookmark the permalink.

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