Created
May 27, 2014 16:37
-
-
Save lalyos/03489a2134d70062d6d2 to your computer and use it in GitHub Desktop.
configure boot2docker networking to use hostonly network on adapter4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################################ | |
# curl -Ls j.mp/b2d-networking | bash | |
############################################ | |
: ${SUBNET:=192.168.201} | |
: ${VMNAME:=boot2docker-vm} | |
: ${ADAPTERIDX=4} | |
: ${B2DBRIDGE:="172.17.0.0/16"} | |
clear() { | |
unset SUBNET VMNAME ADAPTERIDX B2DBRIDGE | |
} | |
settings() { | |
for var in SUBNET VMNAME ADAPTERIDX B2DBRIDGE; do | |
echo ${var}=${!var} | |
done | |
} | |
reset() { | |
VBoxManage hostonlyif remove $VBOXNET | |
VBoxManage modifyvm $VMNAME --nic$ADAPTERIDX none | |
} | |
b2d-hostonly() { | |
VBOXNET=$(VBoxManage hostonlyif create|sed "s/^Interface..//; s/..was.*//") | |
echo [DEBUG] $VBOXNET created | |
VBoxManage hostonlyif ipconfig $VBOXNET --ip $SUBNET.1 | |
VBoxManage dhcpserver modify --netname HostInterfaceNetworking-$VBOXNET --enable | |
VBoxManage dhcpserver modify --netname HostInterfaceNetworking-$VBOXNET --ip $SUBNET.100 --netmask 255.255.255.0 --lowerip $SUBNET.101 --upperip $SUBNET.200 | |
echo [DEBUG] $VBOXNET configured to use DHCP starting from $SUBNET.101 | |
VBoxManage modifyvm $VMNAME --nic$ADAPTERIDX hostonly --cableconnected$ADAPTERIDX on --hostonlyadapter$ADAPTERIDX $VBOXNET | |
echo "[DEBUG] $VMNAME network Adapter$ADAPTERIDX connected to $VBOXNET" | |
echo [DEBUG] create static route from host to $VMNAME ... | |
sudo route add -net $B2DBRIDGE $SUBNET.101 | |
} | |
settings | |
b2d-hostonly |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment