前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >kvm虚拟化关闭虚拟网卡virbr0的方法

kvm虚拟化关闭虚拟网卡virbr0的方法

作者头像
洗尽了浮华
发布2018-01-22 16:17:14
1.9K0
发布2018-01-22 16:17:14
举报
文章被收录于专栏:散尽浮华

我们知道: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 ~]# ifconfig br0 Link encap:Ethernet HWaddr C8:1F:66:F4:FC:4F inet addr:192.168.1.8 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::ca1f:66ff:fef4:fc4f/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:135245 errors:0 dropped:0 overruns:0 frame:0 TX packets:101444 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:13942261 (13.2 MiB) TX bytes:7634359 (7.2 MiB)

em1 Link encap:Ethernet HWaddr C8:1F:66:F4:FC:4E inet addr:103.10.86.8 Bcast:103.10.86.63 Mask:255.255.255.192 inet6 addr: fe80::ca1f:66ff:fef4:fc4e/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1565647 errors:0 dropped:0 overruns:0 frame:0 TX packets:433759 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:371869769 (354.6 MiB) TX bytes:332186615 (316.7 MiB) Interrupt:35

em2 Link encap:Ethernet HWaddr C8:1F:66:F4:FC:4F inet6 addr: fe80::ca1f:66ff:fef4:fc4f/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1306151 errors:0 dropped:0 overruns:0 frame:0 TX packets:95447 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:163400847 (155.8 MiB) TX bytes:7174405 (6.8 MiB) Interrupt:38

lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:128908 errors:0 dropped:0 overruns:0 frame:0 TX packets:128908 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:25188477 (24.0 MiB) TX bytes:25188477 (24.0 MiB)

virbr0 Link encap:Ethernet HWaddr 52:54:00:E7:2D:22 inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0 UP BROADCAST RUNNING 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.0 b) TX bytes:0 (0.0 b)

[root@kvmserver ~]# brctl show bridge name bridge id STP enabled interfaces br0 8000.c81f66f4fc4f no em2 virbr0 8000.525400e72d22 yes virbr0-nic

[root@kvmserver ~]# virsh net-list Name State Autostart Persistent -------------------------------------------------- br0 active yes yes default active yes yes

[root@kvmserver ~]# virsh net-destroy default Network default destroyed

[root@kvmserver ~]# virsh net-undefine default Network default has been undefined

[root@kvmserver ~]# service libvirtd restart Stopping libvirtd daemon: [ OK ] Starting libvirtd daemon: [ OK ] [root@kvmserver ~]# virsh net-list Name State Autostart Persistent -------------------------------------------------- br0 active yes yes

[root@kvmserver ~]# brctl show bridge name bridge id STP enabled interfaces br0 8000.c81f66f4fc4f no em2

再次ifconfig查看,发现virtbr0网卡已经消失了! [root@kvmserver ~]# ifconfig br0 Link encap:Ethernet HWaddr C8:1F:66:F4:FC:4F inet addr:192.168.1.8 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::ca1f:66ff:fef4:fc4f/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:161858 errors:0 dropped:0 overruns:0 frame:0 TX packets:123581 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:15735341 (15.0 MiB) TX bytes:9481865 (9.0 MiB)

em1 Link encap:Ethernet HWaddr C8:1F:66:F4:FC:4E inet addr:103.10.86.8 Bcast:103.10.86.63 Mask:255.255.255.192 inet6 addr: fe80::ca1f:66ff:fef4:fc4e/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1850577 errors:0 dropped:0 overruns:0 frame:0 TX packets:696879 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:407720396 (388.8 MiB) TX bytes:592419489 (564.9 MiB) Interrupt:35

em2 Link encap:Ethernet HWaddr C8:1F:66:F4:FC:4F inet6 addr: fe80::ca1f:66ff:fef4:fc4f/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1572393 errors:0 dropped:0 overruns:0 frame:0 TX packets:115724 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:196738740 (187.6 MiB) TX bytes:8750347 (8.3 MiB) Interrupt:38

lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:350174 errors:0 dropped:0 overruns:0 frame:0 TX packets:350174 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:68170777 (65.0 MiB) TX bytes:68170777 (65.0 MiB)

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2016-08-15 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云服务器
云服务器(Cloud Virtual Machine,CVM)提供安全可靠的弹性计算服务。 您可以实时扩展或缩减计算资源,适应变化的业务需求,并只需按实际使用的资源计费。使用 CVM 可以极大降低您的软硬件采购成本,简化 IT 运维工作。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档