KVM虚拟机(CentOS-6)添加(attach-interface)网卡

线上kvm客户机因业务需要,增加一块访问其它网段的虚拟网卡,命令如下:

1、添加网卡

virsh attach-interface <domain-name> --type bridge --source <net-bridge> --model virtio --config --live

说明:

  • domain-name: 虚拟机名称或ID
  • net-bridge:网桥名称
  • –config:写入配置文件
  • –live:在线添加(表面上添加了,实际上网络不通,需要重启)

2、重启服务器

3、查看网卡名称

cat /etc/udev/rules.d/70-persistent-net.rules

内容如下:

# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x1af4:0x1000 (virtio-pci)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:4d:1d:50", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x1af4:0x1000 (virtio-pci)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:4e:5d:df", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x1af4:0x1000 (virtio-pci)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:12:9a:80", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"

其中最后一行,name=“eth2”即为网卡名称。

4、配置网卡

以网卡名eth2为例:

vim /etc/sysconfig/network-scripts/ifcfg-eth2"

添加下列内容:

DEVICE="eth2"
NAME=eth2
BOOTPROTO="static"
HWADDR="52:54:00:12:9a:80"
IPADDR="172.16.1.100"
# GATEWAY = 
NETMASK="255.255.255.0"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"

5、重启网卡

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值