probably misunderstanding routing

I have a LAN. It connects to the internet via commercial NAT thingie. Works well enough.

Connected to this LAN, is a FreebsdFreeBSD machine. Also works well, networking as intended.

hHowever, in this machine, I have a second ethernet card, and connected to that, iI have a wifi base station. iI would like to make this all work together.

sSo far, iI think the base station is working correctly. it is configured without dhcp or nat, it is on a second subnet which also contains the freebsdFreeBSD second ethernet card. tThe freebsdFreeBSD machine can speak in both directions, to both LANs.

tThe problem comes, when iI want the freebsdFreeBSD machine routing traffic from the base station, to the original LAN and eventually internet. iI turned on the gateway sysctl, but that does not seem to be enough.

I am not sure I am understanding routing. I get how to add routes, and added them correctly for each LAN, and am able to access them from freebsdFreeBSD machine. However that seems to be only for traffic originating from freebsdFreeBSD machine itself. hHow do iI set routes for other traffic the freebsdFreeBSD machine sees on one side of its bridging? dDoes the gateway sysctl simply make the freebsdFreeBSD machine put all interfaces into a "pool", or - what am iI missing here?

Thanks!
 
You have a few options.

First is to tell your "commercial NAT thingie" that there is a another network that is reachable via the IP address of your FreeBSD machine in the "original LAN" by adding a route(8) to its routing table. If this "commercial NAT thingie" was another FreeBSD machine you would do this on the command line to add the route:

route add -net 192.168.100.0/24 192.168.1.47

I'm using 192.168.100.0/24 as the subnet of the second LAN and 192.168.1.47 (the gateway) as the address of the FreeBSD machine in the original LAN. Replace with the real values from your configuration.

How this is done on your NAT router depends on make and model, refer to the manual/online help of your device.

What you're missing about routing is that all hosts do their routing autonomously without consulting anyone else using only their own knowledge of the available networks from its routing table. It's often called "pass the puck" routing, if a host doesn't know where to send a packet it passes it to its default gateway in hopes that the default gw knows better. If there's no default gw the packet to the unknown destination is dropped.

There are routing daemons that exchange route information between host such as routed(8) (not used much anymore) and then there's BPG that is standard route exchange protocol nowadays:

https://en.wikipedia.org/wiki/Border_Gateway_Protocol

These are not used actively as part of the routing process because routing needs to be very fast and consulting a network daemon for every unknown route would be horrendously slow.

Second option would be to "hide" the second LAN from the first LAN alltogether. This is called "double NAT". Using pf(4) it would be quite simple. Enable PF by adding this to /etc/pf.conf:

Code:
pf_enable="YES"

Then add a minimal PF ruleset as /etc/pf.conf:

Code:
ext_if = em0

nat on $ext_if inet from !$ext_if to any -> $ext_if

pass all

Replace em0 with the name of the interface from your configuration.

Start PF:

# service pf start

Third option would be bridging that combines the two LANs into one. This would have the advantage of not having to use two different subnets, all host on the new LAN could use the same addresses as the first. See the handbook for instructions:

https://www.freebsd.org/doc/handbook/network-bridging.html
 
Back
Top