{{tag>[rhel7 libvirt vm networking virtualization]}} =====Add NIC live to libvirt guest===== * List active network interface for vm:[root@srv2 ~]# virsh domiflist vmkdc Interface Type Source Model MAC ------------------------------------------------------- vnet7 bridge br400 virtio 52:54:00:c9:04:15 * Generate new unique MAC-address:[root@srv2 ~]# cat macgen.py #!/usr/bin/python # macgen.py script to generate a MAC address for guests on Xen # import random # def randomMAC(): mac = [ 0x00, 0x16, 0x3e, random.randint(0x00, 0x7f), random.randint(0x00, 0xff), random.randint(0x00, 0xff) ] return ':'.join(map(lambda x: "%02x" % x, mac)) # print randomMAC() * Add new NIC to guest. Use random generated MAC address: [root@srv2 ~]# virsh attach-interface --domain vmkdc --type bridge --source br300 --model virtio --mac 00:16:3e:23:3c:36 --config --live Interface attached successfully * List network interfaces for VM:[root@srv2 ~]# virsh domiflist vmkdc Interface Type Source Model MAC ------------------------------------------------------- vnet7 bridge br400 virtio 52:54:00:c9:04:15 vnet8 bridge br300 virtio 00:16:3e:23:3c:36