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.
- 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
ifconfigYou 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 :
By default, this file is empty, so enter at least one entry here (always good to have at least two)
nameserver 126.96.36.199Now 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.