The following steps show how to configure a static IP address in CentOS.
- Edit the file /etc/sysconfig/network-scripts using an editor like nano or vi.
nano /etc/sysconfig/network-scripts/ifcfg-eth0
- You will see a default configuration similar to this
- Now change the configuration to this (with the appropriate IP address, mask and gateway)
- Then save the file, to save press ctrl+x to exit and press y for confirmation.
- Now restart the network services by issuing the command
service network restart
- To verify the IP address issue the following command
ifconfig
You will then see following information - After configuring IP address now let’s configure DNS. Name server or DNS information is stored in different file. The location is, /etc/recolv.conf. Again using nano editor to configure DNS information :
nano /etc/resolv.conf
By default, this file is empty, so enter at least one entry here (always good to have at least two)
nameserver 8.8.8.8
Now save the file and exit. You can test the configuration by issuing ping command.[root@hostname~]# ping www.google.com
If you get the reply, you have successfully configured the IP address and DNS information.
Joel Eskelsen
Comments