# Stop dhcp overwriting resolv.conf

## timbp

I know I had this working yesterday, but today I can't work it out.

I'm using DHCP to get my network settings, except that gives the router address as the nameserver, and various programs (such as wget) do not get proper addresses from the router.

So I want my nameserver to be the ISP nameserver.

My /etc/conf.d/net file currently has only the line

dns_servers_eth0=( "203.0.178.191" )

As far as I recall, that was all I needed yesterday, but today it doesn't work. Every time the lease is renewed, resolv.conf gets rewritten to use my router as the nameserver.

What have I done wrong?

Furthermore, how do I change the lease time? As this is in my own home with nobody else connecting, I can't see any need to renew the lease every hour or so. I guess I should use static IPs, but dhcp was easier (at least when I was Windows only).

----------

## kds66

To prevent /etc/resolv.conf from being overwritten, add the following line to /etc/conf.d/net:

```
dhcpcd_eth0="-R"
```

The lease time is determined AFAIK by the dhcp server.

----------

## timbp

Thank you.

Found the lease setting in my router and changed that.

Also added your line to my /etc/conf.d/net

Now perhaps I can start a major merge and leave it, and not come back hours later to find it couldn't download from 1.0.0.0

----------

## kds66

You're welcome, I'm glad I could help.

Hint: add "[solved]" to the the subject when your problem has been resolved.

----------

## timbp

But not solved   :Sad: 

Just went to emerge something else and found emerge/wget trying to connect to 1.0.0.0

/etc/resolv.conf currently has

```
dns_servers_eth0=( "203.0.178.191" )

dhcpd_eth0="-R"

```

But stilll /etc/resolv.conf was overwritten with "nameserver 192.168.1.1".

----------

## UberLord

There wasn't a comment at the top saying which program generated resolv.conf?

----------

## kds66

 *timbp wrote:*   

> But not solved  :(
> 
> Just went to emerge something else and found emerge/wget trying to connect to 1.0.0.0
> 
> /etc/resolv.conf currently has
> ...

 

That should go into /etc/conf.d/net - not resolv.conf.

----------

## RedSquirrel

From /etc/conf.d/net.example:

 *Quote:*   

> # GENERIC DHCP OPTIONS
> 
> # Set generic DHCP options like so
> 
> #dhcp_eth0="release nodns nontp nonis nogateway nosendhost"
> ...

 

----------

## timbp

 *kds66 wrote:*   

>  *timbp wrote:*   But not solved  
> 
> Just went to emerge something else and found emerge/wget trying to connect to 1.0.0.0
> 
> /etc/resolv.conf currently has
> ...

 

It was in the right file, I just wrote the wrong thing on the forum.

But it didn't work anyway.

I'll try dhcp_eth0="nodns"

----------

