Changing DNS in CentOS

  • Post author:
  • Post category:Tools

1. Edit resolv.conf and use your chosen name servers. Here we are using Google DNS.

> vi /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4

2. To prevent your resolv.conf from being overwritten on reboot, also change ifcfg-eth0.

> vi /etc/sysconfig/network-scripts/ifcfg-eth0
DNS2=8.8.4.4
DNS1=8.8.8.8