FreeBSD virtual router

I am trying to learn about networking and create a FreeBSD virtual machine to act as a router for other virtual machines. I cannot it to work propertly and have the client machine(s) get online.

The FreeBSD machine is configured with two NIC's in VirtualBox.
em0 192.168.0.20 - is a 'Bridged adaptor and functions as the internet as a member of the 192.168.0.0/24 network
em1 10.0.0.1 - is the second 'Internal Adapter' and will be the router for the other machines on the internal network.

I have set gateway_enable="YES" in rc.conf and rebooted. sysctl -a | grep forward shows that IP forwarding is enabled.

The client machine is configured with one NIC
eth0 - 10.0.0.10/24 with default router 10.0.0.1
Nameservers I have tested - 8.8.8.8 (Google), 192.168.0.4 (another machine running bind), 10.0.0.1 (BSD router), 68.x.x.x (ISP nameservers) and I still can't ping web hosts.

The client machine can ping localhost, 10.0.0.10 (itself), 10.0.0.1 (BSD virtual rouer), and even 192.168.0.1 (the real router) but it is not actually online and can't ping hosts on the internet.

What am I missing and why can't my machines get online? Do I have to setup NAT? I am having such a confusing time understand how to set this up.
 
The "real" router will need to have a static route added. It has to know where the 10.0.0.0/24 network is. Your packets may be going out but the router doesn't know where to route the responses to.
 
My 'real' router is a consumer router which does not let me set static routes. I was finally able to get the networking enabled by setting up NAT. My setup looks like the following and I'm wondering if doing NAT is the only solution in this case

Clients --------------------> Virtual FreeBSD router with NAT enabled -> Consumer modem/router with NAT (no ability to set static routes) -> Internet

If my network looked like the example below would I not have to do NAT on the Virtual FreeBSD router but just enable forwarding? :)

Clients on various networks -> Virtual FreeBSD router with IP forwarding enabled (No NAT), Router that I have configured with static routes of the client networks -> Internet.

I am going to test my learning further by creating a second virtual FreeBSD router with just forwarding and set the first FreeBSD router with the routes of the clients connected to the second router.
 
If my network looked like the example below would I not have to do NAT on the Virtual FreeBSD router but just enable forwarding? :)

Clients on various networks -> Virtual FreeBSD router with IP forwarding enabled (No NAT), Router that I have configured with static routes of the client networks -> Internet.
Correct :)

I am going to test my learning further by creating a second virtual FreeBSD router with just forwarding and set the first FreeBSD router with the routes of the clients connected to the second router.
Routing is always a bit tricky. Besides figuring out the route a packet has to travel going towards its destination, you will also need to take into account the route a packet will travel from it. Or else the response will never reach the requester ;)
 
Back
Top