给kvm虚拟机添加网卡绑定IP1 min read

  • A+
所属分类:云计算

 
 
1.确认kvm虚拟机所在宿主机是否有相对应的网卡(如要给kvm虚拟机添加一个CN2网卡,宿主机上必须有个网卡可以通CN2)

例: 当前环境需要给kvm虚拟机添加一个CN2网卡,宿主机所对应的CN2网卡为: bond0.199

 
2.创建网桥并给指定虚拟机添加网卡

## virsh iface-bridge [宿主机的CN2网卡] [网桥名称,可自定义] --no-stp
[root@localhost]# virsh iface-bridge bond0.199 cn2 --no-stp
Created bridge cn2 with attached device bond0.199
Bridge interface cn2 started

## 查看下我们创建的网桥
[root@localhost]# ip a show cn2
353: cn2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 3c:ec:ef:58:42:ec brd ff:ff:ff:ff:ff:ff
    inet6 fe80::3eec:efff:fe58:42ec/64 scope link 
       valid_lft forever preferred_lft forever

## virsh attach-interface --domain [虚拟机ID或名称] --type bridge --source [要给虚拟机添加的网桥网卡] --model virtio --config --live
[root@localhost]# virsh attach-interface --domain instance-7f390aea-3126-4b96-8f75-268b47af5ae4 --type bridge --source cn2 --model virtio --config --live
Interface attached successfully

 
3.添加好之后这时在该lvm虚拟机中就会发现多了一块网卡,正常配置IP即可

## 进入虚拟机内配置即可
virsh console [虚拟机ID]

 

zhaoyulin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: