How to statically assign DNS in CentOS 7

You can statically assign DNS in Centos 7. In this example we will assign Googles DNS, which is:

8.8.8.8

8.8.44

To begin we will first edit the our internet adaptor, do so run the command:

sudo vi /etc/sysconfig/network-scripts/ifcfg-enpXXX

in our case we ran

 sudo vi /etc/sysconfig/network-scripts/ifcfg-enp0s3

We changed the line

PEERDNS=yes

to:

PEERDNS=no

 

Next we need to edit the resolv.conf file:

 sudo vi /etc/resolv.conf

nameserver 8.8.8.8

nameserver 8.8.4.4

 

Leave a Reply

Your email address will not be published. Required fields are marked *