# SOLVED: problems with resolv.conf

## mjcoss

I'm adding a couple of virtual bridges to my machine - br1 and br2.  So I added a few lines to /etc/conf.d/net, like so

bridge_br1="fakeif1"

config_br1="192.168.1.1/24"

brctl_br1="setfd 0

        sethello 1

        stp off"

and a similar setup for br2, and link appropriate /etc/init.d/net.br? to /etc/init.d/net.lo and try starting them using

% /etc/init.d/net.br1 start

Doing this cause /etc/resolv.conf to be overwritten with effectively an empty file.  I am running dhcp on my real network, and need to have it be the only interface that updates resolv.conf.  But I can't seem to get whatever module is overwriting resolv.conf to quit it.  At first I thought it might be some ipv6 weirdness, but I disabled it to no avail.  I even tried adding a --allowinterfaces option to my dhcpcd line.  Is there some magic keyword I can put into /etc/conf.d/net to say leave resolv.conf alone for the given interface.

Thanks.Last edited by mjcoss on Fri Nov 01, 2013 7:41 pm; edited 1 time in total

----------

## albright

perhaps

```
dhcp_eth0="nodns"
```

(for whatever interface ...)

----------

## Gentree

```
dhcpcd_eth0=" -C resolv.conf"

```

----------

## Hu

Both should work, but the solution proposed by albright has the advantage that it should do the right thing without regard to which DHCP client you use.  The solution proposed by Gentree is explicitly applicable only when using dhcpcd.

----------

## mjcoss

The problem is that I'm trying to set up 3 bridges - 1 that is really connected and 2 that are for testing.

The real one needs to use dhcp to get a real address

config_br0="dhcp"

config_enp13s0="null"

config_enp12s0="null"

dhcpcd_br0="-t 10"

brctl_br0="setfd 0

        sethello 1

        stp on"

depend_br0(){

        need net.enp13s0

}

And this works fine when I bring up br0, it correctly gets an IP address, updates resolv.conf and all is good.  The other bridges are for testing purposes only, and have static ip addresses associated with them, thus

bridge_br1="fakebridge"

config_br1="192.168.1.1/24"

brctl_br1="setfd 0

        sethello 1

        stp off"

but if I start br1 via the init.d/net.br1, it overwrites resolv.conf with a null file.  Note there is no dhcp specified in br1 configuration (static ip), and no reason for resolv.conf to be overwritten.  I could add a dhcp_br1="nodns" or the alternative -C resolv.conf since I am using dhcpcd but that seems wrong.

----------

## Gentree

man dhcpcd:

 *Quote:*   

> 
> 
> SYNOPSIS
> 
>      dhcpcd [-ABbDdEGgHJKkLnpqTVw] [-C, --nohook hook] [-c, --script script] [-e, --env value]
> ...

 

from /var/log/messages I see:

```

Oct 29 07:55:40 localhost init: Entering runlevel: 3

Oct 29 07:55:41 localhost dhcpcd[1763]: version 5.5.6 starting

Oct 29 07:55:41 localhost dhcpcd[1763]: all: not configured to accept IPv6 RAs

```

So it looks like dhcpcd is started with "all" interfaces. You could find out where to change that or conclude it will scan all interfaces and thus putting in the specific options is not "wrong". 

That's the way I read it, I do not claim much expertise in this area.

 :Cool: 

----------

## mjcoss

Nope.  Adding those lines, either dhcp_br1="nodns" or dhcpcd_br1="-C resolv.conf"  have absolutely no effect.  And I do not see any reference to "all interfaces" in my /var/log/message with regards to dhcpcd.  And as I mentioned I tried adding to dhcpcd_br0="-z br0" to say that I only want it on br0.  That doesn't work either.  Note that it is not dhcpcd that is overwriting my resolv.conf but rather something labelled "net-scripts"

The first line in resolv.conf after I start the bridge br1

# Generated by net-scripts for interface br1

The first line in resolv.conf after I start the bridge br0

# Generated by dhcpcd from br0

The first appears to come from /lib/netifrc/net/system.sh but I can't seem to find a way to get it either not run the script or just leave resolv.conf alone.

----------

## Gentree

 *Quote:*   

> # Generated by dhcpcd from br0 

 

Then you need to make your dhcpcd options relate to br0 not br1. 

re albright's suggestion  

```
dhcp_br1="nodns" 
```

in /etc/conf.d/net 

you will need to do it for all interfaces , since it only has to happen once (unless you are sure which it is an minimise later).

Also (or rather alternatively)  in /etc/dhcpcd.conf

```
nohook resolv.conf
```

That should fix one culprit.

