Thursday, 22 August 2013

Static IP configuration for Linux host in DHCP network

1.Configure IP by using BOOTPROTO=DHCP as shown in below configuration file
#cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
HWADDR=00:21:f6:00:00:14   <Replace with your MAC address>
NETMASK=255.255.255.0      <Replace with your Netmask >
GATEWAY=129.221.8.1      <Replace with your Gateway IP>
TYPE=Ethernet

2. Restart the network
#/etc/init.d/network restart

3.Check assigned IP in ifconfig command output
#ifconfig
eth0      Link encap:Ethernet  HWaddr 00:21:F6:00:00:14
          inet addr:129.221.8.111  Bcast:129.221.8.255  Mask:255.255.255.0

4.Change BOOTPROTO=static and IPADDR=<assigned IP> as shown below
#cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
HWADDR=00:21:f6:00:00:14
IPADDR=129.221.8.111
NETMASK=255.255.255.0
GATEWAY=129.221.8.1
TYPE=Ethernet

5. Restart the network
#/etc/init.d/network restart

6. Confirm that your static IP specified in cfg file is configured
#ifconfig
eth0      Link encap:Ethernet  HWaddr 00:21:F6:00:00:14
          inet addr:129.221.8.111  Bcast:129.221.8.255  Mask:255.255.255.0

7. Confirm that you are able to reach to Gateway IP
# ping 129.221.8.1
PING 129.221.8.1 (129.221.8.1) 56(84) bytes of data.
64 bytes from 129.221.8.1: icmp_seq=1 ttl=255 time=0.718 ms
64 bytes from 129.221.8.1: icmp_seq=2 ttl=255 time=0.772 ms

No comments:

Post a Comment