Assign A Static IP On CentOS With A Working DNS Configuration

First we need to become in order to issue the “setup” command.

[root@localhost ~]# setup

A text configuration page will appear, choose “Network configuration”.

Choose the intended interface that will be assigned the static IP.

Remove the star in “Use DHCP” option and start assigning the IP address, Netmask and Gateway address. After you are done choose “OK”.

After making the changes don’t forget to choose Quit instead of Cancel otherwise the changes will not be implemented.

The previous instruction should give you a working machine with a static IP, the only problem is that there is no working DNS to reach other domains in the Internet. If you try to ping you will get an error, however if you Ping one of the many IP’s Google owns like you will have successful packer transmission. To solve this issue we need to add DNS entry’s to the /etc/resolv.conf file.

Open /etc/resolv.conf with your favorite text editor and add the IP addresses for your DNS servers. In this example I added the IP addresses that belong to the OpenDNS service.


Another option is to add the IP address of your gateway (Router) and have it act as the intermediate for your ISP DNS servers.

Do not forget to restart your network service or just reboot the entire machine.

  • Chad T.

    If you have NetworkManager running then it will continually over write the resolv.conf file so you must stop the NetworkManager service and keep it from restarting or you will loose all edits to resolv.conf