Ping problem of ubuntu, windows, development board

Windows 与 Ubuntu

1. NAT method: easy to access the Internet

       (1) For the external network, Ubuntu is equivalent to being in the stomach of Windows and relies on Windows to access the Internet. It is parasitic on Windows and communicates with the external network. As long as Windows can access the Internet (whether it is dial-up or wireless), and the virtual machine can connect to Windows through NAT, Ubuntu can access the Internet.

        Steps: Step 1: In the menu bar Virtual Machine -> Settings -> Hardware -> Network Adapter, select NAT mode on the right.
           Step 2: vi /etc/network/interfaces , open the file and edit the content to:
                              auto eth0 or ens33

                              iface eth0 inet dhcp


2. Bridging method: Internet access is limited

dynamic allocation

        (1) For example, in some campus networks, the external network gives each computer a fixed IP address. At this time, Ubuntu cannot be independent. Some campus networks have DHCP services. After bridging to Windows, the virtual machine will be given an independent IP address through dynamic allocation. The dynamic IP, we can communicate with the external network through this IP. The downside is that this IP will change the next time the NIC is rebooted. It is very troublesome for some projects that require fixed IP.

        Step 1: Bridging. In the menu bar Virtual Machine -> Settings -> Hardware -> Network Adapters, select Bridge Mode on the right.

        Step 2: Bridge to a network card that can access the Internet. In the menu bar Edit -> Virtual Network Editor, choose to bridge to the network card that can access the Internet in your Windows (usually Wifi network or wired network)

        Step 3: Set up dhcp and restart the network card. (Sometimes it doesn't work after restarting the network card, you can reboot to restart the virtual machine)

                            vi /etc/network/interfaces , open the file and edit the content to read:

                            auto eth0

                            iface eth0 inet dhcp

        (2) For the external network, our Ubuntu is equivalent to an independent Windows computer. It can be regarded as an extra computer in your local area network. It divides the physical network card of Windows into two, and provides Windows services on the external network. , while serving Ubuntu and sharing the network card.

        (3) Note: In the menu bar  Virtual Machine  ->  Settings  ->  Hardware  ->  Network Adapter -> Device Status, check Connected and Connect at startup. If you use the default bridge mode to bridge, in the virtual network editor we add VMnet0 to bridge (as if VMnet0 is the default), if you use a custom bridge, delete the previous bridge in the virtual network editor, and add VMnetx again to Bridge, then use custom to select the VMnetx you added.

        (4) The host can ping the virtual machine, but the virtual machine cannot ping the host, which is generally a firewall problem. Select the advanced firewall settings, find the IPV4-related options, and click Enable. (actually encountered, actually solved)


static allocation

      Step 1: In the menu bar  Virtual Machine  ->  Settings  ->  Hardware  ->  Network Adapters, select Bridge Mode on the right

      Step 2:  vi /etc/network/interfaces , open the file and edit the content as:

             auto eth0 //Network card model name

             iface eth0 inet static            

             address 192.168.1 .141 //The fixed virtual machine IP address set        

             netmask 255.255.255.0 //subnet mask

             gateway 192.168.1.1 //Gateway

             Step 3: Open Network Sharing Center->Local Area Connection->Properties->ipv4->If you choose to use the following IP, make the virtual machine network segment the same as the Windows network segment, change the Windows IP to 192.168.1.20 , this At the same time, neither Windows nor the virtual machine can access the Internet. But you can ping Windows; if you use the default IP, change the IP of the virtual machine to be the same as the IP of Windows. For example, the default IP of my campus network is 202.193.75.74, then change the virtual machine to 202.193.75.70, and set the gateway accordingly. , mask, consistent with Windows. At this time, Windows can access the Internet, but the virtual machine still cannot access the Internet. I don't know why? It can be pinged, and the virtual machine also has an independent IP, and the development board can also be pinged.


Ubuntu and development boards

1. NAT method:

        (1) Nat cannot be used at this time, because Ubuntu is in the stomach of Windows, they are not the same level, when the development board is connected to the Windows physical network card, it can only be connected to Windows. Bridging must be used.


2. Bridging method:

        (1) If we use DHCP to assign a dynamic IP to the virtual machine, we can use the development board to ping, but the IP needs to be changed every time the virtual machine is restarted. For some APPs, hang the rootfs under Ubuntu in the root file system, and virtualize the virtual machine. The IP of the machine is dead. At this time, the DHCP method can only satisfy the bridging method so that Ubuntu can access the Internet, but cannot fix the IP.

        (2) Fix the IP of the virtual machine and do not use DHCP. The external network only gives one ip to the host at this time, so our Ubuntu cannot access the external network, but we force bridging to assign a fixed IP to Ubuntu, although we cannot access the external network. , However, the virtual machine has its own independent IP, and the development board can ping the virtual machine.      

        

            


            

    

Guess you like

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