Home > System Tutorial > LINUX > body text

Steps to configure static IP in Linux bridge mode

王林
Release: 2024-01-08 22:30:31
forward
1318 people have browsed it
Introduction I have been using NAT mode before. During the test, when the android terminal remotely accessed the mysql of the virtual machine, I found that it could not connect. However, I successfully accessed the mysql of the virtual machine Linux copied by my classmate. I thought about the reason because it was set by him. bridge mode.

Regarding the difference between the two modes, you can search a lot of articles on the Internet. In layman's terms, in NAT mode, the virtual machine is subordinate to the host, that is, access to the external network must be accessed through the host, so the IP of the virtual machine is only Only the host can identify it. In bridge mode, the virtual machine and the host are in a parallel relationship, share a network card (using multiple interfaces of the network card), and can directly access the external network. Therefore, if you want to remotely access the MySQL of the virtual machine, you need to use bridge mode instead of NAT mode. However, the IP in bridge mode generally changes. In order to avoid resetting the IP for each remote connection, it is set to a static IP here.

The first step is to check the IP under Linux Steps to configure static IP in Linux bridge mode This is Ubuntu 16.04. There are 2 items here. The lower one is lo (local loopback) and can be ignored. The upper one needs to be configured. Note that my virtual network card here is ens33, and the one I will modify later is also ens33. There are many configuration tutorials on the Internet where the network card name of their Linux system is not ens33 (for example, some are eth0). The second step is to set up the virtual network In the VMware menu, Edit->Virtual Network Editor Steps to configure static IP in Linux bridge mode Modify "Bridge to" in the VMnet information to the network card adapter. The default is automatic. The third step is to check the IP information of the host (here is windows) The command is ipconfig /all. The reason why the /all option is added at the end is to view the description of the network card. Steps to configure static IP in Linux bridge mode Note that the description here of Qualcomm Atheros is the same as the name of the network card selected in the second step. Remember the three important items of the host. IPv4 address: 192.168.5.63 Subnet mask: 255.255.255.0 Default gateway: 192.168.5.1 Step 4: Modify the Linux network interface configuration $ sudo vim /etc/network/interfaces Modify the file (the specific path varies with the system) and set ens33 to a new IP under the same network segment. Here I set it to 192.168.5.64. (The IP calculation method for the same network segment is that the IP and subnet mask AND operation results are consistent. For example, if 192.168.5.63 and 255.255.255.0 are ANDed, 192.168.5.0 is obtained. For specific knowledge, please refer to the IP part of the computer network textbook) Steps to configure static IP in Linux bridge mode Lines 5 to 10 were manually edited by me. You can see that the gateway and netmask are the same as those on the host, and only the address has been modified. Step 5: Set DNS xyz@ubuntu:~$ sudo vim /etc/resolvconf/resolv.conf.d/head Steps to configure static IP in Linux bridge mode Then restart the virtual machine network service (practice has proven that this step is useless, although I don’t know why, just restart the system honestly.) xyz@ubuntu:~$ sudo /etc/init.d/networking restart [ ok ] Restarting networking (via systemctl): networking.service. Now check if the configuration is correct. Check the IP and it has changed to the set 192.168.5.64 Steps to configure static IP in Linux bridge mode Try pinging a URL: Steps to configure static IP in Linux bridge mode Try the host pinging the virtual machine: Steps to configure static IP in Linux bridge mode But the virtual machine failed to ping the host: Steps to configure static IP in Linux bridge mode The reason is that the firewall is turned on on the host and the firewall on the public network is turned off. Pinging the host again is successful: Steps to configure static IP in Linux bridge mode

The above is the detailed content of Steps to configure static IP in Linux bridge mode. For more information, please follow other related articles on the PHP Chinese website!

source:linuxprobe.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!