Ubuntu 12.04 server network problems in VirtualBox

Source: Internet
Author: User

Ubuntu 12.04 server network problems in VirtualBox
Some time ago, in order to build an open source blog on ubuntu in a virtual machine, virtualbox's default NAT access method does not support access from the host to the virtual machine. Therefore, I changed the default access method to host-only adapter host mode. By default, the access to 192.168.56.101 can be accessed from the host to the virtual machine. I don't know how to drum up later, but the problem arises. The following lists the problems: 1. input the ifconfig command, and the eth0 Nic disappears ?? I am still "not sure" about this problem, but it disappears. However, if you try the ifconfig-a command, you will find that eth1 or eth2 or eth3... unfortunately, when I input ifconfig-a, it has reached eth5, and I do not know why my Nic number has changed from eth0 to eth5? Also, how can we change eth0 ?? If the ifconfig command does not contain eth Nic information, your network configuration must be faulty, either by setting a static IP address or dynamically and Automatically Obtaining the IP address and setting the configuration file, next, let's look at it. 2. static IP settings ?? Run the following command to open the network settings file:
1 sudo vim/etc/network/interfaces you can see the following content: if you are not confused, the eth5 in the following two lines should be eth0. If you want to set a static IP address, you need to modify this file. Of course, you must remember to back up the original file. Exit the editor and run the following Backup command: 1
Cp/etc/network/interfaces. bak then edits the file and changes the file content to the following content. 01 auto lo02iface lo inet loopback03 04 auto eth005 # iface eth0 inet dhcp dynamically allocates ip addresses, comment out 06 # static IP address 07 iface eth0 inet static08 # IP address 09 address 192.168.1.18810 # subnet mask 11 netmask 255.255.255.012 # gateway 13 gateway 192.168.1.2 and start the service. The command is as follows: 1. If the sudo service networking restart command is OK, no error is returned. If it cannot be started, try restarting: 1 sudo shutdown-r now
Now input ifconfig to display the eth Nic information, and you can clearly see the IP address of the VM. 3. What is the configuration of the Bridged Adapter of virtualbox ?? First, you need to know the basic concept of the Bridge Mode. In the bridge mode, your virtual machine is equivalent to an independent computer in the LAN. As long as you are in the same network segment as the host, you can access each other. For details, see the four network access modes of VirtualBox. According to the introduction of bridging, a virtual machine is a host independent of a host and must have its own IP address, in addition, the same host can be in the same LAN for mutual access. Because I am a campus network, I cannot automatically allocate an IP address, that is, to access the Internet by setting a fixed IP address, first check the IP address on my host, for example; then, according to the IP address on the host, find an available IP address and set a fixed IP address for the VM. For example, the static IP configuration file in the Virtual Machine: After the configuration is complete, the test starts now. Can the ping between the host and the virtual machine be successful? Can virtual machines access the Internet? Step 1: test whether the virtual machine can access the internet. ping www.baidu.com from the host, for example, to view Baidu's IP address, and then ping Baidu's IP address from the virtual machine, for example; we can see that the virtual machine can ping Baidu's IP address, proving that the connection is connected to the Internet. Step 2: test whether the host can be pinged to the virtual machine. According to the above introduction, the Host IP address is 10.1.14.59 and the virtual machine IP address is 10.1.14.50. The test is as follows. You can see that the host can be pinged to the virtual machine. Step 3: test whether the VM can successfully ping the host. In this step, disable the firewall for Windows 7 or Windows 8. Otherwise, ping may fail. After setting it up, I immediately tested it. Can I access an open-source blog? Nice. You can access it. You don't need to set host-only network mode. 4. You may have discovered why you need to ping Baidu's IP address, not directly ping www.baidu.com like the host, because we have not set DNS yet, if you ping www.baidu.com, an error is returned. Next, set the DNS manually. First, find the configuration file where the dns configuration file is/etc/resolv. conf, open edit; 1 sudo vim/etc/resolv. conf append a line at the end of the file: 1 nameserver 202.113.112.55 pay attention to fill in your own Domain Name Server, the domain name server can view the host, as shown below; after filling out, restart the networking service to make it take effect, command: 1 sudo/etc/init. d/networking restart here, the DNS service is also set up, and then ping www.baidu.com on the VM, as shown in; Conclusion: In this mode, the host can easily access services under the virtual machine, but in the default NAT network mode, the host cannot access the virtual machine service.

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.