Warning: Cannot modify header information - headers already sent by (output started at /data/web/virtuals/85063/virtual/www/domains/waldauf.org/lib/plugins/color/syntax.php:1) in /data/web/virtuals/85063/virtual/www/domains/waldauf.org/inc/actions.php on line 180
technology:virtualization:vbox - WiKi

VIRTUALBOX

Networking

Enable internout through Host-Only adapter

In VBox create new vboxnetX interface (X=number) in File –> Preferences –> Network –> Host-only Networks:

  1. Click on “plus” icon and create new interface
  2. Set DHCP server if you wish. If not you must set static IP in guest
  3. “OK” button

IP Forwarding

Temporary setting

This setting is reset after reboot.

# sysctl net.ipv4.ip_forward=1

OR

# echo 1 > /proc/sys/net/ipv4/ip_forward
Persistent setting
cat > /etc/sysctl.d/30-ipforward.conf << EOF
net.ipv4.ip_forward=1
net.ipv6.conf.default.forwarding=1
net.ipv6.conf.all.forwarding=1
EOF

Afterwards it is advisable to double-check forwarding is enabled as required after a reboot.

IPtables

Set vbox interface (in this case vboxnet0) and IP range according your vbox interface.

Temporary

On the host machine, please add the following iptables rules. This will forward packets through the host and on to the Internet:

iptables -A FORWARD -o eth0 -i vboxnet0 -s 192.168.56.0/24 -m conntrack --ctstate NEW -j ACCEPT 
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A POSTROUTING -t nat -j MASQUERADE
Persistent

Run iptables commands from temporary part and then save iptables rules (choose configuration file according your systemd service - /usr/lib/systemd/system/iptables.service):

iptables-save > /etc/iptables/iptables.rules
Navigation
Print/export
Toolbox