Re: Automatically assign link local ipv4 address if dhcp fails



On Wed, Mar 15, 2017 at 04:24:02PM +0100, Viktor S. Wold Eide wrote:
On Wed, Mar 15, 2017 at 3:16 PM, Beniamino Galvani <bgalvani redhat com>
wrote:

You can achieve this by creating two connections with different
autoconnect priorities:

 nmcli connection add type ethernet ifname eth0 con-name eth0-auto
 nmcli connection add type ethernet ifname eth0 con-name eth0-ll
 nmcli connection modify eth0-auto connection.autoconnect-priority 100
 nmcli connection modify eth0-ll connection.autoconnect-priority 50
ipv4.method link-local

In this way NM will try first to autoactivate eth0-auto and, upon
failure, it will fall back to the link-local connection.



Hi Beniamino,

Thanks a lot for the quick response and for the suggestion.

What would happen if the DHCP server is only temporary down in the scenario
with two connections that you describe? I would expect that the low
priority link-local would remain active, even if the DHCP server came back
up.

Correct, the link-local connection remains active until someone
manually reactivates the DHCP connection, or the system is rebooted.

If there are other alternatives, I would appreciate suggestions.

I'm not aware of alternatives at the moment.

As written, a different DHCP client could have been an option, but no luck
so far in this direction.

AFAIK dhcpcd support in NetworkManager hasn't received updates since
long time and I don't know if it is still working well, but you should
be able to turn it on. You said that dhcpcd supported the fallback to
link-local addresses, but I don't see code in NM to do that. Maybe
this logic was done entirely in the client, but I wonder if this works
when dhcpcd is controlled by NM.

Alternatively, it might be possible to hook into
the system, for example via a script in /etc/NetworkManager/dispatcher.d
that can check for DHCP failure / success. However, I was wondering if I
had missed something or whether there is some recommended configuration to
achieve the desired behavior.

We have an open bugzilla [1] about supporting multiple IP methods
(DHCP, link-local, static) at the same type for a connection. Probably
that enhancement would solve your case, but at the moment I don't
think anybody is working on it.

Beniamino

[1] https://bugzilla.gnome.org/show_bug.cgi?id=773481

Attachment: signature.asc
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]