RE: Recommendations for Configuring DHCP on Multiple Interfaces
David Hauck
Fri Jun 06 17:33:09 2014
On Friday, June 06, 2014 9:31 AM, Roy Marples wrote:
> 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
Actually, I admittedly haven't looked at "interface specific" configurations in dhcpcd.conf before, but isn't this exactly what I need here? Couldn't I do something like:
...
interface eth1
nogateway
nooption 12 # ignore hostname on this interface
In a two-interface (eth[01]) DHCP setup this would allow eth0 to do full DHCP negotiation and eth1 to ignore gateway and hostname. Do I have this right?
> 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.
Do you mean "install default route"?
> When the interface is configured (ie, link up) then dhcpcd will change
> the default route to the preferred interface and gateway.
I'm not following the specifics of this. Could you maybe provide a concrete example?
>> 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!
OK.
>>> 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.
OK, so absent potentially using something like the interface specific "nooption 12" (my case) configuration, this script would not reset the hostname if it's previously been configured by an earlier interface's DHCP negotiation. Took me a bit to read through this script thinking about my use case(s), but I think I see what's going on (there's also the ability to use 'env' and 'force_hostname' to further control this behaviour).
> gateway, well dhcpcd handles this internally. We've already discussed
> the possible options above.
Thanks,
-David
> Thanks
>
> Roy
Archive administrator: postmaster@marples.name