Assigning static IP to guest VM on NAT host network using virsh
How to backup VM images in linux. Learn how to backup and restore VM images.
First, find out the MAC address of the VM you want to assign the static IP addresses to:
$ virsh dumpxml $VM_NAME | grep 'mac address'Then, update the ip address for the virtual mac of the VM
$ virsh net-update default add ip-dhcp-host "<host mac='11:22:33:44:55:66' name='FOO' ip='192.168.1.134' />" --live --configThis would always assign 192.168.1.134 to the VM FOO running with a mac 11:22:33:44:55:66.
Finally, restart your VM to get the VM running with the specified IP.
$ virsh shutdown foo
$ virsh start fooTo troubleshoot any issues, begin by checking the IP assigned to the VM by dhcp
$ virsh net-dhcp-leases default