kvm上添加万兆网卡_KVM虚拟机在线添加网卡

本文详细介绍了如何在KVM虚拟机(centos73)上添加万兆网卡。首先,通过`virsh domiflist`查看现有网卡信息。接着,使用`virsh attach-interface`命令临时和永久添加新网卡,并通过`virsh domiflist`验证。最后,通过`virsh dumpxml`和`virsh define`将配置保存到文件,确保网卡配置持久化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值