CodyKochmann
10/19/2015 - 1:54 PM

A setup script for virtualbox internal networking via VBoxManage

A setup script for virtualbox internal networking via VBoxManage

# shell script for setting up internal NAT networking for VirtualBox
# by: Cody Kochmann

# creates a subnet of 16 addresses
VBoxManage natnetwork add --netname natnet1 --network "192.168.15.0/16" --enable --dhcp on;
# starts the service
VBoxManage natnetwork start --netname natnet1;

#------------------------------------
# this will create the table below
#------------------------------------
# ssh:tcp:[]:2202:[192.168.15.2]:22
# ssh:tcp:[]:2203:[192.168.15.3]:22
# ssh:tcp:[]:2204:[192.168.15.4]:22
# ssh:tcp:[]:2205:[192.168.15.5]:22
# ssh:tcp:[]:2206:[192.168.15.6]:22
# ssh:tcp:[]:2207:[192.168.15.7]:22
# ssh:tcp:[]:2208:[192.168.15.8]:22
#------------------------------------
for i in {2..8}
do
  VBoxManage natnetwork modify --netname natnet1 --port-forward-4 "ssh:tcp:[]:220${i}:[192.168.15.$i]:22"
done