Software >> OS >> Unix >> Linux >> Networking >> How to configure for static IP

Oracle Linux 6

# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
HWADDR=52:54:00:91:6a:b3   ==> optional, can also work without hardcoding the MAC
PEERROUTES=yes
IPADDR=192.168.122.89
NETMASK=255.255.255.0
GATEWAY=192.168.122.1
DNS1=192.168.122.1
USERCTL=no

# /etc/init.d/network restart

In the event the we encounter issues due to missing device eth0, check /etc/udev/rules.d/70-persistent-net.rules
and ensure that there is no repeat entries of the same device name.