Last Updated: February 25, 2016
·
919
· hvasconcelos

Configure a Static IP on CentOS 6

vim /etc/sysconfig/network-scripts/ifcfg-ethx

DEVICE=ethX
BOOTPROTO=static
HWADDR=00:30:48:56:A6:2E
IPADDR="<IP_ADDRESS>"
GATEWAY="<NETWORK_GATEWAY>"
NETMASK="<NETWORK_MASK>"
DNS1="<DNS_SERVER1>"
DNS2="<DNS_SERVER2>"
NM_CONTROLLED="yes"
TYPE="Ethernet"
ONBOOT=yes

Example:

DEVICE="eth0"
BOOTPROTO="static"
HWADDR="00:0C:29:1A:56:23"
IPV6INIT="yes"
IPADDR="192.168.131.150"
NETMASK="255.255.255.0"
GATEWAY="192.168.131.2"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
DNS1="192.168.131.2"
DNS2="192.168.131.3"