I can ssh to my 192.168.10.100 machine, which is a router for 172.30.x.x/12 subnet. I added route in freebsd. I would like to confirm that the bsd box indeed routes 172.30.x.x via 192.168.10.100 and then setup appropriate routing rules on pi (192.168.10.100 / 172.30.0.2).
Sure, let's confirm the route on your FreeBSD box and then set up the appropriate routing rules on your Raspberry Pi (acting as the router).
Confirm Route on FreeBSD
Check the routing table:
Use the following command to see the current routing table:
sh netstat -rnf inetLook for an entry like:
172.30.0.0/12 192.168.10.100 UGS 0 24 vtnet0
Set Up Routing Rules on Raspberry Pi (Router)
Since your Raspberry Pi is acting as a router for the 172.30.x.x/12 subnet, you need to ensure it has the correct routing to forward traffic from the FreeBSD box (192.168.10.xx) to the 172.30.x.x/12 subnet.
Ensure IP forwarding is enabled:
Check if IP forwarding is enabled:
sh sysctl net.ipv4.ip_forwardIf it returns
0, enable it by running:sh sudo sysctl -w net.ipv4.ip_forward=1To make the change persistent, edit
/etc/sysctl.confand add or uncomment:sh net.ipv4.ip_forward=1
Set up NAT for outgoing traffic:
- If the FreeBSD box needs to access the internet through your Raspberry Pi, set up NAT masquerading:
sh sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE - Replace
eth0with the appropriate interface for your Raspberry Pi's internet connection.
- If the FreeBSD box needs to access the internet through your Raspberry Pi, set up NAT masquerading:
Add a static route for traffic from FreeBSD to
172.30.x.x/12:- Add the route on the Raspberry Pi:
sh sudo route add -net 172.30.0.0 netmask 255.240.0.0 gw 192.168.10.100
- Add the route on the Raspberry Pi:
Verify the routing table on Raspberry Pi:
- Use the following command to check the routing table:
sh netstat -rn - Look for an entry like:
172.30.0.0 * 255.240.0.0 UG 0 0 eth0
- Use the following command to check the routing table:
Make routes persistent (optional):
- To make the route persistent across reboots, add it to
/etc/network/interfacesor/etc/rc.local:- Edit
/etc/network/interfaces:sh post-up route add -net 172.30.0.0 netmask 255.240.0.0 gw 192.168.10.100 - Or, edit
/etc/rc.local(if it exists):sh route add -net 172.30.0.0 netmask 255.240.0.0 gw 192.168.10.100
- Edit
- To make the route persistent across reboots, add it to
Check firewall rules (if applicable):
- Ensure that the Raspberry Pi's firewall rules allow traffic to flow between the
192.168.10.xand172.30.x.xsubnets.
- Ensure that the Raspberry Pi's firewall rules allow traffic to flow between the
By following these steps, you should be able to verify and set up the routing correctly on both your FreeBSD box and the Raspberry Pi.