博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
kvm 给虚机增加网卡
阅读量:5842 次
发布时间:2019-06-18

本文共 5717 字,大约阅读时间需要 19 分钟。

 

[root@666 ok]# virsh domiflist c03Interface  Type       Source     Model       MAC-------------------------------------------------------vnet1      bridge     br0        rtl8139     52:54:00:cf:e1:a3[root@666 ok]# virsh list Id    Name                           State---------------------------------------------------- 1     c01                            running 2     c03                            running 3     c70                            running

 临时增加网卡:

[root@666 ok]# virsh attach-interface c03 --type bridge --source br0Interface attached successfully查看:[root@666 ok]# virsh domiflist c03Interface  Type       Source     Model       MAC-------------------------------------------------------vnet1      bridge     br0        rtl8139     52:54:00:cf:e1:a3vnet3      bridge     br0        rtl8139     52:54:00:7e:c2:6a[root@c03 conf]# ip a1: lo: 
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 forever2: eth0:
mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 52:54:00:cf:e1:a3 brd ff:ff:ff:ff:ff:ff inet 10.100.0.61/24 brd 10.100.0.255 scope global eth0 inet6 fe80::5054:ff:fecf:e1a3/64 scope link valid_lft forever preferred_lft forever3: eth1:
mtu 1500 qdisc noop state DOWN qlen 1000 link/ether 52:54:00:2b:9e:6c brd ff:ff:ff:ff:ff:ff

永久增加网卡:

命令行增加网卡只保存在内存中,重启就失效,所以要保存在配置文件中

[root@666 ok]# virsh dumpxml c03 >/etc/libvirt/qemu/c03.xml [root@666 ok]# virsh define /etc/libvirt/qemu/c03.xml Domain c03 defined from /etc/libvirt/qemu/c03.xml

 重启虚机后再次查看网卡:

[root@c03 ~]# ip a1: lo: 
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 forever2: eth0:
mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 52:54:00:cf:e1:a3 brd ff:ff:ff:ff:ff:ff inet 10.100.0.61/24 brd 10.100.0.255 scope global eth0 inet6 fe80::5054:ff:fecf:e1a3/64 scope link valid_lft forever preferred_lft forever3: eth2:
mtu 1500 qdisc noop state DOWN qlen 1000 link/ether 52:54:00:7e:c2:6a brd ff:ff:ff:ff:ff:ff

 增加并配置配置文件:

[root@c03 network-scripts]# cp ifcfg-eth0 ifcfg-eth2^C[root@c03 network-scripts]# pwd/etc/sysconfig/network-scripts[root@c03 network-scripts]# cp ifcfg-eth0 ifcfg-eth2配改MAC并查看:  DEVICE=eth0                                                         |  DEVICE=eth2                                                          HWADDR=52:54:00:CF:E1:A3                                            |  HWADDR=52:54:00:7e:c2:6a                                             TYPE=Ethernet                                                       |  TYPE=Ethernet  UUID=4edbb7bf-e64f-402a-854c-ff259250c497                           |  #UUID=4edbb7bf-e64f-402a-854c-ff259250c497                           ONBOOT=yes                                                          |  ONBOOT=yes  NM_CONTROLLED=yes                                                   |  NM_CONTROLLED=yes  BOOTPROTO=dhcp                                                      |  BOOTPROTO=dhcp

 查看IP

[root@c03 network-scripts]# ip a1: lo: 
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 forever2: eth0:
mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 52:54:00:cf:e1:a3 brd ff:ff:ff:ff:ff:ff inet 10.100.0.61/24 brd 10.100.0.255 scope global eth0 inet6 fe80::5054:ff:fecf:e1a3/64 scope link valid_lft forever preferred_lft forever3: eth2:
mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 52:54:00:7e:c2:6a brd ff:ff:ff:ff:ff:ff inet 10.100.0.58/24 brd 10.100.0.255 scope global eth2 inet6 fe80::5054:ff:fe7e:c26a/64 scope link valid_lft forever preferred_lft forever

 

删除网卡命令:

# ip a1: lo: 
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 forever2: eth0:
mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 52:54:00:cf:e1:a3 brd ff:ff:ff:ff:ff:ff inet 10.100.0.61/24 brd 10.100.0.255 scope global eth0 inet6 fe80::5054:ff:fecf:e1a3/64 scope link valid_lft forever preferred_lft forever3: eth2:
mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 52:54:00:7e:c2:6a brd ff:ff:ff:ff:ff:ff inet 10.100.0.58/24 brd 10.100.0.255 scope global eth2 inet6 fe80::5054:ff:fe7e:c26a/64 scope link valid_lft forever preferred_lft forever[root@666 ok]# virsh detach-interface c03 --type bridge --mac 52:54:00:7e:c2:6aInterface detached successfully查看IP# ip a1: lo:
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 forever2: eth0:
mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 52:54:00:cf:e1:a3 brd ff:ff:ff:ff:ff:ff inet 10.100.0.61/24 brd 10.100.0.255 scope global eth0 inet6 fe80::5054:ff:fecf:e1a3/64 scope link valid_lft forever preferred_lft forever再次保存配置文件:[root@666 ok]# virsh dumpxml c03 >/etc/libvirt/qemu/c03.xml [root@666 ok]# virsh define /etc/libvirt/qemu/c03.xml Domain c03 defined from /etc/libvirt/qemu/c03.xml

 

转载地址:http://bfjcx.baihongyu.com/

你可能感兴趣的文章
解决Strict Standards: Only variables should be passed by reference
查看>>
解决JBoss只能通过localhost(127.0.0.1)而不能通过IP访问
查看>>
MS SQL处理双引号(DoubleQuote)函数
查看>>
[智能架构系列]什么是Buddy智能开发框架
查看>>
三十一、关于android camera setParameters出错
查看>>
【收藏】QCIF、 CIF、2CIF、DCIF、D1(4CIF)格式介绍
查看>>
hdu 3836 Equivalent Sets (tarjan缩点)
查看>>
一些iOS高效开源类库(转)
查看>>
JAVA编程心得-JAVA实现CRC-CCITT(XMODEM)算法
查看>>
C# DES加密
查看>>
浅谈Oracle分区表之范围分区
查看>>
IBM Tivoli NetView网管软件实战
查看>>
IPSec逻辑体系架构
查看>>
Exchange 2013部署系列之(六)配置邮件流和客户端访问
查看>>
List of Free Programming books
查看>>
思考Android架构(二):像Android框架,如何(How-to)吸引开发者来使用它呢?
查看>>
在html中,怎么获取当前页面body的高度,body是没有设置高度的,但是里面有内容...
查看>>
把 Array 转换成 Map
查看>>
MyBatis入门学习
查看>>
ASA防火墙IPSEC
查看>>