In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How to carry out the practice of Linux Bridge virtual network, in view of this problem, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
How to implement the virtual network shown in the following figure in the experimental environment
Configure Linux Bridge br0
Edit / etc/network/interfaces to configure br0.
The following changes to / etc/network/interfaces are shown in vmdiff
There are two points to note: 1. Previously, the IP of the host was configured on the eth0 through dhcp; after creating the Linux Bridge, the IP must be placed on the br0. In the configuration information of br0, please note the last line "bridge_ports eth0". Its function is to attach eth0 to br0.
Restart the host and check the IP configuration. You can see that IP has been placed on the br0.
# ifconfig br0 Link encap:Ethernet HWaddr 00:0c:29:8d:ec:be inet addr:192.168.111.107 Bcast:192.168.111.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe8d:ecbe/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:22573 errors:0 dropped:0 overruns:0 frame:0 TX packets:2757 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:4927580 (4. 9 MB) TX bytes:368895 (368.8 KB)
Eth0 Link encap:Ethernet HWaddr 00:0c:29:8d:ec:be inet6 addr: fe80::20c:29ff:fe8d:ecbe/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:24388 errors:0 dropped:0 overruns:0 frame:0 TX packets:2816 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:5590438 (5.5 MB) TX bytes:411558 (411.5 KB)
Lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr:: 1Comp128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:146 errors:0 dropped:0 overruns:0 frame:0 TX packets:146 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:10521 (10.5 KB) TX bytes:10521 (10.5 KB)
Virbr0 Link encap:Ethernet HWaddr 72:db:fb:f2:19:91 inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0B) TX bytes:0 (0.0B)
Use brctl show to view the current configuration of Linux Bridge. Eth0 is already on br0.
# brctl show bridge name bridge id STP enabled interfaces br0 8000.000c298decbe no eth0 virbr0 8000.000000000000 yes
In addition to br0, you should notice that there is also a Bridge for virbr0, and the IP address 192.168.122.1 has been configured on virbr0. The role of virbr0 will be discussed later.
In the host, CloudMan has created virtual machines VM1 and VM2 ahead of time, and now they are both turned off.
# virsh list-all Id Name State-VM1 shut off-VM2 shut off
Configure VM1
Let's take a look at the network card configuration of VM1 in virt-manager (both the command line tool virsh and the graphics tool virt-manager,CloudMan will be used at the same time in the demonstration, both of which are important)
You can see the source device of the virtual network card. We chose br0.
Let's start VM1 and see what happens.
# virsh start VM1 Domain VM1 started
# brctl show
Bridge name bridge id STP enabled interfaces br0 8000.000c298decbe no eth0 vnet0 virbr0 8000.000000000000 yes
Brctl show tells us that a vnet0 device has been added under br0 and confirms through virsh that this is the virtual network card of VM1.
# virsh domiflist VM1 Interface Type Source Model MAC-vnet0 bridge br0 rtl8139 52:54:00:75:dd:1a
VM1's IP is obtained by DHCP (of course, setting a static IP is also possible), log in to VM1 through the virt-manager console and view the IP.
# ifconfig eth0 Link encap:Ethernet HWaddr 52:54:00:75:dd:1a inet addr:192.168.111.106 Bcast:192.168.111.255 Mask:255.255.255.0 inet6 addr: fe80::5054:ff:fe75:dd1a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:400 errors:0 dropped:0 overruns:0 frame:0 TX packets:101 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:41950 (41. 9 KB) TX bytes:12583 (12.5 KB)
The IP obtained by VM1 through DHCP is 192.168.111.106, which is the same network segment as the host (IP is 192.168.111.107). Ping the public network
Root@VM1:~# ping www.baidu.com PING www.a.shifen.com (180.97.33.108) 56 (84) bytes of data. 64 bytes from 180.97.33.108: icmp_seq=1 ttl=53 time=34.9 ms 64 bytes from 180.97.33.108: icmp_seq=2 ttl=53 time=36.2 ms 64 bytes from 180.97.33.108: icmp_seq=3 ttl=53 time=38.8 ms
No problem. You can visit it.
In addition, in VM1, the virtual network card is eth0, not vnet0. Vent0 is the device name corresponding to the virtual Nic in the host, and its type is TAP device, which needs to be noted here.
Configure VM2
Like VM1, VM2's virtual network card is also hung on br0. Start VM1 and view the network card information.
# virsh start VM2 Domain VM2 started
# brctl show
Bridge name bridge id STP enabled interfaces br0 8000.000c298decbe no eth0 vnet0 vnet1 virbr0 8000.000000000000 yes
Vnet1 is added under br0. Confirm through virsh that this is the virtual network card of VM2.
# virsh domiflist VM2 Interface Type Source Model MAC-vnet0 bridge br0 rtl8139 52:54:00:cf:33:a1
The IP obtained by VM2 through DHCP is 192.168.111.108. Log in to VM2 to verify network connectivity.
Ping VM1
Root@VM2:~# ping VM1 PING VM1 (192.168.111.106) 56 (84) bytes of data. 64 bytes from 192.168.111.106: icmp_seq=1 ttl=64 time=4.54 ms 64 bytes from 192.168.111.106: icmp_seq=2 ttl=64 time=1.63 ms 64 bytes from 192.168.111.106: icmp_seq=3 ttl=64 time=2.16 ms
Ping host
Root@VM2:~# ping 192.168.111.107 PING 192.168.111.107 (192.168.111.107) 56 (84) bytes of data. 64 bytes from 192.168.111.107: icmp_seq=1 ttl=64 time=1.02 ms 64 bytes from 192.168.111.107: icmp_seq=2 ttl=64 time=0.052 ms 64 bytes from 192.168.111.107: icmp_seq=3 ttl=64 time=0.064 ms
Ping external network
Root@VM2:~# ping www.baidu.com PING www.a.shifen.com (180.97.33.107) 56 (84) bytes of data. 64 bytes from 180.97.33.107: icmp_seq=1 ttl=53 time=53.9 ms 64 bytes from 180.97.33.107: icmp_seq=2 ttl=53 time=45.0 ms 64 bytes from 180.97.33.107: icmp_seq=3 ttl=53 time=44.2 ms
It can be seen that through the Linux Bridge of br0, we have realized the data communication among VM1, VM2, host and external network.
The answer to the practical question on how to carry out the Linux Bridge virtual network is shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.