Skip to content

[RFE] connman fails to add static routes with dhcp + workaround #5588

@hvegh

Description

@hvegh

Context

Due to the fact that my ISP provided modem is unable to configure an additional static route I had to resort to distribute static route to clients using dhcp.

On the DHCP server i added:
dhcp-option= option:classless-static-route,0.0.0.0/0,192.168.1.253,192.168.100.0/24,192.168.1.1

to tell the LibreElec client that 192.168.1.1 is able to figure out where to route 192.168.100.0/24.

Resulting route:

LibreELEC:~ # route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.253   0.0.0.0         UG    0      0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.1.253   0.0.0.0         255.255.255.255 UH    0      0        0 eth0

So route the route is not added as should be expected...
Then I look at the connman status:

LibreELEC:~ # systemctl status connman.service
● connman.service - Connection service
   Loaded: loaded (/usr/lib/systemd/system/connman.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-04-11 18:28:40 CEST; 2 years 4 months ago
 Main PID: 454 (connmand)
   Memory: 2.2M
   CGroup: /system.slice/connman.service
           └─454 /usr/sbin/connmand -nr --config=/etc/connman/main.conf

Apr 11 18:28:41 LibreELEC connmand[454]: eth0 {del} route fe80:: gw :: scope 0 <UNIVERSE>
Apr 11 18:28:41 LibreELEC connmand[454]: eth0 {del} route ff00:: gw :: scope 0 <UNIVERSE>
Apr 11 18:28:41 LibreELEC connmand[454]: Setting domainname to god.lan
Apr 11 18:28:41 LibreELEC connmand[454]: eth0 {add} address 192.168.1.85/24 label eth0 family 2
Apr 11 18:28:41 LibreELEC connmand[454]: ntp: adjust (jump): +75256701.268360 sec
Aug 29 19:07:02 LibreELEC connmand[454]: eth0 {add} route 192.168.1.0 gw 0.0.0.0 scope 253 <LINK>
Aug 29 19:07:02 LibreELEC connmand[454]: eth0 {add} route 192.168.1.253 gw 0.0.0.0 scope 253 <LINK>
Aug 29 19:07:02 LibreELEC connmand[454]: eth0 {add} route 0.0.0.0 gw 192.168.1.253 scope 0 <UNIVERSE>
Aug 29 19:07:02 LibreELEC connmand[454]: eth0 {add} route 82.165.8.211 gw 192.168.1.253 scope 0 <UNIVERSE>
Aug 29 19:07:04 LibreELEC connmand[454]: eth0 {del} route 82.165.8.211 gw 192.168.1.253 scope 0 <UNIVERSE>

So DHCP client of connman is unable to deal with dhcp option 121, unfortunately.

ISSUE

Would be nice to add dhcp option 121 to connman or maybe switch over to native systemd dhcp client?

Also it would be nice to add EnableOnlineCheck=false to /etc/connman/main.conf in order to ged rid of the phone home of connman...

Workaround

Create a service that starts after network is online in order to add the route.

# File: /storage/.config/system.d/fixup.service

[Unit]
Description=Local fixups
Before=kodi.service
Requires=network-online.service
After=network-online.service
ConditionPathExists=/storage/.config/fixup.sh

[Service]
Type=oneshot
Environment=HOME=/storage
ExecStart=-/bin/sh -c ". /etc/profile; exec /bin/sh /storage/.config/fixup.sh"
RemainAfterExit=No

[Install]
WantedBy=kodi.service

and

# File: /storage/.config/fixup.sh             
                                              
route add -net 192.168.100.0/24 gw 192.168.1.1

and finally:
systemctl enable /storage/.config/system.d/fixup.service

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions