KVM之十:虛擬機器線上新增網路卡

snale1989發表於2016-10-11

1、檢視原有網路卡資訊

#virsh domiflist snale
Interface  Type       Source     Model       MAC
-------------------------------------------------------
vnet0      bridge     br0        virtio      52:54:00:8c:b8:60

2、臨時新增新網路卡

#virsh attach-interface snale --type bridge --source br0 
成功附加介面

永久新增網路卡命令
#virsh attach-interface snale --type bridge --source br0  --config

3、檢視

#virsh domiflist snale
Interface  Type       Source     Model       MAC
-------------------------------------------------------
vnet0      bridge     br0        virtio      52:54:00:8c:b8:60
vnet1      bridge     br0        -           52:54:00:14:86:cf

#ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:8c:b8:60 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.23/24 brd 192.168.0.255 scope global eth0
    inet6 fe80::5054:ff:fe8c:b860/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 52:54:00:14:86:cf brd ff:ff:ff:ff:ff:ff

4、命令列增加的網路卡只儲存在記憶體中,重啟就失效,所以需要儲存到配置檔案中

#virsh dumpxml snale >/etc/libvirt/qemu/snale.xml 
#virsh define /etc/libvirt/qemu/snale.xml

刪除網路卡命令

#virsh detach-interface snale  --type bridge --mac  52:54:00:14:86:cf
成功分離介面

再重新儲存配置

相關文章