1、查看原有网卡信息
root@localhost
~]# virsh domiflist centos73
Interface Type
Source Model MAC
-------------------------------------------------------
vnet1 bridge
br0 virtio 52:54:00:9d:7a:94
2、临时添加新网卡
#
[root@localhost
~]# virsh attach-interface centos73 --type bridge --source br0
Interface
attached successfully
成功附加接口
永久添加网卡命令
#virsh attach-interface centos73 --type bridge --source br0 --config
3、查看
[root@localhost
~]# virsh domiflist centos73
Interface Type
Source Model MAC
-------------------------------------------------------
vnet0 bridge
br0 virtio 52:54:00:9d:7a:94
vnet1 bridge
br0 rtl8139 52:54:00:c4:8d:84
Last login: Mon Aug 21 21:27:27 from 192.168.0.190
[root@localhost ~]# ifconfig
eth0: flags=4163 mtu 1500
inet
192.168.0.112 netmask 255.255.255.0 broadcast 192.168.0.255
inet6
fe80::1e89:5915:c6b6:2eb1 prefixlen
64 scopeid 0x20
ether
52:54:00:c4:8d:84 txqueuelen 1000 (Ethernet)
RX packets 29 bytes 4669 (4.5 KiB)
RX errors 0 dropped 0
overruns 0 frame 0
TX packets 35 bytes 3334 (3.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0
collisions 0
eth1: flags=4163 mtu 1500
inet
192.168.0.172 netmask 255.255.255.0 broadcast 192.168.0.255
inet6
fe80::5054:ff:fe9d:7a94 prefixlen
64 scopeid 0x20
ether
52:54:00:9d:7a:94 txqueuelen 1000 (Ethernet)
RX packets 59 bytes 12755 (12.4 KiB)
RX errors 0 dropped 0
overruns 0 frame 0
TX packets 9 bytes 1246 (1.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0
collisions 0
lo: flags=73 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128
scopeid 0x10
loop txqueuelen 1
(Local Loopback)
RX packets 8 bytes 680 (680.0 B)
RX errors 0 dropped 0
overruns 0 frame 0
TX packets 8 bytes 680 (680.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0
collisions 0
4、命令行增加的网卡只保存在内存中,重启就失效,所以需要保存到配置文件中
virsh dumpxml centos73 >
/etc/libvirt/qemu/centos73.xml
virsh
define /etc/libvirt/qemu/centos73.xml
Domain
centos73 defined from /etc/libvirt/qemu/centos73.xml
删除网卡命令
#virsh
detach-interface centos73--type bridge --mac 52:54:00:c4:8d:84