Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] How do prevent dhcpcd to overwrite /etc/resolf.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
loisl
Apprentice
Apprentice


Joined: 18 Apr 2004
Posts: 167
Location: Egelsbach

PostPosted: Tue Feb 23, 2010 8:49 pm    Post subject: [SOLVED] How do prevent dhcpcd to overwrite /etc/resolf.conf Reply with quote

Hai all,

i am using the last stable version of dhcpcd (net-misc/dhcpcd-4.0.15) and i am struggling to find a knob to prevent it from overwriting my /etc/resolf.conf.

I believe there was such a knob in the past. But today i do not find it any more.

What's happening is as follows: after getting a lease i setup an IPSec Tunnel with StrongSWAN and override my /etc/resolv.conf to use nameservers "behind" the IPSec Tunnel. After a few minutes the lease of my interface IP expires, dhcpcd gets it back again and overrides /etc/resolv.conf.

Just getting rid of DHCP Option 55 (Parameter Request List) does not solve the issue because I loose my default gw etc. as well.

Any Ideas are verry welcome.

Thanks,
Loisl


Last edited by loisl on Wed Feb 24, 2010 5:57 pm; edited 1 time in total
Back to top
View user's profile Send private message
Princess Nell
l33t
l33t


Joined: 15 Apr 2005
Posts: 927

PostPosted: Tue Feb 23, 2010 8:58 pm    Post subject: Reply with quote

Try openresolv for resolv.conf management.
Back to top
View user's profile Send private message
loisl
Apprentice
Apprentice


Joined: 18 Apr 2004
Posts: 167
Location: Egelsbach

PostPosted: Tue Feb 23, 2010 10:42 pm    Post subject: Reply with quote

I just had a look on openresolv. I do not understand how to use it. How do I combine this with strongswan and /etc/conf.d/net?

