Change default route in LibreELEC 10.0 on RPi 4

  • Hi,

    I'm using LibreELEC 10.0 on RPi 4 and everything I need is working fine so far, except for a detail with networking.

    I do have both the eth0 and wlan0 interfaces enabled, and they are connected to different networks:

    - eth0 connected to the 192.168.199.0/24 network which provides IPTV from my ISP (this is the only one able to connect to the IPTV multicast streams of my ISP)

    - wlan0 connected to the 192.168.120.0/24 network which is where my NAS is located

    The plan is to keep both connections and Kodi will be able to show content from my NAS via the wlan0 interface and when it's any other "public" service it should go via eth0 (used for IPTV mainly).

    Code
    LibreELEC10:~ # ip route list
    default via 192.168.120.1 dev wlan0
    192.168.120.0/24 dev wlan0 scope link src 192.168.120.62
    192.168.120.1 dev wlan0 scope link
    192.168.199.0/24 dev eth0 scope link src 192.168.199.105
    192.168.199.1 dev eth0 scope link

    LibreELEC 10.0 keeps setting the wlan0 interface as default route, and trying to delete it to be able to add back a default route via eth0 doesn't work (the delete command doesn't seem to do anything, or something add back a default route, and when adding the new one, it complains a default route already exists).

    I found some other threads about default routes (but it was when using VPNs and on older versions of LibreELEC), and they mentioned to use connmanctl. I did try connmanctl move-after <wlan0 service> <eth0 service> to move the WiFi connection after the ethernet connection, and I lost my SSH session right after (on the wlan0 interface), but it did change the default route apparently because the IPTV started working.

    But at the next reboot everything was back again with wlan0 as default route.

    Any idea how to set the default route to be the eth0 interface instead of wlan0?

    My googling it failing tonight....

    I could add a script executing connmanctl move-after <wlan0 service> <eth0 service> at every boot, but if this make me lose SSH it isn't a real solution as I will be cut out of the RPi 4 (my router firewall isolate the IPTV LAN from everything else to isolate all the multicast streams there inside and not mess with the IPTV service provided by my ISP, so I can't connect via SSH on eth0).

    Any input or idea is welcome, thanks a lot

  • Code
    cp /etc/connman/main.conf /storage/.config/connman_main.conf
    sed -i 's/PreferredTechnologies = ethernet,wifi,cellular/PreferredTechnologies = ethernet/g' /storage/.config/connman_main.conf
    reboot

    ^ Removing wifi from PreferredTechnologies should ensure eth0 always has the default route (maybe .. not tested). You can then create a systemd service file to set defaults routes after the network is up and before Kodi starts.

  • Thanks for the quick reply chewitt .

    I'm trying right now, at a first reboot nothing changed. Few reboot later it looks like it made something as IPTV works and it can also connect to the content on my NAS, so both networks seem to be enabled and working with a default route on eth0.

    But I can't connect via SSH anymore and also the Samba default shares aren't accessible anymore.

    It looks like the same result as when I did execute connmanctl move-after <wlan0 service> <eth0 service>.

    I'm going to explore a bit what happen by connecting eth0 to another LAN (still different than the LAN of wlan0, to clearly see the various routes) that I should have access to so I don't lose SSH and can look at the routes and also the connman logs (will start it in debug mode to see if I can find some hint there as well).

  • Still couldn't find why wlan0 keeps becoming the default route from time to time, or why I lose SSH when it isn't.

    As a temporary workaround I'm testing with a systemd service adding a route for the /16 subnet of the multicast used by the IPTV to go via eth0.

    Looks like it does the job for now.

    Will keep reading and looking after this to see if I find a proper way to deal with this.