Simple method:
# ifconfig eth0 192.168.10.12 netmask 255.255.255.0 broadcast 192.168.10.255
Or manually 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. First change directory to /etc/sysconfig/network-scripts/:
You need to edit / create files as follows:# cd /etc/sysconfig/network-scripts/
- /etc/sysconfig/network-scripts/ifcfg-eth0 : First Ethernet card configuration file
- /etc/sysconfig/network-scripts/ifcfg-eth1 : Second Ethernet card configuration file
Append/modify as follows:# vi ifcfg-eth0
# Intel Corporation 82573E Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=static
DHCPCLASS=
HWADDR=00:30:48:56:A6:2E
IPADDR=10.10.29.66
NETMASK=255.255.255.192
ONBOOT=yes
Save and close the file. Define default gateway (router IP) and hostname in /etc/sysconfig//network file:
Append/modify configuration as follows:# vi /etc/sysconfig/network
Save and close the file. Restart networking:NETWORKING=yes
HOSTNAME=www1.nixcraft.in
GATEWAY=10.10.29.65
Make sure you have correct DNS server defined in /etc/resolv.conf file:# /etc/init.d/network restart
Setup DNS Server as follows:# vi /etc/resolv.conf
Save and close the file. Now you can ping the gateway/other hosts:nameserver 10.0.80.11
nameserver 10.0.80.12
nameserver 202.67.222.222
Output:$ ping 10.0.80.12
Change HOSTNAMEPING 10.0.80.12 (10.0.80.12) 56(84) bytes of data. 64 bytes from 10.0.80.12: icmp_seq=1 ttl=251 time=0.972 ms 64 bytes from 10.0.80.12: icmp_seq=2 ttl=251 time=1.11 ms
Step # 1:
You need to update two files:
- Linux Distribution specific file. Edit appropriate file as per your distribution as follows.
- /etc/hosts
Edit /etc/sysconfig/network, enter:
Set HOSTNAME=newhost.example.com, enter:vi /etc/sysconfig/network
HOSTNAME=server2.nixcraft.com
Save and close the file. Type the following command:Now, proceed to step # 2.hostname server2.nixcraft.com hostname
Step # 2:
Now, you need to edit /etc/hosts file, enter:
Change all old hostname with newer one.vi /etc/hosts