This site has no ads. To help with hosting, crypto donations are accepted:
Tue, 29 Oct 2013
Virtualbox and Shorewall: Put Virtual Machines on Their Own Subnet
Tired of your Virtual Machine's (VM's) network connection being b0rked every time your laptop moves to a
different network environment? So am I. The solution: use VirtualBox's Host-Only Adaptor option to put the
VM on it's own, routed, subnet so that kernel routing can shield the VM from the external network.
- File --> Preferences --> Network: create a "Host-Only Network" if one does not already exist.
Note it's default characteristics: named "vboxnet0", on 192.168.56.1, with DHCP turned on.
- Select the VM in question, click on "Network", select "Host-Only Adaptor" and "vboxnet0".
On the VirtualBox host's Shorewall configuration:
- /etc/shorewall/shorewall.conf: IP_FORWARDING=On
- Permit connections from VM to internet:
- /etc/shorewall/zones: "vms ipv4"
- /etc/shorewall/policy: "vms all ACCEPT
- /etc/shorewall/interfaces: "vms vboxnet0"
- Turn on masquerading from VM interface to internet interface(s):
- /etc/shorewall/masq: "wlan0 192.168.56.0/24"
For the guest VM's network configuration, bring up the network with DHCP,
create a default route, specify DNS servers:
iface eth0 inet dhcp
post-up route add default gw 192.168.56.1
posted at: 04:08 | path: /Linux/router-bridge | permanent link to this entry