Port forwarding connection database using VirtualBox

Source: Internet
Author: User

Transfer from http://blog.sina.com.cn/s/blog_484d87770102uxi6.html

Use VirtualBox for a long time, a lot of usage is not deep drilling, really is not open-minded learning ah.
Because the default approach is to use NAT for virtual machine networking, it can be cumbersome to access the virtual machine's applications from outside the network. Used to bridge the way, but the IP is limited, its own designated IP may conflict with the LAN IP, and the IP obtained by DHCP may change lead to uncertainty, how to do? On the Internet, a simple and effective solution is to use the VirtualBox "Port mapping" function.
Here are some examples to talk about how to do:

Application Scenarios:You want to have the virtual machine's Web 80 port accessible from outside.

1. First of all to know the virtual Machine network card "Big" IP, think of network card to see the Internet Sharing Center.


Look at the properties of VirtualBox host-only Network, see the IP assigned to it is 192.168.56.1, remember this address.
Open cmd window ping 192.168.56.1 see can ping through

2. Configure Port forwarding, open the virtual machine, select the virtual machine you want to access, point to "settings"-"Network"


Point "Port Forwarding", add Web80 project, see no host IP filled in is 192.168.56.1, subsystem IP needs to be viewed in the virtual machine's system through commands such as Linux using Ifconfig view.
Need to explain that the host port can be inconsistent with the subsystem port, such as the MySQL for example, if the host port is configured to 6033, then the MySQL database address from the extranet to access the virtual machine is 192.168.56.1, the port is 6033, The virtual opportunity is automatically forwarded to the 3306 port in the subsystem (the default port for MySQL), so that the application port of the protection subsystem is not directly exposed to the outside.

A little off-topic, even when MySQL is created, although the MySQL account is allowed to connect externally, but still not connected, this time into/etc/mysql/my.cnffile for editing. Comment out #bind-address = 127.0.0.1
Then restart MySQL so you can connect from the outside .

In addition, 192.168. This network segment does not work and needs to see if the virtual machine's Nic 2 is set to the "host only (HOST-ONLY) adapter" mode as shown.



Port forwarding connection database using VirtualBox

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.