Jump to Navigation

084 - Change DHCP to Static IP Address.

When you change your network configuration (IP Address), There are two ways ("setup command" or change related files manually)
to do that. setup command might be easy for change, but you want to know how to change it manually.

1. Login a Linux Server as root.

2. Check your IP address using ifconfig command.

[myserver]# ifconfig

eth0      Link encap:Ethernet  HWaddr 00:21:70:35:D5:8D
          inet addr:192.168.10.60  Bcast:192.168.10.255  Mask:255.255.255.0
          inet6 addr: fe80::221:70ff:fe35:d58d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3768 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1256 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:359259 (350.8 KiB)  TX bytes:190448 (185.9 KiB)
          Memory:fe9e0000-fea00000

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:103 errors:0 dropped:0 overruns:0 frame:0
          TX packets:103 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:5455 (5.3 KiB)  TX bytes:5455 (5.3 KiB)

3. Change your network configuration file.

[myserver]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

4. Before change the file, you shoud take backup for it.

5. Change parameters like the followings.

# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
GATEWAY=192.168.10.1
TYPE=Ethernet
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
NETMASK=255.255.255.0
IPADDR=192.168.10.60
USERCTL=no
PEERDNS=yes
IPV6INIT=no
ONPARENT=yes
NM_CONTROLLED=yes
DNS1=192.168.10.6
DNS2=192.168.10.7
DOMAIN=mydomain.com

6. Reboot your server or use the following command.

[myserver]# /etc/init.d/network restart

 



Main menu 2

Story | by Dr. Radut