Re: Altering preferred connection



On Tue, Jul 4, 2017 at 1:51 AM, Colin Helliwell <colin helliwell ln-systems com> wrote:

> On 03 July 2017 at 19:18 Greg Oliver <oliver greg gmail com> wrote:
>
> On Mon, Jul 3, 2017 at 4:50 AM, Colin Helliwell <colin.helliwell@ln-systems.com> wrote:
>
> > > On 03 July 2017 at 15:39 Thomas Haller <thaller redhat com> wrote:
> > >
> > > On Mon, 2017-07-03 at 14:32 +0100, Colin Helliwell wrote:
> > >
> > > Hi,
> > >
> > > > > An alternative, a bit more graceful is
> > > > >
> > > > > nmcli connection modify "$CON" ipv4.route-metric 42
> > > > >  nmcli device reapply "$DEV"
> > > >
> > > > These two commands are accepted, but 'route -n' doesn't indicate any
> > > > change to the metric?
> > >
> > > Hm, works for me.
> > >
...
> > > > >
> > > > > 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](http://profile.is) never modified.
> > > >
> > > > This one is more like what I'm aiming at - a non-volatile change to
> > > > the current connection, rather than modifying it permanently.
....
> > > 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.
>

Is there a good way to track this down some more?
'nmcli conn show':
connection.id:                          O2
connection.uuid:                        42bf3c07-9dd7-45f6-ba08-37dfc8a7a537
connection.stable-id:                   --
connection.interface-name:              --
connection.type:                        gsm
connection.autoconnect:                 no
connection.autoconnect-priority:        0
connection.autoconnect-retries:         -1 (default)
connection.timestamp:                   1499168619
connection.read-only:                   no
connection.permissions:                 --
connection.zone:                        --
connection.master:                      --
connection.slave-type:                  --
connection.autoconnect-slaves:          -1 (default)
connection.secondaries:                 --
connection.gateway-ping-timeout:        0
connection.metered:                     unknown
connection.lldp:                        default
ipv4.method:                            auto
ipv4.dns:                               --
ipv4.dns-search:                        --
ipv4.dns-options:                       ""
ipv4.dns-priority:                      0
ipv4.addresses:                         --
ipv4.gateway:                           --
ipv4.routes:                            --
ipv4.route-metric:                      -1
ipv4.ignore-auto-routes:                no
ipv4.ignore-auto-dns:                   no
ipv4.dhcp-client-id:                    --
ipv4.dhcp-timeout:                      0
ipv4.dhcp-send-hostname:                yes
ipv4.dhcp-hostname:                     --
ipv4.dhcp-fqdn:                         --
ipv4.never-default:                     no
ipv4.may-fail:                          yes
ipv4.dad-timeout:                       -1 (default)
ipv6.method:                            ignore
ipv6.dns:                               --
ipv6.dns-search:                        --
ipv6.dns-options:                       ""
ipv6.dns-priority:                      0
ipv6.addresses:                         --
ipv6.gateway:                           --
ipv6.routes:                            --
ipv6.route-metric:                      -1
ipv6.ignore-auto-routes:                no
ipv6.ignore-auto-dns:                   no
ipv6.never-default:                     no
ipv6.may-fail:                          yes
ipv6.ip6-privacy:                       -1 (unknown)
ipv6.addr-gen-mode:                     eui64
ipv6.dhcp-send-hostname:                yes
ipv6.dhcp-hostname:                     --
ipv6.token:                             --
gsm.number:                             --
gsm.username:                           --
gsm.password:                           <hidden>
gsm.password-flags:                     0 (none)
gsm.apn:                                mobile.o2.co.uk
gsm.network-id:                         --
gsm.pin:                                <hidden>
gsm.pin-flags:                          0 (none)
gsm.home-only:                          no
gsm.device-id:                          --
gsm.sim-id:                             --
gsm.sim-operator-id:                    --
gsm.mtu:                                auto
proxy.method:                           none
proxy.browser-only:                     no
proxy.pac-url:                          --
proxy.pac-script:                       --
GENERAL.NAME:                           O2
GENERAL.UUID:                           42bf3c07-9dd7-45f6-ba08-37dfc8a7a537
GENERAL.DEVICES:                        ttyMux1
GENERAL.STATE:                          activated
GENERAL.DEFAULT:                        no
GENERAL.DEFAULT6:                       no
GENERAL.SPEC-OBJECT:                    --
GENERAL.VPN:                            no
GENERAL.DBUS-PATH:                      /org/freedesktop/NetworkManager/ActiveConnection/2
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/Settings/1
GENERAL.ZONE:                           --
GENERAL.MASTER-PATH:                    --
IP4.ADDRESS[1]:                         10.67.212.130/32
IP4.GATEWAY:                            10.67.212.130
IP4.DNS[1]:                             82.112.254.2
IP4.DNS[2]:                             82.112.254.3
IP6.GATEWAY:                            --


> I'm just following along here, but you changed the metric of enp0s25, yet that interface is not in your routing table - just ppp0 and eth0.
>

Yes, enp0s25 was Thomas' example - I modified to my device

> It seems this is a lot of work to just change routing on an ad-hoc basis - if you are trying to achieve more granularity, why no just use iproute2 tools instead of poking NM to do it - it just seems like an extra turn to take to get to the finish line - but I am sure you have your reasons.

Well I don't currently have iproute2 (though I daresay I could add it if necessary), so since NM is already there it seemed 'tidy' to continue marshalling everything through that.
I did experiment with (busybox) 'route', but wasn't sure that there's a way - even with real 'route' or 'iproute2' - to do a single *modify*, rather than having to add a route *and* delete the old one. Which means pulling out the IP address and old metric value in order to match to the rule to be deleted. A more single/atomic modify would be cleaner.


Ahh, I see - you must be using an embedded / limited resource device of sorts.  I am unfamiliar with busybox's route implementation, but with iproute2 I would just add the new route with different metric, delete the original route with original metric and then flush the route cache (maybe not needed in your case).


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