Friday, October 22, 2010

Networking: Static IP

Servers usually get static IPs. A few files need to modified as follows:

[root@localhost ~]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=server.example.com  

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile)
DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.1.1
NETMASK=255.255.255.0
HWADDR=00:0D:60:FC:93:54
ONBOOT=yes

[root@localhost ~]# grep -v ^# /etc/hosts
192.168.1.1     server.example.com server
127.0.0.1       localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6

Upon next login we will have prompt showing the desired hostname. Lets ensure with ifconfig that there is no typo in IP address.

[root@server ~]# ifconfig eth0 |grep inet
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0

No comments:

Post a Comment