I have a little complex network setup and I am trying to use a raspberry as a router between three networks with static routes. Please find below a picture of the current set up.
Basically this means that I have a Raspberry Pi with 3 network interfaces:
- Eth0: IP 192.168.1.100 connected to a Firewall/VPN hardware. All connections to 184.108.40.206/8 should go via this interface
- Eth2: IP 192.168.2.1 connected to a router which connects to the internet
- Eth1: 192.168.99.100 connected to the local network
All these IP addresses are static. I also already set the static route on the Raspberry for the 84 rule:
route add -net 220.127.116.11/8 gw 192.168.1.100
I also deleted the default gateway for eth0
route del default gw 192.168.1.100 eth0
My routing table now looks like this:
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.2.1 0.0.0.0 UG 204 0 0 eth2 18.104.22.168 192.168.1.100 255.0.0.0 UG 0 0 0 eth0 192.168.1.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0 192.168.2.0 0.0.0.0 255.255.255.0 U 204 0 0 eth2 192.168.99.0 0.0.0.0 255.255.255.0 U 203 0 0 eth1
IP Route output
default via 192.168.2.1 dev eth2 metric 204 22.214.171.124/8 via 192.168.1.100 dev eth0 192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.10 metric 202 192.168.2.0/24 dev eth2 proto kernel scope link src 192.168.2.28 metric 204 192.168.99.0/24 dev eth1 proto kernel scope link src 192.168.99.100 metric 203
If I do a traceroute on an IP with 84 on the Raspberry it looks correct, the traffic is routed via eth0, all other traffic is routed via eth2.
traceroute to 126.96.36.199 (188.8.131.52), 30 hops max, 60 byte packets 1 192.168.1.100 (192.168.1.100) 9.253 ms 9.047 ms 8.786 ms 2 184.108.40.206 (220.127.116.11) 34.397 ms 34.840 ms 34.753 ms
I have also set
net.ipv4.ip_forward = 1
The problem is that, if I connect via a PC (e.g. PC1) to the network I am not able to get internet access. The gateway for the PCs is set to 192.168.99.100.
I assume I now have to create static routes for eth1 also on the Raspberry but I am kind of stuck.
Can somebody help me how to finish this set up so that it works?