On the other hand I tried to edit /etc/dhcpcd.conf. But when I put some nooptions for dns stuff into dhcpcd.conf, then "my" /etc/resolv.conf becomes overwritten by an empty file after the next dhcp renew :(
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Wed Feb 24, 2010 12:14 am    Post subject: Reply with quote

Code:
-R
    Prevents dhcpcd from replacing existing /etc/resolv.conf file.



I don't know what dhcpcd version this man page is, but i suppose you can check the -R with the current you have.
Back to top
View user's profile Send private message
Rexilion
Veteran
Veteran


Joined: 17 Mar 2009
Posts: 1044

PostPosted: Wed Feb 24, 2010 3:20 am    Post subject: Reply with quote

My gentoo installed dhcpcd man-page mentions this:

-C, --nohook script
Don't run this hook script. Matches full name, or prefixed with
2 numbers optionally ending with .sh.

So to stop dhcpcd from touching your DNS or MTU settings you
would do:-
dhcpcd -C resolv.conf -C mtu eth0

That help?
Back to top
View user's profile Send private message
albright
Advocate
Advocate


Joined: 16 Nov 2003
Posts: 2588
Location: Near Toronto

PostPosted: Wed Feb 24, 2010 3:43 am    Post subject: Reply with quote

you can also add a line like this to /etc/conf.d/net

Code:
dhcp_eth?=( "nodns" )

_________________
.... there is nothing - absolutely nothing - half so much worth
doing as simply messing about with Linux ...
(apologies to Kenneth Graeme)
Back to top
View user's profile Send private message
loisl
Apprentice
Apprentice


Joined: 18 Apr 2004
Posts: 167
Location: Egelsbach

PostPosted: Wed Feb 24, 2010 1:00 pm    Post subject: Reply with quote

krinn wrote:
Code:
-R
    Prevents dhcpcd from replacing existing /etc/resolv.conf file.



I don't know what dhcpcd version this man page is, but i suppose you can check the -R with the current you have.


Unfortunatedly the -R option is gone ...
Back to top
View user's profile Send private message
loisl
Apprentice
Apprentice


Joined: 18 Apr 2004
Posts: 167
Location: Egelsbach

PostPosted: Wed Feb 24, 2010 1:02 pm    Post subject: Reply with quote

albright wrote:
you can also add a line like this to /etc/conf.d/net

Code:
dhcp_eth?=( "nodns" )


Unfortunatedly then dhcpcd does not work (when I look into my syslog, I can see my WiFi connects to the AP but dhcpcd does not retrieve an IP at all).
Back to top
View user's profile Send private message
loisl
Apprentice
Apprentice


Joined: 18 Apr 2004
Posts: 167
Location: Egelsbach

PostPosted: Wed Feb 24, 2010 5:56 pm    Post subject: Reply with quote

Rexilion wrote:

So to stop dhcpcd from touching your DNS or MTU settings you
would do:-
dhcpcd -C resolv.conf -C mtu eth0


This was the bringer. Many thanks for the tip. Yesterday I have had scanned the man page several times and I still overlooked this. Must have been blind :oops:

At the bottom line finally I have modified the original resolv.conf hook script to not overwrite /etc/resolv.conf in case of an scheduled IP renewal. This brings the most freedom to me since for the first time I now get the SP's dns data exactly one times.

Many thanks for pointing me in the correct direction
Back to top
View user's profile Send private message
shallpion
Guru
Guru


Joined: 29 Sep 2008
Posts: 331

PostPosted: Thu Feb 25, 2010 4:02 pm    Post subject: Reply with quote

loisl wrote:
albright wrote:
you can also add a line like this to /etc/conf.d/net

Code:
dhcp_eth?=( "nodns" )


Unfortunatedly then dhcpcd does not work (when I look into my syslog, I can see my WiFi connects to the AP but dhcpcd does not retrieve an IP at all).

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?style=printable&part=4&chap=3
# Only needed if you have more than one DHCP module installed
modules=( "dhcpcd" )

config_eth0=( "dhcp" )
dhcpcd_eth0="-t 10" # Timeout after 10 seconds
dhcp_eth0="release nodns nontp nonis" # Only get an address
Back to top
View user's profile Send private message
loisl
Apprentice
Apprentice


Joined: 18 Apr 2004
Posts: 167
Location: Egelsbach

PostPosted: Thu Feb 25, 2010 7:09 pm    Post subject: Reply with quote

shallpion wrote:
loisl wrote:
albright wrote:
you can also add a line like this to /etc/conf.d/net

Code:
dhcp_eth?=( "nodns" )


Unfortunatedly then dhcpcd does not work (when I look into my syslog, I can see my WiFi connects to the AP but dhcpcd does not retrieve an IP at all).

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?style=printable&part=4&chap=3
# Only needed if you have more than one DHCP module installed
modules=( "dhcpcd" )

config_eth0=( "dhcp" )
dhcpcd_eth0="-t 10" # Timeout after 10 seconds
dhcp_eth0="release nodns nontp nonis" # Only get an address


This was exactly what did not work (I had only the "nodns" flag set). Dhcpcd did not retrieve an IP address.
Back to top
View user's profile Send private message
jathlon
Tux's lil' helper
Tux's lil' helper


Joined: 26 Sep 2006
Posts: 89
Location: Canada

PostPosted: Fri Feb 26, 2010 3:25 am    Post subject: Reply with quote

[quote="loisl"]
shallpion wrote:
loisl wrote:
albright wrote:
you can also add a line like this to /etc/conf.d/net

Code:
dhcp_eth?=( "nodns" )

dhcp_eth0="release nodns nontp nonis" # Only get an address


This was exactly what did not work (I had only the "nodns" flag set). Dhcpcd did not retrieve an IP address.


I'm not really sure that this is the solution for your situation but notice the difference in syntax. Specifically =( "nodns" ) verses ="nodns"

Depending on what version your init scripts are one or the other might work. Try 'em both.

Hope something like that works for you.

j
Back to top
View user's profile Send private message
kosik
n00b
n00b


Joined: 09 Nov 2007
Posts: 20
Location: 127.0.0.1

PostPosted: Thu Apr 10, 2014 8:12 pm    Post subject: Reply with quote

Was looking for this for ages ... now it popped up again while fiddling /etc/resolv.conf, solution works!

Thanks, dude!
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