How to set custom DNS on CentOS7 AWS

30. August 2016 AWS, CentOS 0
How to set custom DNS on CentOS7 AWS

There may be scenarios, when you need to use a custom DNS server for your Instances. So if you are deploying your application on an CentOS 7 on AWS, lets see how can set a custom DNS server such as 8.8.8.8 and 8.8.4.4

  • Edit the following file,

vim /etc/sysconfig/network-scripts/ifcfg-eth0

  • change the line PEERDNS="yes" to PEERDNS="no"
  • Now, Edit the file /etc/sysconfig/network and add the DNS entries after the existing contents.

NETWORKING=yes
NOZEROCONF=yes
DNS1=8.8.8.8
DNS2=8.8.4.4

  • Then, restart your network service

/etc/init.d/network  restart

  • Now check and verify the DNS servers in /etc/resolv.conf

Leave a Reply

Your email address will not be published.