It’s a bit different from what we’re used to do in Ubuntu, here are the instructions, assuming our network interface is eth0:
- 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”
- Open the “/etc/sysconfig/network-scripts/ifcfg-eth0” file for editing using vi or similar and do the following:
- change BOOTPROTO from “dhcp” to “static”
- Add the following lines replacing the “X” with your values:
- IPADDR=XXX.XXX.XXX.XXX
- NETMASK=XXX.XXX.XXX.XXX
- GATEWAY=XXX.XXX.XXX.XXX
- DNS1=XXX.XXX.XXX.XXX
Note: You can add more “DNS1” entries to add additional DNS servers
- 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