标签:define frame ifconfig 必须 been led 虚拟化 通过 car
我们知道: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)
标签:define frame ifconfig 必须 been led 虚拟化 通过 car
原文地址:https://www.cnblogs.com/lsgxeva/p/9026752.html