Today I stumbled upon the fact that my KODI based media box (Raspberry Pi 4) is still using a dynamic IPv4 address. Hence I want to connect via ssh regularly, I had to set a static IP on LibreElec (former OpenELEC) which my KODI mediacenter is running on.
To achieve that, I had to connect to the Raspberry via SSH and ran the following command.
$> connmanctl config "$(connmanctl services | awk '/^\*/ {print $3}')" --ipv4 manual 192.168.178.88 255.255.255.0 192.168.178.1
What this command does to set a static IP on LibreELEC is:
-  It determines the the currently used service interface via “$(connmanctl services | awk ‘/^\*/ {print $3}’)” .
connmanctl services gives a list of a available services to connect to the network.
For example:*AO Wired ethernet_dca12324234f3_cable WLAN01 wifi_dca12324234f3_4ee233232232256c61_managed_psk o2-WLAN40 wifi_dca12324234f3_656ff574c4f86e3430_managed_psk OTHERWLAN wifi_dca12324234f3_888fff887_managed_psk
As you can see, it lists LAN and WiFi based connection services as well.
The second part after the pipe (awk ‘/^\*/ {print $3}’ ) filters the output after the line starting with an asterisk (*), which identifies the currently used connection. Afterwards it returns the last part of the line (here: ethernet_dca12324234f3_cable). - The determined interface name is used by the connmanctl config command as parameter. So the target interface for the subsequent settings ist defined.
- Finally the IP settings are defined by –ipv4 manual 192.168.178.88 255.255.255.0 192.168.178.1 to set a static IP on LibreELEC.
The distinct parts have the following meanings:- –ipv4 manual specifies that the IP should be bound statically
- 192.168.178.88 represents the chosen static IP address itself
- 255.255.255.0 is the network mask used for the target network
- 192.168.178.1 is the gateway to use for that connection
That’s it! After executing the command, the connection is lost immediately and you have to reconnect by using the newly created static IP. Â As you can see, its not that hard to set a static IP on LibreELEC.
If the connection service list is empty, you probably have to run “$> connmanctl enable wifi &&Â connmanctl scan wifi” first.
It works perfectly ! Thank you
Bernard from Toulouse
I get an error: Error ‚config‘: Invalid argument
Hello Steve,
did you already try the command from my first comment?
If this didn’t work either, please give me the whole command causing this error. I don’t have an LibreELEC anymore, but perhaps I can see, what’s wrong.