Rather than saying what you don't see post what you do see re. dhcp in  /var/log/messages

----------

## Gentree

 *Quote:*   

> Note that it is not dhcpcd that is overwriting my resolv.conf but rather something labelled "net-scripts" 

 

Then find out what package that comes from and check the doc / man page.

----------

## mjcoss

Obviously, I'm not being clear.  I have 3 bridges.  

One is connected to my corp network and I need dhcp to get an address, set the routes, and give me a resolv.conf for dns.  This is br0.  The other two bridges, br1 and br2, are test bridges which do not use dhcp, have statically provisioned ip address, and I want to be able to start them by default at system startup via /etc/init.d/net.br1 and /etc/init.d/net.br2

These are the messages in /var/log/message re: dhcpcd 

Oct  7 11:58:11 cerberus dhcpcd[4035]: br0: carrier acquired

Oct  7 11:58:11 cerberus dhcpcd[4035]: br0: soliciting an IPv6 router

Oct  7 11:58:11 cerberus dhcpcd[4035]: br0: rebinding lease of xxx.xxx.xxx.xxx

Oct  7 11:58:21 cerberus dhcpcd[4035]: br0: leased xxx.xxx.xxx.xxx for 259200 seconds

Oct  7 11:58:21 cerberus dhcpcd[4035]: br0: adding host route to xxx.xxx.xxx.xxx via 127.0.0.1

Oct  7 11:58:21 cerberus dhcpcd[4035]: br0: adding route to xxx.xxx.xxx.0/23

Oct  7 11:58:21 cerberus dhcpcd[4035]: br0: adding default route via xxx.xxx.xxx.xxx

Oct  7 11:58:21 cerberus dhcpcd[4035]: forked to background, child pid 4087

which is what I expect and need.  Starting br1 and/or br2 do not generate any dhcpcd messages but does overwrite resolv.conf.  And as I've shown, resolv.conf is not be rewritten by dhcpcd but by net-scripts.  Restarting br0 will restore resolv.conf so I guess I could just add a dependency that says that br0 must start after br1 and br2 which will give me the right resolv.conf, but I had hoped for a better way to stop the scripts from regenerating resolv.conf incorrectly.

----------

## Gentree

OK, so you could work around it but you want to understand and control it rather than walk away. I'd probably be the same. 

So repeat my last suggestion:

Then find out what package that [init-scripts] comes from and check the doc / man page.

----------

## mjcoss

Well it's part of the net-misc/netifrc package and no man pages.  There are 2 docs in /usr/share but nothing particularly enlightening jumps out at me in those two files as a way to stop resolv.conf from being overwritten by system.sh.  But looking at the script it does seem that if "/sbin/resolvconf" is installed, it will pass the updates to it rather than overwriting the file.  Might be a better hack than pinning the order of startup of the bridges.

----------

## TomWij

 *mjcoss wrote:*   

> Well it's part of the net-misc/netifrc package and no man pages.  There are 2 docs in /usr/share but nothing particularly enlightening jumps out at me in those two files as a way to stop resolv.conf from being overwritten by system.sh.  But looking at the script it does seem that if "/sbin/resolvconf" is installed, it will pass the updates to it rather than overwriting the file.  Might be a better hack than pinning the order of startup of the bridges.

 

Documentation is present at:

/usr/share/doc/netifrc-0.1/README.bz2

/usr/share/doc/netifrc-0.1/net.example.bz2

Bug about less accessible documentation filed at:

https://bugs.gentoo.org/show_bug.cgi?id=489822

Bug about an accessible solution for resolf.conf being overwritten filed at:

https://bugs.gentoo.org/show_bug.cgi?id=489826

I don't have any experience with bridges; but if you keep experiencing this, feel free to ping me and I can ask the netifrc developers to take a look.

----------

## mjcoss

So it turns out that if you emerge openresolv, this installs /sbin/resolvconf.  And /sbin/resolvconf correctly maintains /etc/resolv.conf no matter what order I bring up the bridges by default.  I didn't have to make any system configuration changes.  Without it, I could find no obvious solution to the bad behaviour of the netifc scripts.

Thanks for the suggestions.

----------

## ulenrich

dhcpd 

is meant as a super-meta daemon 

(which eg. by default also manages wpa_supplicant when additional git patch applied).

So, why not try the other way round:

1) let /sbin/resolvconf just handle 

 a) /etc/resolv.conf.head

 b) /etc/resolv.conf.tail

as apropriate for your purposes.

2) let dhcpd create /etc/resolv.conf out of the above

... just an idea ...

[edit] Uups, this thread just turned solved meanwhile

----------

