Thursday, September 10, 2009

Change network setting from DHCP to Static

[root@host ~]# ifconfig


eth0 Link encap:Ethernet HWaddr 00:D0:BC:08:09:BC

inet addr:70.238.17.69 Bcast:255.255.255.255 Mask:255.255.255.248

inet6 addr: fe80::2d0:b7ff:fe08:9bb/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:7174 errors:0 dropped:0 overruns:0 frame:0

TX packets:2305 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:5339910 (5.0 MiB) TX bytes:170109 (166.1 KiB)



lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

inet6 addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:34 errors:0 dropped:0 overruns:0 frame:0

TX packets:34 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:4275 (4.1 KiB) TX bytes:4275 (4.1 KiB)




cat /etc/hosts


# Do not remove the following line, or various programs

# that require network functionality will fail.

127.0.0.1 myhost.mydomain.com myhost localhost.localdomain localhost

192.168.1.100 myhost.mydomain.com myhost

::1 localhost6.localdomain6 localhost6







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

DEVICE=eth0

BOOTPROTO=dhcp

HWADDR=00:D0:B7:08:09:BB

ONBOOT=yes







Change above file to below one

OUTPUT for static IP (example)

#

# File: ifcfg-eth0

#

DEVICE=eth0

IPADDR=192.168.1.100

NETMASK=255.255.255.0

BOOTPROTO=static

ONBOOT=yes

#

# The following settings are optional

#

BROADCAST=192.168.1.255

NETWORK=192.168.1.0

TYPE=Ethernet









Also confirm below files have correct entry

cat /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=myhost

GATEWAY=192.168.1.1









Now restart network

/etc/rc.d/init.d/network restart





Check all with below command

ethtool eth0

No comments: