kvm 给虚机增加网卡

[[email protected] ok]# virsh domiflist c03
Interface  Type       Source     Model       MAC
-------------------------------------------------------
vnet1      bridge     br0        rtl8139     52:54:00:cf:e1:a3

[[email protected] ok]# virsh list
 Id    Name                           State
----------------------------------------------------
 1     c01                            running
 2     c03                            running
 3     c70                            running

临时增加网卡:

[[email protected] ok]# virsh attach-interface c03 --type bridge --source br0
Interface attached successfully
查看:
[[email protected] ok]# virsh domiflist c03
Interface  Type       Source     Model       MAC
-------------------------------------------------------
vnet1      bridge     br0        rtl8139     52:54:00:cf:e1:a3
vnet3      bridge     br0        rtl8139     52:54:00:7e:c2:6a
[[email protected] conf]# 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: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
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 52:54:00:2b:9e:6c brd ff:ff:ff:ff:ff:ff

永久增加网卡:

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

[[email protected] ok]# virsh dumpxml c03 >/etc/libvirt/qemu/c03.xml
[[email protected] ok]# virsh define /etc/libvirt/qemu/c03.xml
Domain c03 defined from /etc/libvirt/qemu/c03.xml

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

[[email protected] ~]# 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: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
3: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 52:54:00:7e:c2:6a brd ff:ff:ff:ff:ff:ff

增加并配置配置文件:

[[email protected] network-scripts]# cp ifcfg-eth0 ifcfg-eth2^C
[[email protected] network-scripts]# pwd
/etc/sysconfig/network-scripts
[[email protected] 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

[[email protected] network-scripts]# 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: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
3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> 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 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: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
3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> 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
[[email protected] ok]# virsh detach-interface c03 --type bridge --mac 52:54:00:7e:c2:6a
Interface detached successfully
查看IP
# 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: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
再次保存配置文件:
[[email protected] ok]# virsh dumpxml c03 >/etc/libvirt/qemu/c03.xml
[[email protected] ok]# virsh define /etc/libvirt/qemu/c03.xml
Domain c03 defined from /etc/libvirt/qemu/c03.xml
时间: 2024-10-04 05:29:22

kvm 给虚机增加网卡的相关文章

KVM修改虚机网卡模式:由NAT模式改为Bridge模式

1)关闭虚机 # virsh  shutdown  vm1 2)编辑虚机配置文件 # virsh  edit  vm1 <interface type='default'> 改为<interface type='bridge'> <mac address='52:54:00:50:58:7e'/> <source network='default'/>    改为<source bridge='br0'/> <model type='vir

vSphere克隆虚机重启网卡报错

使用VMware vSphere克隆虚机,修改IP重启网卡报错: 解决报错:修改MAC地址,重启网卡 编辑虚拟机配置,查看MAC地址 修改 /etc/udev/rules.d/70-persistent-net.rules 文件,保存退出执行 start_udev 修改网卡配置文件./etc/sysconfig/network-scripts/ifcfg-eth0/1 HWADDR="MAC地址"  和 /etc/udev/rules.d/70-persistent-net.rules

为EXSi5.5上的Centos虚机增加硬盘容量

宿主机调整 1. 关闭虚机, 2. 检查是否有存在的snapshot, 如果有, 需要删除, 否则不能调整磁盘容量 3. 虚机上编辑配置, 将磁盘容量调大后保存 虚机调整 参考这篇写得非常详细: 点击查看 To extend the logical volume: Note: These steps only apply to EXT3 file systems. Caution: VMware recommends having a complete backup of the virtual

linux 虚机增加硬盘大小 转自

转自http://blog.csdn.net/tongyu2009/article/details/8525384 当我做到#unzip liunx_oracle时候,提示disk full? [[email protected] ~]# df -h 发现已用100%, 说明安装时分配的空间10G不够,就需要增加虚拟机硬盘空间了,参考以下方法: 首先,可以备份下 .vmdk 我用上述方法,linux加硬盘空间成功了,但因为我挂载到了home/tony文件夹里面了,而home/tony是我装Lin

查看运行的KVM的虚机

[[email protected] Desktop]# cat demo.py #!/usr/bin/python import libvirt conn = libvirt.open("qemu:///system") for id in conn.listDomainsID(): dom = conn.lookupByID(id) infos = dom.info() print "" print "ID = %d" % id print

SDN Overlay网络中虚机到物理机的数据包的转发

在之前我们讨论了SDN Overlay 网络中5个不同场景下虚机数据包如何转发,今天我们将继续讨论处于Overlay网络中的虚机如何与物理机进行数据转发.有关于微软网络虚拟化HNV的相关概念,如RDID.VSID.虚机网络.虚拟子网.默认网关等,可以参考http://ichbinleo.blog.51cto.com/11948851/1902265和http://ichbinleo.blog.51cto.com/11948851/1903866  进一步了解. 在开始今天的讨论之前,我们需要引入

ESXi5.5下的Centos7虚机配置静态IP

使用的是osboxes.org上下载的已安装centos7 image, 在启动后, ifconfig不能看到网卡, 需要关机后在ESXi客户端编辑虚机, 删除网卡, 保存, 添加网卡, 网卡类型选择 VMXNET3 启动后, ifconfig能看到新的网卡, 名称为 eno16777984, 在/etc/sysconfig/network-scripts/ 下新建文件 ifcfg-eno16777984, 内容类似于 DEVICE="eno16777984" HWADDR="

在KVM虚机中增加磁盘空间

因虚机磁盘空间不足,导致业务无法正常运行1.创建镜像文件qemu-img create -f qcow2 /opt/vm_disk/215add_disk.img 100G2.修改配置文件virsh edit vm215 找到以下内容 <disk type='file' device='disk'> <driver name='qemu' type='qcow2' cache='none'/> <source file='/opt/vm_disk/vm02_210.img'/

启动第一个 KVM 虚机 - 每天5分钟玩转 OpenStack(4)

本节演示如何使用 virt-manager 启动 KVM 虚机. 首先通过命令 virt-manager 启动图形界面 # virt-manager 点上面的图标创建虚机 给虚机命名为 kvm1,这里选择从哪里启动虚机.如果是安装新的 OS,可以选择第一项.如果已经有安装好的镜像文件,选最后一项(如上图) 接下来需要告诉 virt-manager 镜像的位置. 点击 “Browser” 在我的系统中存放了一个 cirros-0.3.3-x86_64-disk.img 镜像文件 .cirros 是