# [solved: avahi problem] why is resolv.conf overwritten?

## FishB8

I cannot figure out why the /etc/resolv.conf is being overwriten by /etc/init.d/net.eth0

I have name servers listed in /var/lib/net-scripts/resolv.conf that I need. When net.eth0 starts up it creates a soft link in /etc to that file. Great, that's what I expect. What I don't understand is why it then totally overwrites it with a regualr file that has the nameserver set to the gateway, 192.168.1.1 (which is NOT what I want)

Weather or not I define the dns servers within /etc/conf.d/net changes weather the /var/lib/net-scripts/resolv.conf is static or genereated, but does nothing to fix the problem of the /etc/resolv.conf link being overwritten.

I can't seem to find any documentation on why this is happening. Am I missing something?

----------

## Decibels

http://www.die.net/doc/linux/man/man8/dhcpcd.8.html

Try adding '-R' to your /etc/conf.d/net file for interfaces using dhcp

```

-R

    Prevents dhcpcd from replacing existing /etc/resolv.conf file.
```

----------

## madisonicus

Another option is to add a 

```
dhcp_ESSID="nodns"
```

line to /etc/conf.d/net.

See /etc/conf.d/net.example for more info.

HTH,

m

----------

## Decibels

I was trying to look up more info on that 'nodns',... and there isn't a man page that I can find that has it in there.

So checked /lib64/rcscripts/net/dhcpcd.sh and found this, so looks like this is how they map it. If I'm reading it

right then '-R' = 'nodns' 

```
        # Map some generic options to dhcpcd

        d="dhcp_${ifvar}"

        d=" ${!d} "

        [[ ${d} == "  " ]] && d=" ${dhcp} "

        [[ ${d} == *" nodns "* ]] && opts="${opts} -R"

        [[ ${d} == *" nontp "* ]] && opts="${opts} -N"

        [[ ${d} == *" nonis "* ]] && opts="${opts} -Y"

        [[ ${d} == *" nogateway "* ]] && opts="${opts} -G"
```

----------

## FishB8

Well, here's the problem: I'm not using dhcp.

I have it set to a static address. (I have some services that need to be accessed from the net, and I have to have a static address in order for the router to forward related ports to the correct IP)

All I have set in the config is the static IP and the route.

There is a resolv_avahi.conf file that _is_ linked to /var/lib/net-scripts/resolv.conf. I'm starting to wonder if maybe the resolv.conf link isn't actually overwritten, but renamed (or copied)  to resolv_avahi.conf first, before the regular non-linked resolv.conf file is created. (I have the sneaking suspicion that this is related to avahi somehow) It does get created each time by the net.eth0 script as well...

----------

## Decibels

I figured as much. Only seen the problem with dhcp. I have static and have never ran into the problem, so must be what you suspect. I don't use avahi though.

Have you checked with these:

http://www.die.net/doc/linux/man/man8/avahi-daemon.8.html

http://www.die.net/doc/linux/man/man5/avahi-daemon.conf.5.html

----------

## FishB8

Well, apparently avahi will read from resolv.conf if the publish-resolv-conf-dns-servers option is turned on.

I'm willing to bet that Gentoo has avahi set up a little different to that it reads from resolv_avahi.conf instead of resolv.conf in order that the nameservers for DNS and mDNS can be configured independantly. If so, the script that takes care of this is probably botched up. Will look into this more...

----------

## Decibels

I've never used avahi, but could you tell it to read resolv.conf instead?

```
-f | --file= FILE

    Specify the configuration file to read. (default: /etc/avahi/avahi-daemon.conf)
```

try giving it /etc/resolv.conf , might work. Certainly isn't going to make it any worse cause you can just switch it back.

----------

## FishB8

First, a typo: the file is not "resolv_avahi.conf" but rather "resolv.conf.avahi"

I found the problem.  In the avahi-daemon.conf I had "publish-dns-servers=192.168.1.1" for some reason. I commented it out and problem is fixed.

----------

