dhcpcd-discuss

RE: Recommendations for Configuring DHCP on Multiple Interfaces

Roy Marples

Fri Jun 06 16:30:45 2014

On 06/06/2014 17:09, David Hauck wrote:
Can you say more about how dhcpcd manages this? Our system has very
diverse network configurations (including up to 6+ network interfaces
- all wired) and we need fairly explicit control of these. One
configuration that I'm currently pondering is the "all interfaces
configured for DHCP" scenario and it is this scenario that I'm curious
about. Unless I understand exactly how dhcpcd controls this case (in
any/all circumstances) I would like to be able to control its
operation on an interface by interface basis (for e.g., I know about
the lowest metric wins, multi-default gateway scenario, but I need to
prevent this configuration from occurring - i.e., enforce a single
gateway on a specific interface only).

You could add -DHAVE_ROUTE_METRIC=0 to CPPFLAGS and recompile dhcpcd.
This would effectively manage your routing like BSD where there are no route metrics and enforce your one gateway policy. To ensure that your specific interface "wins" just give it the lowest metric number in dhcpcd.conf

But Beware!
IF this interface is not configured (ie, link down) and another is then dhcpcd will install a default interface for that interface and gateway. When the interface is configured (ie, link up) then dhcpcd will change the default route to the preferred interface and gateway.

As far as I know (under my Debian-like sysvinit system) the network is
brought up during init via an RC script  with 'ifup -a'. I'm not
exactly sure how ifup/down iterates interfaces, but my understanding
is that it invokes dhcpcd "an interface at a time". If so, I wonder if
these invocations can be parameterized in any particular way (e.g.,
the reference I saw somewhere to /etc/default/dhcpcd), or whether the
recommendation is to do this via the dhcpdh-hooks mechanism instead
(which would be somewhat intricate).

Ah yes.
You're probably thinking of the dhcpcd package in Debian. That is ancient, the package you want is dhcpcd5 (really dhcpcd6) and also old, I should update it.
Of course, hopefully you're compiling from source ;)

The dhcpcd5 package has a script that pops into /etc/init.d (yes, I need to supply a systemd script as Debian recently changed)

So basically it's one daemon that controls all interfaces, and realistically the only way it can work in a BSD way which you want. I would NOT use the per interface invocation, which is a positively ancient way of managing this kind of stuff!

As to information duplication, well all of the hook scripts take this
into account.
So for resolv.conf and ntp{d}.conf it's all managed.
You may want to look into using resolvconf (I personally recommend
openresolv ;) ) as that can handle it better than dhcpcd.

Interesting. So multiple identical incoming nameserver parameters are
merged/normalized across interfaces (resulting in a single
recolve.conf file with the merged nameserver list - including removed
duplicates)?

If I wanted to do the same for hostname and gateway across interfaces
I would need to do something similar? This would be instead of doing
some other kind of interface-specific invocation of dhcpcd from ifup
that just informed this interface negotiation to ignore/not negotiate
(for e.g.) gateway and/or hostname? Personally, I'd prefer the former
if it was available since it seems easier ;).

hostname, no.
hostname has specific rules of when it's configured, please read the hook script for exact details Basically it will update it IF unset or localhost or the the OLD name provided by the DHCP server.
That may or may not fit your goal.

gateway, well dhcpcd handles this internally. We've already discussed the possible options above.

Thanks

Roy

Follow-Ups:
RE: Recommendations for Configuring DHCP on Multiple InterfacesDavid Hauck
References:
Recommendations for Configuring DHCP on Multiple InterfacesDavid Hauck
Re: Recommendations for Configuring DHCP on Multiple InterfacesRoy Marples
RE: Recommendations for Configuring DHCP on Multiple InterfacesDavid Hauck
Archive administrator: postmaster@marples.name