On Thu, 2017-06-29 at 13:14 +0100, Colin Helliwell wrote:
Is there a way to get NM to alter fully on-the-fly which connection is preferred/default for traffic? I see that I can modify the route-metric parameter: if the connection is taken down and up again then I see the change in the output of 'route', and indeed this seems to change which connection is preferred. But is there a way to poke the change through without the down/up? (ideally via NM, or in any other safe & sane way) Ta
Hi, if you modify a connection profile that is currently active on an interface, those modifications do not automatically apply on the interface. You only modify the profile -- with the exception of connection.zone and connection.metered properties, these two apply immediately. As you figured out, after you modified a profile, you can get the connections working by doing a full down/up cycle. By just upping the connection (again): nmcli connection modify "$CON" ipv4.route-metric 42 nmcli connection up "$CON" An alternative, a bit more graceful is nmcli connection modify "$CON" ipv4.route-metric 42 nmcli device reapply "$DEV" this takes the changes from the profile and applies them on the device without going through a full down/up. Not all changes are re-applyable, so, if you change something that isn't, the command will just fail and do nothing. Basically, IP settings are reapplyable. There is also nmcli device set "$DEV" setting.property value [...] for example nmcli device set "$DEV" ipv4.route-metric 42 the difference is, that this change is run-time only. The connection profile.is never modified. Another way of thinking of this is, when you activate a "settings- connection" on a device, it copies the profile as "applied-connection". Later modifications with nmcli connection modify "$NAME" only modify the settings connection, not the applied connection (except connection.zone and connection.metered). Then nmcli device reapply copies the settings connection over to the applied connection (and applies them). And nmcli device set only modifies the applied connection directly (and applies the changes). You can also see the applied connection on D-Bus: busctl --system call org.freedesktop.NetworkManager /org/freedesktop/NetworkManager/Devices/19 org.freedesktop.NetworkManager.Device GetAppliedConnection "u" 0 best, Thomas
Attachment:
signature.asc
Description: This is a digitally signed message part