In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How to understand and use virbr0, I believe that many inexperienced people are at a loss about it. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Virbr0 is a Bridge created by KVM by default, and its function is to provide NAT access to the external network for the virtual machine network card connected to it.
Virbr0 assigns an IP 192.168.122.1 by default and provides DHCP services for other virtual network cards connected to it.
Let's demonstrate how to use virbr0.
Open the VM1 configuration interface in virt-manager, select "default" for the network card Source device, and hang the VM1 network card on the virbr0.
Start VM1,brctl show and you can see that vnet0 has been hung on virbr0.
# brctl show bridge name bridge id STP enabled interfaces br0 8000.000c298decbe no eth0 virbr0 8000.fe540075dd1a yes vnet0
Use the virsh command to confirm that vnet is the virtual network card of VM1.
# virsh domiflist VM1 Interface Type Source Model MAC-vnet0 network default rtl8139 52:54:00:75:dd:1a
Virbr0 uses dnsmasq to provide DHCP service, and you can view the process information in the host.
# ps-elf | grep dnsmasq
5 S libvirt+ 2422 10 800-7054 poll_s 11:26? 00:00:00 / usr/sbin/dnsmasq-- conf-file=/var/lib/libvirt/dnsmasq/default.conf
There is a default.leases file in the / var/lib/libvirt/dnsmasq/ directory. When VM1 successfully obtains the IP of DHCP, you can find the corresponding information in this file.
# cat / var/lib/libvirt/dnsmasq/default.leases 1441525677 52:54:00:75:dd:1a 192.168.122.6 ubuntu *
The above shows that 192.168.122.6 has been assigned to the network card whose MAC address is 52:54:00:75:dd:1a, which is the MAC of vnet0. You can then use this IP to access VM1.
# ssh 192.168.122.6 root@192.168.122.6's password: Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.16.0-30-generic x86y64) Last login: Sun Sep 6 01:30:23 2015 root@VM1:~# ifconfig eth0 Link encap:Ethernet HWaddr 52:54:00:75:dd:1a inet addr:192.168.122.6 Bcast:192.168.122.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:61 errors:0 dropped:0 overruns:0 frame:0 TX packets:66 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:7453 (7.4 KB) TX bytes:8649 (8.6 KB)
Ping the public network.
Root@VM1:~# 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=52 time=36.9 ms 64 bytes from 180.97.33.107: icmp_seq=2 ttl=52 time=119 ms 64 bytes from 180.97.33.107: icmp_seq=3 ttl=52 time=88.5 ms 64 bytes from 180.97.33.107: icmp_seq=4 ttl=52 time=38.0 ms 64 bytes from 180.97.33.107: icmp_seq=5 ttl=52 time=122 ms
No problem, you can access the public network, indicating that NAT is working.
It should be noted that the virtual machine VM1 using NAT can access the public network, but the public network cannot directly access the VM1. Because the source address of the network packet sent by VM1 is not 192.168.122.6, but is replaced by NAT with the IP address of the host.
This is different from using br0, in the case of br0, VM1 communicates directly with the external network through its own IP and does not go through NAT address translation.
After reading the above, have you mastered how to understand and use virbr0? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.