These forums are locked and archived, but all topics have been migrated to the new forum. You can search for this topic on the new forum: Search for Adding 127.0.0.1 to /etc/resolv.conf ? on the new forum.
It seems to me, I need 127.0.0.1 added to the /etc/resolv.conf file (my server is using BIND and is a name server).
However, whenever I try to add it via the form on the "Hostname and DNS Client" page in Virtualmin, they are not saved.
In the file itself (/etc/resolv.conf) it says:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
So, how do I solve this?
I believe its saved in the network config when using the Hostname and DNS settings page. Look at /etc/network/interfaces file. 'dns-nameservers' will be listed in the interface settings.
Hi,
If you are using a VPS or a server configured with DHCP, it is common for the "resolv.conf" file to be overwritten by the DHCP server. This can drive you nuts without question as it did so many times before I learned how to address the matter.
You can effectively write content to the "resolv.conf" file, then make the file "read-only" making any further changes impossible until you remove the read-only status on the file.
The trick to making a file "read-only" or "immutable" comes with the program "chattr" which can change this attribute.
Once you've made the change, and before you restart the network (or Apply in Webmin) you need to go to the command line and enter:
chattr +i /etc/resolv.conf
If at a later date you want make changes to the file, simply enter the following command:
chattr -i /etc/resolv.conf
This will remove the write protection from the file.
Hope this helps!
Best Regards,
Peter Knowles | TPN Solutions
Email: pknowles@tpnsolutions.com | Skype: tpnassist
There is one "dirty" trick what will always work:
1. Go to
/root
and runcp /etc/resolv.conf /root/resolv.conf
.2. Use WinSCP, nano or any other software and open
/etc/rc.local
.3. At the bottom insert this line
/bin/cp /root/resolv.conf /etc/resolv.conf
.4. Leave one empty line at the end and save.
5. Again use WinSCP (nano...) and open
/root/resolv.conf
.6. This is what you should have in this file:
nameserver 127.0.0.1
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver xxx.xxx.xxx.xxx
where
xxx.xxx.xxx.xxx
is IP of your server.7. Dont mess up this order, e.g. must be exactly as i posted.
8. Save
/root/resolv.conf
.9. Last but not least check if
/etc/rc.local
is executable, if isnt make it.For now on every time when you restart your server the file
/etc/resolv.conf
will be replaced with/root/resolv.conf
and no more problems with missing127.0.0.1
. This is why i call this "dirty" trick but compared to anything else it will work 100%... at least i never encountered any problem. This usually happens with VPS on OpenVZ virtualization.P.S. This was for Centos 6/7 but it should work with any other OS.
- I often come to the conclusion that my brain has too many tabs open. -
Failing at desktop publishing & graphic design since 1994.
Unfortunately Debian 9 is missing the rc.local. Any idea how to solve this?
Operating system Debian Linux 9 | Webmin version 1.891 | Usermin version 1.741 | Virtualmin version 6.03
Rather than "hack" the system, when you are using DHCP, just edit the dhclient.conf file and supersede:
# vim /etc/dhcp/dhclient.conf
supersede domain-name-servers 1.1.1.1, 1.0.0.1;
or
supersede domain-name-servers 127.0.0.1;
Remember that you need to "reboot" rather than just "restart networking" on Ubuntu 18.