Configuring DNS on CentOS, AlmaLinux, and Rocky Linux

How to Change DNS Servers on Your System

To set a new DNS server, you’ll need to edit the resolv.conf file. Open it with any text editor, for example Nano:

nano /etc/resolv.conf

and replace the ip-address with a new one in the line nameserver:

options rotate
options timeout:2
options attempts:1

nameserver 91.228.153.88
nameserver 195.26.237.237
nameserver 31.172.68.71

Also, to keep your settings intact after a reboot, you will need to make changes to the network interface configuration file:

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

Enter the new ip on the lines:

DNS1=91.228.153.88
DNS2=195.26.237.237
DNS3=31.172.68.71

Once the changes are applied, the server will use the specified DNS to resolve domain names. These settings are commonly used on VPS and dedicated servers.

Need help?Our engineers will help you free of charge with any question in minutesContact us