Add Static Route to Hassio on RPI3B+

Probably another stupid question/problem from me.

I believe, after talking to pfSense people, I need to set a static route from my Hassio install at 172.27.3.4 to my 172.27.2.x network:

ip route add 172.27.2.0/24 via 172.27.3.1 dev eth0

This should allow me to access Hassio from 172.27.2.x by bypassing the default gateway at 172.27.3.3, which does not route to 172.27.2.x normally.

But when I enter the above command through SSH on my RPI3B+ running Hassio 0.91.3, I get:

core-ssh:/etc/network# ip route
default via 172.30.32.1 dev eth0
172.30.32.0/23 dev eth0 scope link  src 172.30.33.2
core-ssh:/etc/network# ip route add 172.27.2.0/24 via 172.27.3.1 dev eth0
ip: RTNETLINK answers: Operation not permitted
core-ssh:/etc/network#

And even stranger, my Hassio device is still at 172.27.3.4 as assigned by the DHCP server in pfSense, but ifconfig show a completely different ip address on eth0 (yes, it connected via Ethernet):

eth0      Link encap:Ethernet  HWaddr 02:42:AC:1E:21:02
          inet addr:172.30.33.2  Bcast:172.30.33.255  Mask:255.255.254.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:26997 errors:0 dropped:0 overruns:0 frame:0
          TX packets:333 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2406071 (2.2 MiB)  TX bytes:44652 (43.6 KiB)

What am I missing here? And why is eth0 assigned this strange IP address that’s not even part of my network?

Thanks!

sudo maybe?

You’re SSH’d into a container, not the host.

It’s the internal Docker network. You’re on the wrong path here.

It’s running as root, but in a container. Sudo has no power here.

none of the docker commands work.

core-ssh:~# docker network ls
-bash: docker: command not found

Correct. Because you are INSIDE a docker container…

The ssh add-on is a container. You don’t have full control of the host through it.

So how do I get out of it?

https://developers.home-assistant.io/docs/en/hassio_debugging.html

I don’t think you are going to accomplish what you need with this though. Your router should handle the routing.

I have static routes to handle local addresses and I can ping and traceroute across networks, back and forth, without any problem. I can access devices on the 2.x network from the 3.x network (where Home Assistant is located), but I can’t go the other way: access devices on the 3.x network from the 2.x
So this is sort of a Hail Mary
Thanks for your help!

-A POSTROUTING -o eth0 -j MASQUERADE

Well, it looks like this was the problem. I don’t know why it was in there. I don’t know what taking it out might break, but now I can get to 3.x devices from the 2.x network!

Didn’t need access to the HassOS afterall. It was this setting in RPI Gateway

Hi, i have same problem, hassio on 192.168.0.3 and network on 192.168.1.1. how can add a static route?

Dear, I’m facing the same issue, could you please explain me better how you fixed it? I dind’t got very well the “-A POSTROUTING -o eth0 -j MASQUERADE” sentence. Where is supposed to be located this sentence? thank you very much

Hi
I have same problem
How you fix it ?

Same here, still looking for a solution.
If I found something I’ll copy / paste here.

Find a way to deal with, open a local connection to shell and use nmcli (one shot)

nmcli connection modify "Supervisor enp0s18" +ipv4.routes "192.168.20.0/24 192.168.10.250"

Or try in interactive mode :

nmcli con edit "Supervsisor enp0s18"
nmcli> set ipv4.routes 192.168.20.0/24 192.168.10.250
nmcli> save persistent
nmcli> quit

I tried this and then reboot (not sure if needed) and magic, it worked.

2 Likes

FYI - looks like the Supervisor connection is now “Supervisor eth0”

I Also want to add a static route to Home assistant OS 10.4. as I have multiple routers on my network.
So I opened “Terminal” in HA and tried NMCLI. But then it says “Command not found”

Please help.