Persistent Static Routes in OSMC

I have come across an interesting predicament: I can’t seem to get OSMC to take a persistent static route. Traditionally this is pretty easy to do in linux - simply create the route-iface# file and possibly the NAT lookup table depending on distribution. However, given that I know OSMC is based on Debian (a Linux distribution I seldom use) and the fact that apparently every location suggested for Debian doesn’t seem to exist I have one simple question: how do I add a persistent static route to OSMC?

Say for example, in my network environment we have two gateways we need to be concerned with: one located at and one located at For this example, let’s say the subnet is a /16 and OSMC rPi 3 resides on the subnet while the supporting media server resides on subnet which is provided by the gateway at

Now, continuing on this example, let’s also say Windows, the OS running on the server has been configured (a long with the gateways) to properly send traffic across the gateways. Windows can trace, ping, nslookup, etc. the Raspberry Pi running OSMC all day long. However, in this scenario, the reverse is not true - the Raspbery Pi can’t get further than the gateway because a static route hasn’t been setup.

In this example, how can I tell OSMC on the rPi 3 to create a persistent static route that effectively adds the missing piece by adding the route: FROM USE gw ON dev eth0?

Did you use the forum search? It’s quite good.

ConnMan can be a pain for static routes. If this is Ethernet, and you’re familiar with networking, then you could instruct ConnMan to ignore your Ethernet adapter, and configure the interface directly via /etc/network/interfaces manually.

In /etc/connman/main.conf, put


This will break OSMC’s ability to configure eth0 via My OSMC, but you’ll have unfettered control over the adapter via the command line. Then you can sudo apt-get install ifup and set up the route in /etc/if-up.d

CC @DBMandrake

1 Like

@sam_nazarko Thank you for the information; I was able to setup the static routes as needed for future network implementation (about 3 weeks). While I am very familiar with networking and linux, or at least enterprise linux in general, Debian and related are out of my depth and up until today I have never heard of ConnMan although I see it brought up frequently when searching Google about Debian.

I had to make a few modifications to what you had said to have ConnMan ignore eth0 and install traditional networking:

The path to the ConnMan configuration is: /etc/connman.conf

Also, to install traditional networking I had to use sudo apt-get install ifupdown and then to restore the parts which were left out from that I had to run sudo apt-get install ppp rdnssd iproute2-doc isc-dhcp-client libatm1 ndisc6 resolvconf avahi-autoipd ethtool (one of these packages gets installed as a dependency of another but that’s the entire list).

Naturally, as to be expected, that wasn’t the end of it as the configuration file for the eth0 needs to be created in /etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
        address 10.0.XXX.XX
### Static Routing on eth0 Device for SAMPLE ###
        post-up route add -net netmask gw

Then just reboot the device. One caveat: the OSMC splash screen is “written over” by the Linux boot notifications.

For me, this was pretty easy (once I knew where to look); I’m comfortable with the Linux CLI but it would be nice to be able to add static routing more “natively” as a feature suggestion.

You should be able to use ip route add without installing any additional packages, but of course ifupdown would be needed if you want to do this as the network is brought up or down.

This means either a systemd service is failing, or taking longer than 30 seconds to finish. It’s probably the early HTTP time service which normally depends on ConnMan, but now starts too early and cannot receive the time from the Internet properly.

This is a really niche request, and there are other improvements I’d like to work on in the networking area first. I am sure that these instructions will benefit other users though, thanks!

1 Like

[quote=“sam_nazarko, post:5, topic:18873, full:true”]
You should be able to use ip route add without installing any additional packages, but of course ifupdown would be needed if you want to do this as the network is brought up or down.[/quote]

Indeed; in this case I wanted it to persist over network up/down changes and reboots. Sure, adding the routes again are simple and rPi3’s aren’t usually ever turned off but “setting it and forgetting it” is something I like to do. It’s part of why I use OSMC with Emby.

[quote=“sam_nazarko, post:5, topic:18873, full:true”]
This means either a systemd service is failing, or taking longer than 30 seconds to finish. It’s probably the early HTTP time service which normally depends on ConnMan, but now starts too early and cannot receive the time from the Internet properly.[/quote]

I believe you are right; while I couldn’t see the first message as it was on my 4K so I was pretty far away from the screen, the glimpses I got said something about waiting 30 seconds for something to finish. However, if it’s internet time, it seems the device does get the time correct (guessing NTP or waiting for the time via HTTP) still.

Ah, I didn’t know that. Well, I marked this solved @sam_nazarko with the instruction post for others to search for (there’s no answers when you search the forums for this otherwise which was why I posted).

I am surprised though - OSMC’s networking seems to work pretty well; up until now I had no issues but that was with the standard ethernet on an rPi3. I guess my setup is a bit niche having to have rack servers to store the media and a desktop with Emby Server to decode things like H.265 and send it off to the rPi3 and OSMC.

I guess my home network is getting too crowded between guests, home, and work stuff given that I’ve had to create more VLANs.

Either case, thank you for the help and as I said, I marked the directions post as the answer for anyone else that might be looking for it and found searching coming up empty.

Time is set in two ways. First with early time sync via wget and HTTP. This lets us get a rough idea of time, and close enough for NTP to sync quickly and avoid nasty time jumps (which can cause issues with things like CEC which do not use CLOCK_MONOTONIC_RAW). We also use fake-hwclock, but that’s not really accurate and just takes the time of the last shutdown if it was done properly.

sudo systemctl disable http-time will probably remove the error.


I’ve followed the information here to set up a static route for eth0, but now the wlan0 becomes the default gateway and I don’t want that. How can I fix this?

My setup:
OSMC wlan0 --> router1 netblock
OSMC eth0 --> router2 netblock

router2 is connected to router1 via ethernet. I want to keep wlan0 enabled on OSMC for fallback, but eth0 should be the primary connection and default gateway. However, I have a media server ( connected to router1 via ethernet, so now when I want to access stuff from OSMC on it goes through wlan0 instead of eth0. That’s why I wanted to create a persistent static route: route add -net netmask gw dev eth0. I don’t mind if traffic for everything else on the goes through wlan0, but traffic to should go through eth0 because it’s a wired connection all the way through.

Because of this I followed the instructions here and removed eth0 from connman, installed ifupdown and configured eth0 through /etc/network/interfaces and added the static route for The problem is that now OSMC treats wlan0 as default gateway:

osmc@osmcsk:~$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    0      0        0 wlan0   U     0      0        0 wlan0 UH    0      0        0 wlan0 UGH   0      0        0 eth0   U     0      0        0 eth0

I think you’ve made this far too complicated.

Unless you’re expecting a digger to cut through your ethernet cables, I’m not convinced of the need “to keep wlan0 enabled on OSMC for fallback”. Ethernet works reliably, so the scenarios where you’ll need to fallback to Wifi are likely to be few and far between.

The simplest, most logical and most straightforward solution is to undo your modifications on OSMC and send all traffic through eth0. Then add a static route on router2 to send traffic to router1.

As to your question about why wlan0 is the default gateway, I assume that you’ve disabled eth0 using NetworkInterfaceBlacklist=eth0 so connman will only see wlan0.