# [SOLVED] How do prevent dhcpcd to overwrite /etc/resolf.conf

## loisl

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,

LoislLast edited by loisl on Wed Feb 24, 2010 5:57 pm; edited 1 time in total

----------

## Princess Nell

Try openresolv for resolv.conf management.

----------

## loisl

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   :Sad: 

----------

## krinn

```
-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.

----------

## Rexilion

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?

----------

## albright

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

```
dhcp_eth?=( "nodns" )

```

----------

## loisl

 *krinn wrote:*   

> 
> 
> ```
> -R
> 
> ...

 

Unfortunatedly the -R option is gone ...

----------

## loisl

 *albright wrote:*   

> you can also add a line like this to /etc/conf.d/net
> 
> ```
> 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).

----------

## loisl

 *Rexilion wrote:*   

> 
> 
>              So to stop dhcpcd from touching your DNS or MTU settings you
> 
>              would do:-
> ...

 

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   :Embarassed: 

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

----------

## shallpion

 *loisl wrote:*   

>  *albright wrote:*   you can also add a line like this to /etc/conf.d/net
> 
> ```
> dhcp_eth?=( "nodns" )
> 
> ...

 

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

----------

## loisl

 *shallpion wrote:*   

>  *loisl wrote:*    *albright wrote:*   you can also add a line like this to /etc/conf.d/net
> 
> ```
> dhcp_eth?=( "nodns" )
> 
> ...

 

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

----------

## jathlon

[quote="loisl"] *shallpion wrote:*   

>  *loisl wrote:*    *albright wrote:*   you can also add a line like this to /etc/conf.d/net
> 
> ```
> dhcp_eth?=( "nodns" )
> 
> ...

 

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

----------

## kosik

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

Thanks, dude!

----------

