Home>Article>Operation and Maintenance> What is centos virbr0

What is centos virbr0

藏色散人
藏色散人 Original
2022-01-27 15:23:11 7065browse

centos virbr0 is a Bridge created by KVM by default. Its function is to provide the virtual machine network card connected to it with the function of NAT access to the external network; virbr0 is assigned an IP "192.168.122.1" by default and provides access to the external network for other virtual machines. The network card provides DHCP service.

What is centos virbr0

The operating environment of this article: CentOS 7 system, DELL G3 computer

What is centos virbr0?

Understanding virbr0

virbr0 is a Bridge created by KVM by default, and its function is to connect to it The virtual machine network card provides the function of NAT access to the external network.

virbr0 is assigned an IP 192.168.122.1 by default and provides DHCP services for other virtual network cards connected to it.

Below we demonstrate how to use virbr0.

Open the configuration interface of VM1 in virt-manager, select "default" for the network card Source device,

Hang the network card of VM1 on virbr0 .
Start VM1 and run brctl show to 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 on the host machine

ps -elf|grepdnsmasq

5 S libvirt 2422 1 0 80 0 - 7054 poll_s 11:26 ?

00:00:00 /usr/ sbin/dnsmasq--conf-file=/var/lib/libvirt/dnsmasq/default.conf

in /var/lib/libvirt/ There is a default.leases file in the dnsmasq/ directory. After VM1 successfully obtains the DHCP IP,

you can view the corresponding information in the file

# cat /var/lib/libvirt/dnsmasq/default.leases 144152567752:54:00:75:dd:1a192.168.122.6 ubuntu *

The above shows that 192.168.122.6 has been assigned to the MAC address52:54:00:75:dd:1a, this 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 x86_64) Last login: Sun Sep 6 01:30:23 2015 root@VM1:~# ifconfig eth0 Link encap:Ethernet HWaddr52:54:00:75:dd:1ainet 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 external 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 external network, indicating that NAT works.

It should be noted that the virtual machine VM1 using NAT can access the external network, but the external network cannot directly access VM1. Because the source address of the network packet sent by VM1 is not 192.168.122.6, but replaced by the IP address of the host by NAT.

This is different from using br0. In the case of br0, VM1 communicates directly with the external network through its own IP without going through NAT address translation.

Recommended: "centos usage tutorial"

The above is the detailed content of What is centos virbr0. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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