Ubuntu16.04 virtual machine network card configuration bridge mode Internet access under virtualbox

First of all, I have been trapped by this for a long time, and I wasted a lot of time on the network card configuration. So record it here:
I chose virtualbox because its installation package is small, free, and quick to start, vmvare workstation is charged, of course it can be cracked, vmvare player is free, but not as good as virtualbox. However, vmvare is still very cost-effective. After all, vmvare (Chinese name: Wei Rui) is the most powerful company in virtual machines, virtual servers, virtual PCs, cloud platforms, and infrastructure. The above is bullshit.
Enter the topic : The
host machine is win10 professional version. When I installed the virtual machine, I installed the ubuntu16.04 desktop version. The network card selected is bridged, so that the host machine and the virtual machine can ping each other.
You can also choose NAT mode, so that the virtual machine can only ping the host machine, but not vice versa

The IP to be configured is in the same network segment as your host's IP, and the gateway requirements are the same.
What IP is in the same network segment, this is the IP divided according to the subnet mask.

  1. Note: Here is the configuration of the network card, only one network card is configured, select wired connection, the interface name is the name of the real network card of the host machine.
    write picture description here

  2. Enter the virtual machine and use the ifconfig command in the terminal to view the ip of the network card
    write picture description here

  3. You can see a network card enp or something, the original enp0 and so on. If there are more than one, you can click the network connector in the upper right corner, edit the connection information, delete all the connections in it, and then use ifconfig to view the network card.
    write picture description here
  4. Then switch root user login
    write picture description here

  5. Then edit the interfaces file, which is located under /etc/network/, and execute the following command:
    vim /etc/network/interfaces (compare the network card information under win10)
    write picture description here

  6. After adding, save and exit (command: wq), the next step is to configure DNS resolution, DNS resolution file and then /etc/resolv.conf. Execute: vim /etc/resolv.conf, as shown below:
    write picture description here

  7. After changing the above, if you restart, it will still be the same as before, so you need to make it permanent. Therefore, execute: vim /etc/resolvconf/resolv.conf.d/base, as shown below:
    write picture description here

  8. Then save and exit (:wq) and restart the server (reboot). The static IP configuration is basically completed here.

  9. After startup, use ifconfig to check whether the configuration is successful:
    write picture description here

  10. Test, open the browser, whether you can access the Internet, it may not work, mutual ping test (may be a firewall problem) close ubuntu16.04 (sudo ufw disable) and the firewall on win10
    write picture description here

  11. This will ping each other
    write picture description here

Write down your own insights: When encountering a problem, you must repeatedly find the reason. You can’t be busy with Baidu and Baidu. Another point is to understand what you have done at each step. Be a scumbag who loves to learn.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324658579&siteId=291194637