# resolv.conf gets clobbered on boot [SOLVED]

## magister

I just finished a fresh install on a new hard drive, and everything seems fine except I can't seem to keep any DNS server addresses in my resolv.conf. I can replace /etc/resolv.conf with a copy of the one generated by the livecd during install (which has three nameservers listed) and everything will work fine for a while, but it gets replaced every time I reboot with one that looks like this:

```
# Generated by net-scripts for interface lo

domain lan

```

I thought I followed the install guide pretty meticulously, but I wound up with this problem anyway. Any thoughts?Last edited by magister on Tue Sep 19, 2006 8:45 pm; edited 1 time in total

----------

## Kosmas

The resolv.conf file is generated at boot time overwriting anything in there. You have to add your dns servers to the /etc/conf.d/net config file

somewhere like 

```
 dns_servers_eth0="xxx.xxx.xxx.xxx yyy.yyy.yyy.yyy"
```

where xxx.xxx.xxx.xxx and yyy.yyy.yyy.yyy are the addresses of the dns servers you want to use.

----------

## magister

Thanks, that seems to have fixed it.  Looks like that's been left out of the installation guide.

----------

## Kosmas

No problem. Just if you please edit your post and add [SOLVED] to the subject.

----------

## cayenne

 *magister wrote:*   

> Thanks, that seems to have fixed it.  Looks like that's been left out of the installation guide.

 

Thank you, this helped me too..was having several problem with new boxes....losing their resolv.conf on every boot...

This really does need to be added to the install manuals!!

C

----------

## UberLord

What needs to be in the install manuals is discouraging users to set a dns domain.

99.99% of the time you don't need it.

----------

## Stefano Crocco

Hello to everyone.

Since today, I'm having some problems with the /etc/resolv.conf file. I used to keep there the dns provided by my isp and everything worked correctly. Today, after an emerge --sync followed by emerge --update world and a reboot, I found out that that file had been replaced by one with the following content:

```

# Generated by net-scripts for interface lo

domain casa

```

Following the Gentoo Installation Guide, I tried to add the "nodns" option to the dchp_eth0 entry in /etc/conf.d/net and /etc/conf.d/net.eth0 (I didn't know which was the correct one, so I tried both). What I found out is that the option was already there (which should have been obvious to me, since I knew I was managing that file by hand, but I had forgot). At any rate, that option doesn't seem to have any effect.

In despair, I also tried to make the /etc/resolv.conf file read only (chmod a-w /etc/resolv.conf), but still, after reboot I found that the file had been overwritten.

Has anybody some idea of who is changing the file and/or how I can stop it from doing it?

Thanks in advance

----------

## infernus

I'm not exactly sure what is changing it but if you have root access on your machine do this:

1. Edit /etc/resolv.conf and add whatever DNS servers you need

2. Instead of making it read-only, you can make it immutable by running the following command as root (or with sudo)

```
# chattr +i /etc/resolv.conf
```

Now you can't edit it unless you reverse the command by using "-i" instead of "+i"

Even the system can't overwrite that now. Hope that helps.

----------

## Spear

This is normal.

https://forums.gentoo.org/viewtopic-t-499334-highlight-resolv+conf.html

----------

## uaeb

Edit: Woops.. Just skimmed the OP again and noticed I missed this was already tried.. Ignore the rest of this message.

Assuming you're using dhcp, Add or Edit "/etc/conf.d/net", with:

```
config_eth0=( "dhcp" )

dhcp_eth0="nodns"
```

You might need to alter the above according to your specific setup. Have a look at /etc/conf.d/net.example for more info.

----------

## Stefano Crocco

 *Spear wrote:*   

> This is normal.
> 
> https://forums.gentoo.org/viewtopic-t-499334-highlight-resolv+conf.html

 

Thanks, it worked

----------

## cwall64

 *Stefano Crocco wrote:*   

>  *Spear wrote:*   This is normal.
> 
> https://forums.gentoo.org/viewtopic-t-499334-highlight-resolv+conf.html 
> 
> Thanks, it worked

 

Glad it worked for you, but it is still driving me crazy!

/etc/conf.d/net:

```

config_eth0=( "dhcp" )

dhcp_eth0="nodns"

dns_servers_eth0=( "192.168.1.2" " 192.168.1.1" )

dns_domain_eht0="chris-wall.lan"

dns_search_eht0="chris-wall.lan"

```

/etc/resolv.conf after reboot:

```

gentoo ~ # cat /etc/resolv.conf

nameserver 192.168.1.1

```

Any thoughts?  what am i missing?

Chris

----------

## timeBandit

Merged above six posts here.

----------

## UberLord

 *cwall64 wrote:*   

> 
> 
> /etc/resolv.conf after reboot:
> 
> ```
> ...

 

Nothing I know of did that to resolv.conf.

Most things in Gentoo should stick a comment at the top stating which program made the change.

----------

