• Sharing Host VPN with VirtualBox guest

After looking for this solution everywhere, I finally found a working solution that doesn't require a lot of configuration changes and is really simple. Use the default NAT network and type this in the terminal:

VBoxManage modifyvm "VM name" --natdnsproxy1 on

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。


$ VBoxManage list vms
"Linux_VM_Lab" {9844011a-321e-4975-9799-24deebec696c}


$ VBoxManage modifyvm 9844011a-321e-4975-9799-24deebec696c --natdnsproxy1 on

 

  • Building an Internal Network in VirtualBox

TCP port forwarding

The VirtualBox NAT interface is a NAT firewall that connects guest virtual machines to the host computer’s local area network. It supports DHCP configuration of IP addresses.

Because the virtual machines are hidden behind a NAT firewall, the host computer cannot initiate connections to them. To connect from the host computer to the virtual machines using SSH, you must set up TCP port forwarding on each virtual machine.

TCP port forwarding creates a hole in the NAT firewall through which the host computer or other clients from the local area network may initiate connections to the virtual machines.

The default SSH port on each guest virtual machine is TCP port 22. Map unused TCP port numbers on the host computer to port 22 on each guest virtual machine. Any unassigned or unreserved TCP port numbers may be used on the host computer. I prefer to use TCP port numbers between between 14415 and 14935 which provides 520 contiguous unassigned TCP port numbers1.

Configure port forwarding on NAT interfaces

On each virtual machine, click on Settings, then click on the Network tab in the settings window. Select the tab for Adapter 1. Expand the Advanced network panel and click on Port Fowarding.

 

To log into any running virtual machine, use the host computer’s IP address and the host port number assigned to the virtual machine:

$ ssh -l <userid> -p <port number> <IP address>


Refrence:

https://sandilands.info/sgordon/building-internal-network-virtualbox

http://www.brianlinkletter.com/how-to-use-virtualbox-to-emulate-a-network/

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