Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Manually edit /etc/resolv.conf
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
donjames
Apprentice
Apprentice


Joined: 19 Dec 2004
Posts: 251
Location: 32°9'50" N 94°50'54" W

PostPosted: Thu Sep 03, 2020 11:33 pm    Post subject: Manually edit /etc/resolv.conf Reply with quote

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
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 2434
Location: Frankfurt, Germany

PostPosted: Thu Sep 03, 2020 11:38 pm    Post subject: Reply with quote

Do you use DHCP? DHCP clients overwrite /etc/resolv.conf - unless you tell them not to do that.
Back to top
View user's profile Send private message
Ionen
Veteran
Veteran


Joined: 06 Dec 2018
Posts: 1275

PostPosted: Thu Sep 03, 2020 11:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
donjames
Apprentice
Apprentice


Joined: 19 Dec 2004
Posts: 251
Location: 32°9'50" N 94°50'54" W

PostPosted: Fri Sep 04, 2020 2:17 am    Post subject: Reply with quote

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
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 4147
Location: Illinois, USA

PostPosted: Fri Sep 04, 2020 2:49 am    Post subject: Reply with quote

/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
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6799
Location: Blighty

PostPosted: Fri Sep 04, 2020 10:49 am    Post subject: Reply with quote

Many things try to control /etc/resolv.conf - DHCP, PPP, VPN, etc.
Most well behaved applications do this via resolvconf(8).

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.
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
donjames
Apprentice
Apprentice


Joined: 19 Dec 2004
Posts: 251
Location: 32°9'50" N 94°50'54" W

PostPosted: Fri Sep 04, 2020 8:46 pm    Post subject: Reply with quote

UberLord wrote:
Many things try to control /etc/resolv.conf - DHCP, PPP, VPN, etc.
Most well behaved applications do this via resolvconf(8).

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
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6799
Location: Blighty

PostPosted: Fri Sep 04, 2020 11:13 pm    Post subject: Reply with quote

resolvconf is normally in /sbin

udev has nothing to do with resolv.conf to the best of my knowledge.
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
figueroa
l33t
l33t


Joined: 14 Aug 2005
Posts: 769
Location: Lower right-hand corner USA

PostPosted: Sat Sep 05, 2020 3:11 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum