Setup NAT Network

Prerequisites

BVCP Installed and running on the machine
Due we respects FreeBSD and it's network stack, NAT is considered advanced networking, that we simply do not want to implement into BVCP.


1) Edit: /etc/pf.conf (create if nonexists)

PF is one of the firewalls available on FreeBSD out-of-the-box.

# igb0 is the main interface in this example and we want enable NAT for 10.10.10.1/24 (10.10.10.1-255) network.

nat on igb0 from {10.10.10.1/24} to any -> (igb0)

# Enable port forward, forward 80 and 443 TCP port behind the NAT: 10.10.10.2
rdr on igb0 proto tcp from any to igb0 port 80 -> 10.10.10.2 port 80
rdr on igb0 proto tcp from any to igb0 port 443 -> 10.10.10.2 port 443  


2) Save and Restart the firewall

To test your config (once): `service pf onerestart`
To enable on boot: `sysrc pf_enable="YES"`
A good way to reload any change: `service pf reload`


3) Edit: /etc/sysctl.conf


# Add the following lines to enable `routing`
net.inet6.ip6.forwarding=1
net.inet.ip.forwarding=1    
To make effect to this change run: `sysctl -f /etc/sysctl.conf`


4) Edit: /etc/rc.conf

# Add the following lines to make a dummy network interface
cloned_interfaces="epair0"
ifconfig_epair0a="inet 10.10.10.1 netmask 0xffffff00 up"
To make effect to this change run: `service netif restart && service routing restart`

5) Create a network switch in the BVCP, and set epair0b as dedicated interface

And you're done, assign the new network to the VMs, the NAT should work.