How to set static ip address on RedHat/CentOS, and Fedora linux

Photo of author

By rasho

This post shows the steps to configure static ip address, default gateway, netmask, dns server and make a network auto start at boot on RedHat/CentOS 5.x/6.x and Fedora linux host normally configured with static ip address, so that easier to maintain the configuration on it’s client and DNS server will always able to resolve it.
See below the default RHEL/Centos, Fedora network card configuration file.

# cat /etc/sysconfig/network-scripts/ifcfg-eth0

Sample output:

DEVICE="eth0"
BOOTPROTO="dhcp"
HWADDR="xx:xx:xx:xx:xx:xx"
NM_CONTROLLED="yes"
ONBOOT="no"
TYPE="Ethernet"

Here are steps to configure static ip address and auto start of network card once system rebooted.

Configure eth0:

[ads]

# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="static"
HWADDR="xx:xx:xx:xx:xx:xx"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
IPADDR=192.168.1.2
NETMASK=255.255.255.0

Configure Default gateway:

# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=host.lintut.com
GATEWAY=192.168.1.1

Configure DNS server:

# vi /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4

Restart Network service:

# service network restart

That’s is all..

1 thought on “How to set static ip address on RedHat/CentOS, and Fedora linux”

Leave a Comment