Re: Altering preferred connection

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:


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" value [...]

for example

nmcli device set "$DEV" ipv4.route-metric 42

the difference is, that this change is run-time only. The
[]( 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         UG    100    0        0 eth0         UG    400    0        0 ppp0 UH    400    0        0 ppp0   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':                          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                   no
connection.permissions:                 --                        --
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                       -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:                                               --                                <hidden>                          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:                    --
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.

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