Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
prevent /etc/resolv.conf from overwritten by dhcpcd
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
yufw
n00b
n00b


Joined: 11 Nov 2013
Posts: 57

PostPosted: Sun Jul 06, 2014 1:13 pm    Post subject: prevent /etc/resolv.conf from overwritten by dhcpcd Reply with quote

I use pptpclient to connect to VPN, since I have enabled the 'usepeerdns' option for pptpclient, when the ppp0 interface is on, it will copy /etc/ppp/resolv.conf to /etc/resolv.conf. However, every several hours or so, /etc/resolv.conf gets overwritten by dhcpcd.

I want to use the peer supplied DNS when I connect to VPN, so how to prevent /etc/resolv.conf from overwritten by dhcpcd?
Back to top
View user's profile Send private message
saivinoba
n00b
n00b


Joined: 20 May 2014
Posts: 30

PostPosted: Sun Jul 06, 2014 4:38 pm    Post subject: Reply with quote

I don't know if I understand the problem but will disabling dhcpcd help?
Back to top
View user's profile Send private message
ulenrich
Veteran
Veteran


Joined: 10 Oct 2010
Posts: 1371

PostPosted: Sun Jul 06, 2014 5:46 pm    Post subject: Re: prevent /etc/resolv.conf from overwritten by dhcpcd Reply with quote

yufw wrote:
, /etc/resolv.conf gets overwritten by dhcpcd.
Create an /etc/resolv.conf.head with entries you want to keep staying!
_________________
fun2gen2
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 6972
Location: Saint Amant, Acadiana

PostPosted: Sun Jul 06, 2014 6:24 pm    Post subject: Reply with quote

DHCP clients can be configured to do certain tasks only. Disable pulling DNS and it will not overwrite your resolv.conf.
_________________
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1717

PostPosted: Sun Jul 06, 2014 7:01 pm    Post subject: Reply with quote

If you're happy with completly static resolv.conf, you can `chattr +i /etc/resolv.conf`
I don't say this solution is perfect, but it's fast, generic, and contents of that file will not change, no matter what, until you remove this flag.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Sun Jul 06, 2014 7:18 pm    Post subject: Reply with quote

yufw ....

simply configure dhcpcd to not run the resolv.conf 'hook'

/etc/dhcpcd.conf
Code:
nohook resolv.conf

or add the following to /etc/conf.d/net (openrc)

Code:
dhcpcd_ppp0="--nohook resolv.conf"

or similarly via the cmdline ...

Code:
# dhcpcd --nohook resolv.conf <iface>

see 'man dhcpcd' '-C, --nohook'

best ... khay
Back to top
View user's profile Send private message
yufw
n00b
n00b


Joined: 11 Nov 2013
Posts: 57

PostPosted: Mon Jul 07, 2014 11:50 am    Post subject: Reply with quote

Thank you all for so many replies. I think I will take khay's advice because it is the most natural solution to me.
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6737
Location: Blighty

PostPosted: Mon Jul 07, 2014 5:41 pm    Post subject: Reply with quote

I propose another solution - resolvconf to manage this for you, assuming your VPN supports it.

openresolv is an implementation in Gentoo.
_________________
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
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