Hi All
Hi have a pi server running on my lan which also runs a hotspot on the wlan. Lan address is dynamically assigned but has.a reservation on the dhcp server so always has the same address. All this works fine, but I need to access clients in the VPN subnet as I have a Pi-camera at a remote sited want to grab some images to this server for the web page it hosts.
My eth0 is in a private range 10.x.y.0/23 and always has the address 10.x.y.15 the default gateway is obviously 10.x.y.1 and the VPN server sits at 10.x.y.7 and is running TUN mode so issues clients with addresses in the range 10.x.z.0//24. From the client end all is good as the connection sets up routing to access the local lan and the internet via the local gateway. The issue comes with accessing those clients from the home network.
On a PC or I would just say 'route add -p 10.x.z.0/24 10.x.z.7' and on my Mac I use something similar although it is much harder to make it persistent. I cannot get this to work with my Pi server though. The above command (minus the -p) yields and error "route: netmask 000000ff doesn't make sense with host route"
I have tried adding a route command to dhcpcd.conf in a section called interface eth0 but as that interface is assigned dynamically I don't think it is read.
I would be happy to find a simple command line solution as I can script it to run when I want.
Re: Add an addition persistent route on eth0
The Arch documentation shows how to:
- set a static route from dhcpcd
- use the "ip" command to specify your route ("route", "ifconfig", "brctl" etc are deprecated)
- set a static route from dhcpcd
- use the "ip" command to specify your route ("route", "ifconfig", "brctl" etc are deprecated)
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel
Re: Add an addition persistent route on eth0
Would have been so much simpler to read if you actually used numbers.'route add -p 10.x.z.0/24 10.x.z.7'
The error here is that the VPN is 10.x.y.7 and not 10.x.z.7 but most likely a slip of your finger when writing this post.
This is me adding a route to network 192.168.0.0 from my pi on 192.168.10.103
Code: Select all
pi@raspberrypi:~ $ ip route list
default via 192.168.10.1 dev wlan0 src 192.168.10.103 metric 303
192.168.10.0/24 dev wlan0 proto kernel scope link src 192.168.10.103 metric 303
pi@raspberrypi:~ $ sudo ip route add 192.168.0.0/24 via 192.168.10.98 dev wlan0
pi@raspberrypi:~ $ ip route list
default via 192.168.10.1 dev wlan0 src 192.168.10.103 metric 303
192.168.0.0/24 via 192.168.10.98 dev wlan0
192.168.10.0/24 dev wlan0 proto kernel scope link src 192.168.10.103 metric 303
Re: Add an addition persistent route on eth0
Its actually uncanny how often googling for something asked for in the Pi forums leads you to the Arch Linux Wiki.The Arch documentation shows how to:
Re: Add an addition persistent route on eth0
Unfortunately it also leads to a ton of ill-informed or obsolete howtos... But with Arch you rarely can go wrong.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel
Re: Add an addition persistent route on eth0
It is good practice to add a protocol as well to arbitrary routes you introduce by hand or with a script. Just in case a routing daemon kicks in later and purges them leaving you puzzled why they are gone.topguy wrote: ↑Tue Jul 03, 2018 6:45 pmCode: Select all
pi@raspberrypi:~ $ sudo ip route add 192.168.0.0/24 via 192.168.10.98 dev wlan0 pi@raspberrypi:~ $ ip route list default via 192.168.10.1 dev wlan0 src 192.168.10.103 metric 303 192.168.0.0/24 via 192.168.10.98 dev wlan0 192.168.10.0/24 dev wlan0 proto kernel scope link src 192.168.10.103 metric 303
Code: Select all
pi@raspberrypi:~ $ sudo ip route add 192.168.0.0/24 via 192.168.10.98 dev wlan0 proto static
protocol RTPROTO
the routing protocol identifier of this route. RTPROTO may be a number or a string from the file
/etc/iproute2/rt_protos. If the routing protocol ID is not given, ip assumes protocol boot (i.e. it
assumes the route was added by someone who doesn't understand what they are doing). Several protocol val‐
ues have a fixed interpretation. Namely:
redirect - the route was installed due to an ICMP redirect.
kernel - the route was installed by the kernel during autoconfiguration.
boot - the route was installed during the bootup sequence. If a routing daemon starts, it will
purge all of them.
static - the route was installed by the administrator to override dynamic routing. Routing daemon
will respect them and, probably, even advertise them to its peers.
ra - the route was installed by Router Discovery protocol.
The rest of the values are not reserved and the administrator is free to assign (or not to assign) proto‐
col tags.
Re: Add an addition persistent route on eth0
Thanks for all the replies. Seems all I was missing was the IP command rather than going straight for route.seems to be working fine.