KVM修改网络模式为Bridge后,原有虚拟机该如何修改配置
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了KVM修改网络模式为Bridge后,原有虚拟机该如何修改配置相关的知识,希望对你有一定的参考价值。
场景说明:KVM虚拟机之前没有设置为Bridge模式,然后就直接创建虚拟机了(当时网卡模式选择的为default),后来调整KVM网卡模式为Bridge后,虚拟机没法正常联网。
[[email protected] ~]# virsh shudown CentOS-7.3-X86_64 [[email protected] ~]# virsh edit CentOS-7.3-X86_64 将xml配置文件中的: <interface type=‘network‘> <mac address=‘52:54:00:e4:7c:77‘/> <source network=‘default‘/> <model type=‘virtio‘/> <address type=‘pci‘ domain=‘0x0000‘ bus=‘0x00‘ slot=‘0x03‘ function=‘0x0‘/> </interface> 修改为: <interface type=‘bridge‘> <mac address=‘52:54:00:e4:7c:77‘/> <source bridge=‘br0‘/> <model type=‘virtio‘/> <address type=‘pci‘ domain=‘0x0000‘ bus=‘0x00‘ slot=‘0x03‘ function=‘0x0‘/> </interface>
由于kvm虚拟机使用的是bridge模式,可以把virbr0接口(即NAT方式里面的default虚拟网络)删除
[[email protected] ~]# ip add list 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP qlen 1000 link/ether 00:0c:29:14:2b:9a brd ff:ff:ff:ff:ff:ff 4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000 link/ether 52:54:00:9f:ad:48 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000 link/ether 52:54:00:9f:ad:48 brd ff:ff:ff:ff:ff:ff 7: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000 link/ether 00:0c:29:14:2b:9a brd ff:ff:ff:ff:ff:ff inet 10.10.10.160/24 brd 10.10.10.255 scope global br0 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe14:2b9a/64 scope link valid_lft forever preferred_lft forever 8: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UNKNOWN qlen 1000 link/ether fe:54:00:71:7b:aa brd ff:ff:ff:ff:ff:ff inet6 fe80::fc54:ff:fe71:7baa/64 scope link valid_lft forever preferred_lft forever 10: vnet1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UNKNOWN qlen 1000 link/ether fe:54:00:e4:7c:77 brd ff:ff:ff:ff:ff:ff inet6 fe80::fc54:ff:fee4:7c77/64 scope link valid_lft forever preferred_lft forever [[email protected] ~]# virsh net-list --all Name State Autostart Persistent ---------------------------------------------------------- default active yes yes [[email protected] ~]# brctl show bridge namebridge idSTP enabledinterfaces br08000.000c29142b9anoeth0 vnet0 vnet1 virbr08000.5254009fad48yesvirbr0-nic [[email protected] ~]# virsh net-destroy default Network default destroyed [[email protected] ~]# virsh net-undefine default Network default has been undefined
配置完成后,再次查看网卡信息
[[email protected] ~]# ip add list 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP qlen 1000 link/ether 00:0c:29:14:2b:9a brd ff:ff:ff:ff:ff:ff 7: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000 link/ether 00:0c:29:14:2b:9a brd ff:ff:ff:ff:ff:ff inet 10.10.10.160/24 brd 10.10.10.255 scope global br0 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe14:2b9a/64 scope link valid_lft forever preferred_lft forever 8: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UNKNOWN qlen 1000 link/ether fe:54:00:71:7b:aa brd ff:ff:ff:ff:ff:ff inet6 fe80::fc54:ff:fe71:7baa/64 scope link valid_lft forever preferred_lft forever 10: vnet1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UNKNOWN qlen 1000 link/ether fe:54:00:e4:7c:77 brd ff:ff:ff:ff:ff:ff inet6 fe80::fc54:ff:fee4:7c77/64 scope link valid_lft forever preferred_lft forever
本文出自 “冰冻vs西瓜” 博客,请务必保留此出处http://molewan.blog.51cto.com/287340/1926137
以上是关于KVM修改网络模式为Bridge后,原有虚拟机该如何修改配置的主要内容,如果未能解决你的问题,请参考以下文章