Virtualbox SSH connection using NAT

Source: Internet
Author: User


Solve the problem through a close test on RHEL 5.6.

The virtualbox in this article is based on the Windows platform environment. Ubuntu is installed in the virtual machine, that is, Ubuntu is connected to the virtual machine through SSH on the Windows platform.

Virtualbox has always been used for virtual Ubuntu, and your computer is used at home, and a wireless router is configured at home, therefore, I always set the network mode of virtualbox to the Bridge Mode (bridged adapter), so that you can easily use the SSH mode of securecrt to connect to the virtual Ubuntu in virtualbox.

Because the network connection in the bridge mode is equivalent to the parallel existence of the virtualized system and the real host, that is, if the IP address assigned by the real host from the router is "192.168.1.100 ", then, the virtualized system can configure the IP address as "192.168.1.101" in the bridging mode to simply ping the virtual host on the real host or use SSH to connect, the connected IP address is "192.168.1.101 ".

Recently, after a holiday and preparing to go home for the New Year, I suddenly thought there was no router in the environment, so it was impossible to work in the above bridging mode.

After virtualbox is installed, the default connection method is "Nat". You can use this method to directly access the network in the virtual system. Of course, it is based on the fact that the real host can access the network. However, this "Nat" mode is isolated from the vro mode. The virtual system depends on the real system, but not the parallel mode. In this way, you can access the virtual system through the real host system without a network.

However, such a "Nat" method cannot be directly connected by simply configuring the IP address, and simple settings are required.

Step 1: Install the SSH service

This is a required step. For more information, see the previous article.

Step 2: port forwarding

This step is the key to the full text. Shut down the virtual machine, enter the command prompt mode on the Windows platform, and locate your virtualbox installation directory, for example, "C: \ Program Files \ oracle \ virtualbox". Then enter:

1 vboxmanage
modifyvm
" VM
name "

-- natpf1
"Guestssh, TCP, 2222, 22"

"VM name" is the name of your virtual Ubuntu, that is, the name displayed on the system list in virtualbox manager. The "2222" Port of the local host points to the "22" Port of the Linux System in the virtual machine.

"-Natpf1" does not need to be modified. Generally, a virtual machine has only one network connection by default, that is, the first connection. Unless you have set multiple network connections, you can modify them as needed.

By default.

Step 3: connect to Ubuntu through SSH

Start Ubuntu in your Vm, start it, open securecrt, and create a new connection. The connection IP address is 127.0.0.1, and the connection port is 2222 ". This is very important, otherwise you will not be able to connect.

The rest is the access account and password, which is not explained in detail. Click OK to connect to Linux in your VM.

Keywords: Nat, ssh, virtualbox, connection

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.