# Yet more resolv.conf problems

## rickj

On a laptop I have two LAN interfaces, eth0 wired, eth1 wireless. Eth0 is sometimes on a local network with no DHCP, sometimes on a DHCP network, sometimes disconnected. It's configured to use DHCP by default, time out in ten seconds, then use a fixed fallback configuration. All this works fine.

The rot sets in when the wireless interface starts up. It always configures by DHCP. Regardless of whether it finds a network or not, it overwrites /etc/resolv.conf so that the DNS info for the first network is lost. If it does not connect, /etc/resolv.conf has nothing in it except comments. To add insult to injury, the working resolv.conf is not restored if eth1 is taken down.

Of course, I can stop this with the nodns option for eth1 (provided I use masked dhcpcd 4.0.7, stable version 4.0.2 seems to ignore this switch), but then I will never see an appropriate nameserver for eth1.

If both interfaces come up, each will generally have a nameserver, so that the appropriate behaviour is surely for the information from the second to be *appended* to resolv.conf. At a minimum, if the second interface does not connect, it should refrain from removing the DNS information which applies to an already-working interface. I'm at a loss as to how to obtain this behaviour.

----------

## cyrillic

```
# emerge openresolv 
```

----------

## rickj

Thanks cyrillic, after a bit of config-ing that seems to do at least some of the right things. I need to test it under different circumstances, and probably config a bit more as a result. I'll post results.

<EDIT> The more I test it, the better I like it. A handy utility that solves a real problem well.

----------

## rickj

So I had it all working well, but I had to try gilding the lily so I set up bonding.

The bonded interfaces work for some functions, but the resolv.conf is very basic. Despite the fact that the two devices involved n the bond are the same as the ones used previously, their DNS info is not transmitted to resolv.conf. Is there any way to persuade bonding to send its device info to openresolv?

----------

## cyrillic

Is your DHCP client running on the bond or on the underlying interfaces ?

----------

## rickj

It runs on the underlying interfaces. I tried, just now, to run it on bond0 and got:

```

# /etc/init.d/net.bond0 restart

 * Caching service dependencies ...                                       [ ok ]

 * Service net.bond0 stopping

No resolv.conf for interface bond0

 * Service net.bond0 stopped

 * Service net.bond0 starting

bond0: dhcpcd 4.0.7 starting

bond0: waiting for carrier

bond0: carrier acquired

bond0: broadcasting for a lease

bond0: offered 192.168.1.22 from 10.100.0.4

bond0: checking 192.168.1.22 is available on attached networks

bond0: acknowledged 192.168.1.22 from 10.100.0.4

bond0: leased 192.168.1.22 for 9054 seconds

bond0: add_route: Network is unreachable

SIOCADDRT: Network is unreachable                                         [ !! ]

 * Service net.bond0 started

```

and the network really was unreachable. Perhaps I'm just configuring it wrongly in /etc/conf.d/net. Any tips would be very welcome.

----------

## cyrillic

I have not played around with the fancy stuff like bonding and bridging, so I can't really help you there.

I normally let all my network interfaces come up separately, and whichever one has a connection will be the one that is used.

----------

## rickj

That's exactly the behaviour I'm seeking. I'd like to use the wired connection if available, and the wireless connection otherwise. Ideally, I'd do this automatically, even if I connect a wired connection where the wireless is able to connect to a network.

If your setup does this, how is it configured, please?

----------

## cyrillic

I have ifplugd installed and handling my wired interfaces, and openresolv handling DNS for multiple interfaces.

I did not need to configure anything, it just works.  :Smile: 

----------

## rickj

Great!

I emerged ifplugd, deconfigured all the bonding stuff, and, as you say, it "just works" 

It's a little strange that there is no trace of ifplugd in /etc/init.d or /etc/conf.d,  but it now seems to be run automagically at boot time. 

Many thanks for your kind help

----------

## cyrillic

Yeah, the Gentoo networking scripts have a lot more built-in functionality than most people realize.

Many thanks to the developers who set it up this way.

----------

