Start a conversation

How to Configure Static IP Address in CentOS

The following steps show how to configure a static IP address in CentOS.

  1. Edit the file /etc/sysconfig/network-scripts using an editor like nano or vi.
    nano /etc/sysconfig/network-scripts/ifcfg-eth0
  2. You will see a default configuration similar to this
  3. Now change the configuration to this (with the appropriate IP address, mask and gateway)
  4. Then save the file, to save press ctrl+x to exit and press y for confirmation.
  5. Now restart the network services by issuing the command 
    service network restart
  6. To verify the IP address issue the following command
    You will then see following information
  7. 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)

     Now save the file and exit. You can test the configuration by issuing ping command.
    [root@hostname~]# ping

    If you get the reply, you have successfully configured the IP address and DNS information.

Choose files or drag and drop files
Was this article helpful?
  1. Joel Eskelsen

  2. Posted