VirtualBox Network

VirtualBox Network

Last one year, I am not setting my VirtualBox in the right way. So I need to switch the IP address between my working environment and home wifi environment.

Actually it is not necessary. I knew this long time ago. VirtualBox support the VM using 2 network Adapters. So the best way to set up the VM is that, one adapter with NAT Network and one with Host-only Adapter. Then we can access the outside network via NAT, and our host machine can access the VM from the Host-only Adapter.

Open the VirtualBox —> References ——> Network —> Add NAT Networks ——> Host-only Networks Tab, add One vboxnet0 —> Edit that —> Setting the DHCP Server with these information
Server Address: 192.168.56.100
Server Mask: 255.255.255.0
Lower Address Bound: 192.168.56.101
Upper Address Bound: 192.168.56.254

Then start the Virtual Machine.
> sudo vi /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet dhcp

It works pretty well.

References:
https://technology.amis.nl/2014/01/27/a-short-guide-to-networking-in-virtual-box-with-oracle-linux-inside/

猜你喜欢

转载自sillycat.iteye.com/blog/2218494