2020-08-07 method of configuring static ip under Linux (centos) bridging mode

The following is reproduced from: https://www.php.cn/linux-389431.html

This article mainly shares with you the method of configuring static ip under linux bridge mode, hoping to help you.

1: Bridging mode

VMware bridging mode is to connect the virtual network adapter of the virtual machine with the physical network adapter of the host. The virtual network adapter in the virtual machine can directly access the external network through the physical network adapter in the host. In short, it is like adding a new and independent computer to the local area network. Therefore, the virtual machine will also occupy an IP address in the LAN and can access each other with other terminals. Bridge mode network connection supports wired and wireless host network adapters. If you want to treat the virtual machine as a completely independent computer and allow it to communicate with other terminals, the bridge mode is usually the easiest way for the virtual machine to access the network.

2: Set up network adapter

3: Modify the configuration file and set the static ip address

1: Check the network card interface name ifconfig | more or ip addr | more

[root@localhost ~]# ifconfig | more  
eth0      Link encap:Ethernet  HWaddr 00:0C:29:5A:71:6D    
          inet addr:  Bcast:  Mask:  
          inet6 addr: fe80::20c:29ff:fe5a:716d/64 Scope:Link  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1  
          RX packets:5631 errors:0 dropped:0 overruns:0 frame:0  
          TX packets:324 errors:0 dropped:0 overruns:0 carrier:0  
          collisions:0 txqueuelen:1000   
          RX bytes:398905 (389.5 KiB)  TX bytes:27775 (27.1 KiB)  
lo        Link encap:Local Loopback    
          inet addr:  Mask:  
          inet6 addr: ::1/128 Scope:Host  
          UP LOOPBACK RUNNING  MTU:16436  Metric:1  
          RX packets:230 errors:0 dropped:0 overruns:0 frame:0  
          TX packets:230 errors:0 dropped:0 overruns:0 carrier:0  
          collisions:0 txqueuelen:0   
          RX bytes:19722 (19.2 KiB)  TX bytes:19722 (19.2 KiB)

2: Edit the network card file VIM / etc / sysconfig / network scripts / ifcfg-eth0

As shown in the above figure, my network card name is eth0, and the corresponding file name is ifcfg-eth0

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0   
DEVICE=eth0   #Network card interface name  
BOOTPROTO=dhcp  #System startup address Protocol DHCP: DHCP dynamic address protocol static: static address protocol  
ONBOOT=yes   #Whether to activate the network card interface when the system starts  

Then add the following content to the file

IPADDR=  #Static ip. ping the ip before adding it. It can only be used if the ping fails to ensure its uniqueness  
NETMASK=  #Subnet mask  
GATEWAY=   #gateway

The complete configuration file is as follows

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0   

3: Restart network service network restart

[root@localhost Desktop]# service network restart  
Shutting down interface eth0:                              [  OK  ]  
Shutting down loopback interface:                          [  OK  ]  
Bringing up loopback interface:                            [  OK  ]  
Bringing up interface eth0:  Active connection state: activating  
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/9  
state: activated  
Connection activated  
                                                           [  OK  ]

4: Open cmd locally to test ping

Is Ping Data with 32 bytes:  
From Reply from: byte=32 time=6ms TTL=64
 From Reply from: byte=32 time=30ms TTL=64
 From Reply from: byte=32 time=8ms TTL=64
 From Reply from: byte=32 time=8ms TTL=64

Relevant recommendations:

Detailed explanation of bridging mode of PHP design mode

The above is the details of how to configure static ip in linux bridging mode. Please pay more attention to other relevant articles on php Chinese network!

The copyright of this article belongs to the author.
For commercial reprint, please contact the author for authorization. For non-commercial reprint, please indicate the source.
Source address: https://www.php.cn/linux-389431.html
Source: PHP Chinese website (www.php.cn)
© Copyright notice: Please attach the original link for reprint!

Posted by nikky_d16 on Tue, 24 May 2022 08:15:21 +0300