Question

DNS and cloud init; where is the proper location to set the resolver

Posted February 15, 2020 380 views
DigitalOcean Accounts

I’m running Centos 7. All the usual places to change the DNS resolver have a warning message that this file is created by cloudinit. So where do I actually set the resolver address? That is I need a file not created by cloudinit or any other automatic process.

The only reason I ask is in the last few days my reverse DNS check in Postfix has failed on some IP addresses that are fine, i.e. do have a reverse pointer. For example google gmail servers and comcast.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hi @gc948486cbc56b8,

If you wish to change your Resolv.conf you’ll need to edit your /etc/NetworkManager/NetworkManager.conf file. Open the file and search for the [main] section in this file. As soon as you find it, Add dns=none just after the [main] tag:

[main]
dns=none

Now that you are done with that part, update your /etc/resolv.conf to whatever you like and restart your NetworkManager.

sudo systemctl restart NetworkManager.service

And that’s it, your resolv.conf should now be safe.

Regards,
KDSys

  • I don’t have that file structure. I have
    /etc/NetworkManager/dispatcher.d
    with a number of different files.

    This is my /etc/sysconfig/network-scripts/ifcfg-eth0 with obvious censoring.

    # Created by cloud-init on instance boot automatically, do not edit.
    #
    BOOTPROTO=none
    DEFROUTE=yes
    DEVICE=eth0
    GATEWAY=zzz.zzz.zzz.zzz
    HWADDR=aa:bb:cc:dd:ee
    IPADDR=xxx.xxx.xxx.xxx
    IPADDR1=yyy.yyy.yyy.yyy
    MTU=1500
    NETMASK=255.255.255.0
    NETMASK1=255.255.0.0
    ONBOOT=yes
    TYPE=Ethernet
    USERCTL=no
    DNS1=9.9.9.9
    ZONE=public
    ~           
    

    suggested fix
    except the Digitalocean comment says not to edit the file. The DNS1 does seem to propagate. The suggested fix is to remove the DNS1 line and then change resolve.conf

    sh-4.2# cat resolv.conf
    ; Created by cloud-init on instance boot automatically, do not edit.
    ;
    search localdomain
    nameserver 9.9.9.9
    
    

    I would like to switch to a non-filtered DNS like 1.1.1.1

Submit an Answer