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:
        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!


About SoCRaT

Research Support and Infrastructure 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: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google 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 )

Connecting to %s