#yyds干货盘点# kvm虚拟化关闭虚拟网卡virbr0的方法

网友投稿 1031 2022-08-26

#yyds干货盘点# kvm虚拟化关闭虚拟网卡virbr0的方法

#yyds干货盘点# kvm虚拟化关闭虚拟网卡virbr0的方法

kvm虚拟化环境安装好后,ifconfig会发现多了一个虚拟网卡virbr0,这是由于安装和启用了libvirt服务后生成的,libvirt在服务器(host)上生成一个 virtual network switch (virbr0),host上所有的虚拟机(guests)通过这个 virbr0 连起来。默认情况下 virbr0 使用的是 NAT 模式(采用 IP Masquerade),所以这种情况下 guest 通过 host 才能访问外部。

但是大多数情况下:我们虚拟机使用的是bridge(网桥)直接连到局域网里,所以这个 virbr0 不是必须的(注:不要搞混淆了,bridge 和这里的 virbr0 bridge 是互不相干的)。

那么如何关掉这个 virbr0 呢?下面对关闭这个virbr0虚拟网卡的操作做一记录:总结为以下三步:

1)首先net-destroy

2)接着net-undefine

3)最后重启libvirtd让设置生效

[root@kvmserver ~]# ifconfigbr0 Link encap:Ethernet HWaddr C8:1F:66:F4:FC:4Finet addr:192.168.1.8 Bcast:192.168.1.255 Mask:255.255.255.0inet6 addr: fe80::ca1f:66ff:fef4:fc4f/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:135245 errors:0 dropped:0 overruns:0 frame:0TX packets:101444 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:0RX bytes:13942261 (13.2 MiB) TX bytes:7634359 (7.2 MiB)em1 Link encap:Ethernet HWaddr C8:1F:66:F4:FC:4Einet addr:103.10.86.8 Bcast:103.10.86.63 Mask:255.255.255.192inet6 addr: fe80::ca1f:66ff:fef4:fc4e/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:1565647 errors:0 dropped:0 overruns:0 frame:0TX packets:433759 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:371869769 (354.6 MiB) TX bytes:332186615 (316.7 MiB)Interrupt:35em2 Link encap:Ethernet HWaddr C8:1F:66:F4:FC:4Finet6 addr: fe80::ca1f:66ff:fef4:fc4f/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:1306151 errors:0 dropped:0 overruns:0 frame:0TX packets:95447 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:163400847 (155.8 MiB) TX bytes:7174405 (6.8 MiB)Interrupt:38lo Link encap:Local Loopbackinet addr:127.0.0.1 Mask:255.0.0.0inet6 addr: ::1/128 Scope:HostUP LOOPBACK RUNNING MTU:16436 Metric:1RX packets:128908 errors:0 dropped:0 overruns:0 frame:0TX packets:128908 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:0RX bytes:25188477 (24.0 MiB) TX bytes:25188477 (24.0 MiB)virbr0 Link encap:Ethernet HWaddr 52:54:00:E7:2D:22inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:0 errors:0 dropped:0 overruns:0 frame:0TX packets:0 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:0RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)[root@kvmserver ~]# brctl showbridge name bridge id STP enabled interfacesbr0 8000.c81f66f4fc4f no em2virbr0 8000.525400e72d22 yes virbr0-nic[root@kvmserver ~]# virsh net-listName State Autostart Persistent--------------------------------------------------br0 active yes yesdefault active yes yes[root@kvmserver ~]# virsh net-destroy defaultNetwork default destroyed[root@kvmserver ~]# virsh net-undefine defaultNetwork default has been undefined[root@kvmserver ~]# service libvirtd restartStopping libvirtd daemon: [ OK ]Starting libvirtd daemon: [ OK ][root@kvmserver ~]# virsh net-listName State Autostart Persistent--------------------------------------------------br0 active yes yes[root@kvmserver ~]# brctl showbridge name bridge id STP enabled interfacesbr0 8000.c81f66f4fc4f no em2再次ifconfig查看,发现virtbr0网卡已经消失了![root@kvmserver ~]# ifconfigbr0 Link encap:Ethernet HWaddr C8:1F:66:F4:FC:4Finet addr:192.168.1.8 Bcast:192.168.1.255 Mask:255.255.255.0inet6 addr: fe80::ca1f:66ff:fef4:fc4f/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:161858 errors:0 dropped:0 overruns:0 frame:0TX packets:123581 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:0RX bytes:15735341 (15.0 MiB) TX bytes:9481865 (9.0 MiB)em1 Link encap:Ethernet HWaddr C8:1F:66:F4:FC:4Einet addr:103.10.86.8 Bcast:103.10.86.63 Mask:255.255.255.192inet6 addr: fe80::ca1f:66ff:fef4:fc4e/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:1850577 errors:0 dropped:0 overruns:0 frame:0TX packets:696879 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:407720396 (388.8 MiB) TX bytes:592419489 (564.9 MiB)Interrupt:35em2 Link encap:Ethernet HWaddr C8:1F:66:F4:FC:4Finet6 addr: fe80::ca1f:66ff:fef4:fc4f/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:1572393 errors:0 dropped:0 overruns:0 frame:0TX packets:115724 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:196738740 (187.6 MiB) TX bytes:8750347 (8.3 MiB)Interrupt:38lo Link encap:Local Loopbackinet addr:127.0.0.1 Mask:255.0.0.0inet6 addr: ::1/128 Scope:HostUP LOOPBACK RUNNING MTU:16436 Metric:1RX packets:350174 errors:0 dropped:0 overruns:0 frame:0TX packets:350174 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:0RX bytes:68170777 (65.0 MiB) TX bytes:68170777 (65.0 MiB)

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:js提交表单
下一篇:你的Android不好用,都是因为这几点原因(android有用吗)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~