0

I have internet on my RPi via 4G USB dongle, modem connection managed by NetworkManager (Raspbian/debian 10) using /dev/ttyUSB0. I have also OpenVPN tunnel active. Now I wanted to share this internet connection via ethernet eth0 (with Wifi AP connected to it by cable). So I added new NetworkManager connection nmcli connection add type ethernet ifname eth0 ipv4.method shared con-name ethShared. However when I connect anything to eth0, RPi loses internet access because of NetworkManager adding default gateway via eth0 for some reason.

root@rpi3meteo:~# ip route
default dev eth0 scope link src 169.254.15.88 metric 202
default via 100.94.218.129 dev wwan0 proto static metric 700
10.5.6.0/24 via 10.5.6.5 dev tun0
10.5.6.5 dev tun0 proto kernel scope link src 10.5.6.6
10.42.0.0/24 dev eth0 proto kernel scope link src 10.42.0.1 metric 100
100.94.218.128/25 dev wwan0 proto kernel scope link src 100.94.218.191 metric 700
169.254.0.0/16 dev eth0 scope link src 169.254.15.88 metric 202

Also for some reason eth0 gets 2 IP addresses - 10.42.0.1 which is used also by internal DHCP server and also 169.254.15.88 (which is used in the spurious route table entry). I know 169.254.0.0/16 is link-local and for use without DHCP server, but don't know why NetworkManager configures it for connection of type "shared", which does have DHCP automaticaly provided by NetworkManager.

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:20:80:80 brd ff:ff:ff:ff:ff:ff
    inet 10.42.0.1/24 brd 10.42.0.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet 169.254.15.88/16 brd 169.254.255.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
3: wwan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 00:1e:10:1f:00:00 brd ff:ff:ff:ff:ff:ff
    inet 100.94.218.191/25 brd 100.94.218.255 scope global noprefixroute wwan0
       valid_lft forever preferred_lft forever
4: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100
    link/none
    inet 10.5.6.6 peer 10.5.6.5/32 scope global tun0
       valid_lft forever preferred_lft forever

Internet access for both RPi and Wifi clients start to work when I manually remove the spurious route via route del default dev eth0. However as the RPi is at a remote location, it needs to work even after a reboot without manual intervention.

I already tried to set ipv4.never-default parameter, but it didn't help. Also already tried to manually set the IP address range via ipv4.addresses. I also found a workaround with altering priority of the default route (ipv4.route-metric ) and dns (ipv4.dns-priority), but didn't have time to test it yet, however I am more interested in preventing it happen in the first place, or having NetworkManager deleting the route automatically each time the connection is activated.

connection.id:                          ethShared
connection.stable-id:                   --
connection.type:                        802-3-ethernet
connection.interface-name:              eth0
connection.autoconnect:                 yes
connection.autoconnect-priority:        0
connection.autoconnect-retries:         -1 (default)
connection.multi-connect:               0 (default)
connection.auth-retries:                -1
connection.master:                      --
connection.slave-type:                  --
connection.autoconnect-slaves:          -1 (default)
connection.secondaries:                 --
connection.gateway-ping-timeout:        0
connection.metered:                     unknown
connection.lldp:                        default
connection.mdns:                        -1 (default)
connection.llmnr:                       -1 (default)
802-3-ethernet.port:                    --
802-3-ethernet.speed:                   0
802-3-ethernet.duplex:                  --
802-3-ethernet.auto-negotiate:          no
802-3-ethernet.mac-address:             --
802-3-ethernet.cloned-mac-address:      --
802-3-ethernet.generate-mac-address-mask:--
802-3-ethernet.mac-address-blacklist:   --
802-3-ethernet.mtu:                     auto
802-3-ethernet.s390-subchannels:        --
802-3-ethernet.s390-nettype:            --
802-3-ethernet.s390-options:            --
802-3-ethernet.wake-on-lan:             default
802-3-ethernet.wake-on-lan-password:    --
ipv4.method:                            shared
ipv4.dns:                               --
ipv4.dns-search:                        --
ipv4.dns-options:                       ""
ipv4.dns-priority:                      0
ipv4.addresses:                         --
ipv4.gateway:                           --
ipv4.routes:                            --
ipv4.route-metric:                      -1
ipv4.route-table:                       0 (unspec)
ipv4.ignore-auto-routes:                no
ipv4.ignore-auto-dns:                   no
ipv4.dhcp-client-id:                    --
ipv4.dhcp-timeout:                      0 (default)
ipv4.dhcp-send-hostname:                yes
ipv4.dhcp-hostname:                     --
ipv4.dhcp-fqdn:                         --
ipv4.never-default:                     no
ipv4.may-fail:                          yes
ipv4.dad-timeout:                       -1 (default)
GENERAL.NAME:                           ethShared
GENERAL.DEVICES:                        eth0
GENERAL.STATE:                          activated
GENERAL.DEFAULT:                        yes
GENERAL.DEFAULT6:                       no
GENERAL.SPEC-OBJECT:                    --
GENERAL.VPN:                            no
GENERAL.ZONE:                           --
GENERAL.MASTER-PATH:                    --
IP4.ADDRESS[1]:                         10.42.0.1/24
IP4.ADDRESS[2]:                         169.254.15.88/16
IP4.GATEWAY:                            0.0.0.0
IP4.ROUTE[1]:                           dst = 10.42.0.0/24, nh = 0.0.0.0, mt = 100
IP4.ROUTE[2]:                           dst = 169.254.0.0/16, nh = 0.0.0.0, mt = 202
IP4.ROUTE[3]:                           dst = 0.0.0.0/0, nh = 0.0.0.0, mt = 202
0

I didn't found a solution, but at least found a workaround to get it working. I tried to change the route metrics as advised in this answer.

Setting the ipv4.route-metric on the ethShared connection to higher value (lower priority) didn't work, because it did not affect the spurious route via 169.254.15.88 at all.

So I ended up setting ipv4.route-metric for the 4G modem connection from default 700 to 99 (so it has now higher priority than the ethernet's 202 priority).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.