How to Configure Static IP Address on RHEL/CentOS Linux


(1) Cent OS Linux
(2) Fedora Core Linux
(3) Red Hat Enterprise Linux (RHEL) 3/4/5
Method # 1: GUI tool system-config-network
Type the following command at shell prompt (open x terminal):
# system-config-network &
Method # 2: Command line tool system-config-network-tui
If you don’t have X windows GUI installed type the following command at shell prompt:
# system-config-network-tui &
Method #3: Edit configuration files stored in /etc/sysconfig/network-scripts/
You can configure network card by editing text files stored in /etc/sysconfig/network-scripts/ directory.
1) /etc/sysconfig/network-scripts/ifcfg-eth#
Where # can be 0 ,1 ,2 .. .. depending on the number of Ethernet Adapter or NIC
2) /etc/sysconfig/network
In this tutorial you will use the following Internet Protocol Version 4 (TCP/IPv4) Properties including IP,default gateway, and preferred DNS servers as an example:
IP Address : 192.168.1.10
Netmask: 255.255.255.0
Hostname: server.vjetnamnet.com
Domain name: vjetnamnet.com
Gateway IP: 192.168.1.1
DNS Server 1: 8.8.8.8
DNS server 2: 8.8.4.4
Task 1 : Edit the file /etc/sysconfig/network as below example using vi:
# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=server.vjetnamnet.com
GATEWAY=192.168.1.1
Task 2: Edit /etc/sysconfig/network-scripts/ifcfg-eth0 as below example using vi and assign “StaticIP Address” “192.168.1.10″:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
TYPE=Ethernet
HWADDR=00:50:56:97:02:FD
IPADDR=192.168.1.10
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
BROADCAST=192.168.1.255
ONBOOT=yes
DNS1=8.8.8.8
DNS2=8.8.4.4
PEERDNS=yes
NM_CONTROLLED=yes
Explanations:
DEVICE: Specifies the device to use for the configuration.
IPADDR: The static IP for the network interface
NETMASK: The network mask for the device
HWADDR: The MAC address for the device
NM_CONTROLLED: Determines if the device can be controlled by the network manager.
ONBOOT: Determines if the device should be initialized when booted
DNS1: Specifies the DNS server for the device.  This is needed for name resolution.  You may also add DNS2 and DNS3 if you have additional servers.
Task 3: Edit /etc/resolv.conf and setup DNS servers as below example using vi:
# vi /etc/resolv.conf
search vjetnamnet.com
nameserver 192.168.1.1
nameserver 8.8.8.8
nameserver 8.8.4.4
Task 4: Restart the network services
# service network restart
Task 5 : Verify new “Static IP Address” configuration for eth0 as below:
# ping server.vjetnamnet.com
# ifconfig eth0
# ping google.com