In this Tutorial I am going to show how to assign Permanent IP Address in Linux. Specially RedHat and CentOS 5 Linux.
First you have to do is to Log on as root user and go to the Directory /etc/sysconfig/network-scripts/ to view all available devices.
# cd /etc/sysconfig/network-scripts/
You need to edit following files:
/etc/sysconfig/network-scripts/ifcfg-eth0 ( First Ethernet card configuration file)
/etc/sysconfig/network-scripts/ifcfg-eth1 ( Second Ethernet card configuration file)
To edit/create first NIC file, type command:
# vim ifcfg-eth0
Append/modify as follows:
DEVICE=eth0
BOOTPROTO=static
DHCPCLASS=
HWADDR=00:30:48:56:A6:2E
IPADDR=192.168.1.100
NETMASK=255.255.255.0
ONBOOT=yes
Save and close the file. (:wq!)
After that, configure the default gateway (router IP) and hostname in /etc/sysconfig/network file:
# vim /etc/sysconfig/network
Append/modify configuration as follows:
NETWORKING=yes
HOSTNAME=opesource
GATEWAY=192.168.1.1
Save and close the file(:wq!). Restart networking by enter following command:
# /etc/init.d/network restart
Make sure you have correct DNS server defined in /etc/resolv.conf file:
# vi /etc/resolv.conf
Setup DNS Server as follows:
nameserver 8.8.8.8
nameserver 8.8.4.4
Save and close the file(:wq!). Now you can check(ping) the gateway/other hosts:
# ping 192.168.1.1 (check network connection)
#ping www.google.com (check Internet connection )
IF You want to assign temporary ip address then Log on as root user and run the below command.
#ifconfig eth0:0 192.168.1.101 netmask 255.255.255.0
#ifconfig eth0:1 192.168.1.102 netmask 255.255.255.0
0 coment�rios:
Post a Comment