Preface: our normal virtual machine installed linux system, using the default NAT connection, generally as long as the host can access the virtual machine can be. But many times we need remote access to the virtual machine, but can not be accessed through NAT, then use bridging mode, but after switching to bridging mode, the virtual machine can not access it ... this article to solve this problem, pro-test available. Proceed as follows:
1, open VirtualBox, setting interface into the Ubuntu system specific settings as shown below:
2, into the system after setting, open Ubuntu terminal:CTRL+ALT+T
3, enter the command: ifconfig
Check the network configuration
4, switch to the root user, execute the command: su root
if no root privileges, you need to add, execute the command: sudo passwd root
and enter the password root privileges (of course, can not switch to the root user, then only sudo when required are the following commands, as vi /etc/network/interfaces
)
5, edit / etc / network / interfaces file, execute the command: vi /etc/network/interfaces
set as follows:
After the addition, save and exit, then restart.
note:
- Configuring network interface (in this case enp0s3) and third steps need to query the same ifconfig
- netmask and gateway needs consistent and host
- We can modify the DNS by modifying the /etc/resolv.conf file, but the restart will fail. So we used
dns-nameservers
to configure DNS, permanent - DNS address is also consistent with the needs and host
6. After the restart, check whether success by ifconfig
7, Baidu to see if the ping can ping, execute the command ping www.baidu.com
, if you can ping the note will be online. Then the host and virtual machines to test ping each other, there may be unreasonable if a firewall problem, turn off the firewall to the host and virtual machines.
Well, you're done, then you can remotely access virtual machines through ssh, here steps in the virtual machine to open ssh service simply say:
-
To see whether to open an ssh service is installed, use the command:
sudo ps -e | grep ssh
If the installation is displayed sshd service, did not open any of the information is not displayed -
First update the resource list, use the command:
sudo apt-get update
-
Open SSH service on Ubuntu
sudo apt-get install openssh-server
-
Check whether the installation is successful
sudo ps -e | grep ssh
the following message is displayed after a successful installation: