View previous topic :: View next topic |
Author |
Message |
donjames Apprentice


Joined: 19 Dec 2004 Posts: 251 Location: 32°9'50" N 94°50'54" W
|
Posted: Thu Sep 03, 2020 11:33 pm Post subject: Manually edit /etc/resolv.conf |
|
|
Hi,
I have noticed that something in the system automatically resets the /etc/resolv.conf file.
Can someone tell me how to turn off the automatic reset so that I can enter the nameservers of my choice and not have them over written by the system?
I may have found the answer:
Add to the end of /etc/dhcpcd.conf
nohook resolv.conf
Thanks,
Don James
Last edited by donjames on Thu Sep 03, 2020 11:50 pm; edited 1 time in total |
|
Back to top |
|
 |
mike155 Advocate

Joined: 17 Sep 2010 Posts: 2564 Location: Frankfurt, Germany
|
Posted: Thu Sep 03, 2020 11:38 pm Post subject: |
|
|
Do you use DHCP? DHCP clients overwrite /etc/resolv.conf - unless you tell them not to do that. |
|
Back to top |
|
 |
Ionen Veteran

Joined: 06 Dec 2018 Posts: 1590
|
Posted: Thu Sep 03, 2020 11:42 pm Post subject: |
|
|
Some init scripts have support to add wanted nameservers in their configs and then will edit resolv.conf using those. Some other stuff will use things like /etc/resolv.conf.head for merging.. well there's a lot of network management systems / dhcp implementation and it's hard to tell without more info.
Personally I use static entries only (with openrc's newnet) and no dhcp, so resolv.conf never changes and only uses local nameserver (dnsmasq). Not that it means you should do the same. |
|
Back to top |
|
 |
donjames Apprentice


Joined: 19 Dec 2004 Posts: 251 Location: 32°9'50" N 94°50'54" W
|
Posted: Fri Sep 04, 2020 2:17 am Post subject: |
|
|
mike155 wrote: | Do you use DHCP? DHCP clients overwrite /etc/resolv.conf - unless you tell them not to do that. |
Yes, I use dhcp. |
|
Back to top |
|
 |
Tony0945 Advocate

Joined: 25 Jul 2006 Posts: 4463 Location: Illinois, USA
|
Posted: Fri Sep 04, 2020 2:49 am Post subject: |
|
|
/etc/resolv.conf get overwritten, but with the namerservers I want:
Code: | $ cat /etc/conf.d/net
# copied from central server, DHCP version
#config_eth0="dhcp"
dhcp_eth0="nodns"
config_eth0="192.168.0.104 netmask 255.255.255.0 "
mtu_eth0="1500"
dns_servers="127.0.0.1 192.168.0.102 1.1.1.1 198.192.0.1"
#dns_domain_lo="workgroup"
routes_eth0="default via 192.168.0.1"
|
Code: | $ cat /etc/resolv.conf
# Generated by net-scripts for interface eth0
nameserver 127.0.0.1
nameserver 192.168.0.102
nameserver 1.1.1.1
nameserver 198.192.0.1
|
|
|
Back to top |
|
 |
UberLord Retired Dev


Joined: 18 Sep 2003 Posts: 6815 Location: Blighty
|
|
Back to top |
|
 |
donjames Apprentice


Joined: 19 Dec 2004 Posts: 251 Location: 32°9'50" N 94°50'54" W
|
Posted: Fri Sep 04, 2020 8:46 pm Post subject: |
|
|
UberLord wrote: | Many things try to control /etc/resolv.conf - DHCP, PPP, VPN, etc.
Most well behaved applications do this via resolvconf( .
openresolv is a resolvconf implementation in portage which allows a fine graned control of how updates to this file should be handled.
If don't want resolvconf and just want a never changing file, then just make it immutable and nothing can ever change it. |
Hi,
openresolv is not installed on my system. It is using udev. Should I install openresolv?
Where would resolvconf be located?
donjames |
|
Back to top |
|
 |
UberLord Retired Dev


Joined: 18 Sep 2003 Posts: 6815 Location: Blighty
|
|
Back to top |
|
 |
figueroa Veteran


Joined: 14 Aug 2005 Posts: 1020 Location: The Matrix? USA
|
Posted: Sat Sep 05, 2020 3:11 am Post subject: |
|
|
If you want to override everything without undoing all those other things and ensure your /etc/resolv.conf doesn't get changed, make it immutable:
Code: | chattr +i /etc/resolv.conf |
If and when you need to reverse that, do:
Code: | chattr -i /etc/resolv.conf |
_________________ Andy Figueroa
andy@andyfigueroa.net Working with Unix since 1983. |
|
Back to top |
|
 |
|