I have private DNS servers and I want to write them to resolv.conf
with resolvconf
on Debian on AWS/EC2.
There is a problem in the order of nameserver entries.
In my resolv.conf
, EC2's default nameserver is always written at first line like so:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 172.16.0.23
nameserver 10.0.1.185
nameserver 10.100.0.130
search ap-northeast-1.compute.internal
172.16.0.23
is EC2's default nameserver and others are mine.
How to remove EC2 entry? Or, how to move EC2 entry to third?
Here I have an interface file:
% ls -l /etc/resolvconf/run/interface/
-rw-r--r-- 1 root root 62 Jun 7 23:35 eth0
It seems that the file eth0
is automatically generated by dhcp so can't remove it permanently.
% cat /etc/resolvconf/run/interface/eth0
search ap-northeast-1.compute.internal
nameserver 172.16.0.23
My private DNS entry is here:
% cat /etc/resolvconf/resolv.conf.d/base
nameserver 10.0.1.185
nameserver 10.100.0.130
Please help.
You can disable netconfig 's handling of /etc/resolv. conf by disabling the NETCONFIG_DNS_POLICY option in /etc/sysconfig/network/config to an empty string as shown below. Afterward, you should delete the netconfig -generated resolv. conf file, and reboot the system.
To stop NetworkManager from changing resolv. conf you should select "Automatic (DHCP) addresses only" in all connection configurations that become active on your system.
I think I just solved a very similar problem. I was bothered by Amazon EC2's crappy internal DNS servers so I wanted to run a local caching dnsmasq
daemon and use that in /etc/resolv.conf
. At first I just did echo nameserver 127.0.0.1 > /etc/resolv.conf
but then I realized that my change would eventually be overwritten by the DHCP client after a reboot or DHCP lease refresh.
What I've now done instead is to edit /etc/dhcp3/dhclient.conf
and uncomment the line prepend domain-name-servers 127.0.0.1;
. You should be able to use the prepend
directive in a very similar way.
Update: These instructions are based on Ubuntu Linux but I imagine the general concept applies on other systems as well, even other DHCP clients must have similar configuration options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With