How to configure a static IP Address
Written by Frank Contreras on January 18, 2012 – 1:29 pm
CentOS has a really nice GUI to configure the IP Address and other NIC settings. But I wanted to manage a Linux server without the crutch of a GUI. Here’s some notes on how to do it.
The file to configure settings for the first Ethernet ”eth0″ or for any interface can be found in this location:
/etc/sysconfig/network-scripts
The file corresponding to eth0 is
ifcfg-eth0
Use a text editor to make it look something like this:
DEVICE="eth0" NM_CONTROLLED="yes" ONBOOT=yes TYPE=Ethernet BOOTPROTO=none IPADDR=192.168.1.100 PREFIX=24 GATEWAY=192.168.1.1 DNS1=192.168.1.2 DNS2=4.2.2.2 DOMAIN=domain.com DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME="System eth0" UUID=5fb06bd0-0bb1-7ffa-44f1-d6eda65f2e03 HWADDR=00:01:01:12:34:56
After you save your changes, you’ll need to restart your network service with this command:
service network restart
You should be able to ping the address you just configured, but you might not be able to ping it from another client or even ping out. This has to do with your firewall settings, but that’s something that will be covered in another post.
No tags for this post.