0

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.

Current SetUp

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 84.0.0.0/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 84.0.0.0/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
84.0.0.0        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
84.0.0.0/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 84.72.108.96 (84.72.108.96), 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  84.72.0.228 (84.72.0.228)  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?

  • Next time, could you please use the output of ip route instead? The BSD route tool doesn't always show all details on Linux. – grawity Apr 6 '17 at 18:20
  • 1
    Check your routing table on the router that connects to the internet. You need to have static routes set up on that router too otherwise the router won't know where to send a packet to when it sees IP address 192.168.99.x. Thus the packet will be dropped which leads us to no internet connection. – Jerry Hundric Apr 6 '17 at 18:22
  • I have added the ip route to the description now – TerenceJackson Apr 6 '17 at 18:42
2

The routing on the Raspberry Pi is probably OK. You need to make sure that your Internet-facing router has a route for 192.168.99.* that points to 192.168.2.1. Also, you will need to have your Firewall/VPN NAT (PAT) source IPs from 192.168.99.* to an IP on the serial link between the Firewall/VPN and your Router.

If the Router receives packets with the source IP of 192.168.99.* it will always route the reply packets to the same gateway, which in your case is probably 192.168.2.1, not the IP of the Firewall/VPN.

  • Hi. Thanks for your answer. Can you help me a little more here. How can I link my source IPs from 192.168.99.* to an IP on the serial link between the Firewall/VPN and your Router? Do I need to do this via iptables? – TerenceJackson Apr 10 '17 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.