# Prevent router to overwrite nameserver in resolv.conf

## gmtongar

Hi everyone

I've set up DNSMASQ on my gentoo box, my server.

The thing is, my router also function as a DNS+DHCP server. When I boot my other boxes running gentoo, my resolv.conf gets overwritten.

How can I prevent that from happening? 

Now I have to manually update resolv.conf (adress 192.168.0.60), istead of 192.168.0.1, which

the router sets it to be (a long drown-out sentence, I know)

Any hint on how to solve this would be most welcome!

thanks

----------

## SlightlyMiffed

I think you need to set the "-R" option for dhcpcd.

 *Quote:*   

> man dhcpcd
> 
> ...
> 
> -R     Prevents dhcpcd from replacing existing <etcDir>/resolv.conf file.
> ...

 

You set this in /etc/conf.d/net, something like:

dhcpcd_eth0="-R"

HTH!

----------

## wafox

I'm getting a similar problem.  My resolv.conf file gets nuked every time I boot up or bring my eth0 interface up.

Contents of my /etc/conf.d/domainname file:

```

# /etc/conf.d/domainname

# When setting up resolv.conf, what should take precedence?

#  0 = let dhcp/whatever override DNSDOMAIN

#  1 = override dhcp/whatever with DNSDOMAIN

OVERRIDE=1

DNSDOMAIN="stfu.lan"

NISDOMAIN=""

```

Contents of my /etc/conf.d/net file:

```

dhcpcd_eth0="-R"

config_eth0=( "dhcp")

```

but my /etc/resolv.conf files always get an overwrite and looks like this:

```

# generated automatically by net-scripts

domain hawaii.rr.com

nameserver 192.168.0.118

```

The nameserver is set correctly by DHCP - this box is my nameserver and the dhcp server sets me to this static IP address. But this overwriting of the resolv.conf file is driving me nuts.

----------

## gmtongar

 *Quote:*   

> You set this in /etc/conf.d/net, something like: 
> 
> dhcpcd_eth0="-R"
> 
> 

 

Thanks. Worked like magic beans...   :Wink: 

Could you, if it's not too much to ask, give me a hint on how I could prevent my gentoo boxes

from using my router as DHCP, and instead only use my gentoo server as DHCP (I got DNSMASQ

installed and working, it seems)?

But thanks anyway...

----------

## UberLord

You have to stop your router serving DHCP  :Smile: 

----------

## gmtongar

right  :Embarassed: 

you may now stop laughing...   :Rolling Eyes: 

----------

## lmcogs

 *UberLord wrote:*   

> You have to stop your router serving DHCP 

 

Now how do you do that and yes as far as I am know I try to update the system, after updates.  

dhcpcd_lan="-R" is not working for me.  Need more clarity.

----------

## lmcogs

Hi

As well as dhcpcd_lan="-R" I found this

https://forums.gentoo.org/viewtopic-t-454524-start-25-postdays-0-postorder-asc-highlight-resolv+conf.html

and changing my domainname as given  the system now starts without changing the resolv.conf file

----------

