Re: Altering preferred connection



On Thu, Jul 6, 2017 at 7:57 AM, Colin Helliwell <colin helliwell ln-systems com> wrote:

> On 03 July 2017 at 15:50 Colin Helliwell <colin.helliwell@ln-systems.com> wrote:
>
> > On 03 July 2017 at 15:39 Thomas Haller <thaller redhat com> wrote:
> >
....
> > ah, it's "modify", not "set".
> >
> > nmcli device modify enp0s25 ipv4.route-metric 42
>
> Ok, no error to the command now, but 'route -n' indicates no change has occurred:
>
> root@wg6s:~# route -n
> Kernel IP routing table
> Destination Gateway Genmask Flags Metric Ref Use Iface
> 0.0.0.0 192.168.10.254 0.0.0.0 UG 100 0 0 eth0
> 0.0.0.0 10.65.106.176 0.0.0.0 UG 400 0 0 ppp0
> 10.65.106.176 0.0.0.0 255.255.255.255 UH 400 0 0 ppp0
> 192.168.10.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
>
> and the RTD of a ping also suggests the 'preference' is un-changed.
>

A bit more info on this. I tried the command on my eth0 connection, and it did indeed result in [according to 'ip route'] a change to the metric.
But it doesn't on my gsm connection. I wonder if it's to do with their differing natures: eth0 is both the network interface name and the NM device name, whereas the gsm interface is ppp0 but the NM device is ttyMux1. Maybe not a simple text difference as such, but the fact that the latter is on top of PPP.
Logging the command on the two:

Jul  6 13:17:45 wg daemon.debug NetworkManager[835]: <debug> [1499343465.1376] device[0x486490] (eth0): reapply (version-id 11)
Jul  6 13:17:45 wg daemon.debug NetworkManager[835]: <debug> [1499343465.1486] device[0x486490] (eth0): reapplying wired settings
Jul  6 13:17:45 wg daemon.debug NetworkManager[835]: <debug> [1499343465.1489] device[0x486490] (eth0): set-link: ignore link negotiation
Jul  6 13:17:45 wg daemon.debug NetworkManager[835]: <debug> [1499343465.1492] firewall: [0x4dadb8,change*:"eth0"]: firewall zone change eth0:default (not running, simulate success)
Jul  6 13:17:45 wg daemon.info dhclient: Received signal 15, initiating shutdown.
Jul  6 13:17:45 wg daemon.debug NetworkManager[835]: <debug> [1499343465.1509] kill child process 'dhcp-client-eth0' (1199): waiting up to 500 milliseconds for process to terminate normally after sending SIGTERM (15)...
Jul  6 13:17:45 wg daemon.info dhclient: DHCPRELEASE on eth0 to 192.168.10.254 port 67
Jul  6 13:17:45 wg daemon.debug NetworkManager[835]: <debug> [1499343465.6510] kill child process 'dhcp-client-eth0' (1199): sending SIGKILL...
Jul  6 13:17:45 wg daemon.debug NetworkManager[835]: <debug> [1499343465.6552] kill child process 'dhcp-client-eth0' (1199): after sending SIGTERM (15) and SIGKILL, process 1199 exited by signal 9 (504333 usec elapsed)
Jul  6 13:17:45 wg daemon.info NetworkManager[835]: <info>  [1499343465.6557] dhcp4 (eth0): canceled DHCP transaction, DHCP client pid 1199
Jul  6 13:17:45 wg daemon.info NetworkManager[835]: <info>  [1499343465.6558] dhcp4 (eth0): state changed bound -> done
Jul  6 13:17:45 wg daemon.info NetworkManager[835]: <info>  [1499343465.6677] dhcp4 (eth0): activation: beginning transaction (timeout in 45 seconds)
Jul  6 13:17:45 wg daemon.debug NetworkManager[835]: <debug> [1499343465.6680] dhcp4 (eth0): creating composite dhclient config /var/lib/NetworkManager/dhclient-eth0.conf
[etc]

vs.

Jul  6 13:29:49 wg daemon.debug NetworkManager[835]: <debug> [1499344189.3624] device[0x4c2388] (ttyMux1): reapply (version-id 14)
Jul  6 13:29:49 wg daemon.debug NetworkManager[835]: <debug> [1499344189.3734] firewall: [0x4daea0,change*:"ppp0"]: firewall zone change ppp0:default (not running, simulate success)
Jul  6 13:29:49 wg daemon.debug NetworkManager[835]: <debug> [1499344189.3741] ip4_config_start
Jul  6 13:29:49 wg daemon.debug NetworkManager[835]: <debug> [1499344189.3749] pacrunner: call[0x4e84c0]: send: new config ({'Interface': <'ppp0'>, 'Method': <'direct'>, 'BrowserOnly': <false>},)
Jul  6 13:29:49 wg daemon.info NetworkManager[835]: <info>  [1499344189.3805] audit: op="device-reapply" interface="ppp0" ifindex=4 args="ipv4.route-metric" pid=1343 uid=0 result="success"
Jul  6 13:29:49 wg daemon.debug NetworkManager[835]: <debug> [1499344189.3897] pacrunner: call[0x4e84c0]: sending failed: GDBus.Error:org.freedesktop.DBus.Error.NameHasNoOwner: Name "org.pacrunner" does not exist
Jul  6 13:29:49 wg daemon.debug NetworkManager[835]: <debug> [1499344189.3944] firewall: [0x4daea0,change*:"ppp0"]: complete: fake success
[nothing more after this]

(a similar not-much-activity occurs if I instead use   nmcli connection modify "$CON" ipv4.route-metric 42; nmcli device reapply "$DEV")


I'd also thought "well if I can't decrease the ppp metric, then I'll increase the eth one instead", to achieve the change of preference. Trouble is that the time that I'm doing this is when the ethernet connection is broken, so the dhcp renewal fails, so the change of route doesn't happen.


I would really have completely different routing tables for this rather than changing metrics.  Source routing /netfilter is your friend here, but source routing also comes with security risks, so you need to make sure netfilter is stopping anything you do not want.  Basically, then you can easily say the interafce it comes in on, it goes out of (or any interface you want...).

The good thing about the linux kernel is that there are usually ten(s) or more ways of doing what you want/need.


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