User Tools

Site Tools


unix:virtualization:techniques

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

unix:virtualization:techniques [2020/02/19 15:02]
rodolico created
unix:virtualization:techniques [2020/02/19 15:15] (current)
rodolico
Line 25: Line 25:
 ===== Sticky IP's (Reservations) with virt-manager ===== ===== Sticky IP's (Reservations) with virt-manager =====
  
 +virt-manager defaults to NAT on the networking. I find this useful on my laptop, where I don't always have a DHCP server available and the running virtuals should be private to my laptop. However, the dhcp server will occasionally give a different IP to the same machine.
  
 +To get around this, find the MAC address of the virtual, then set the network to always give it the same IP address. By default, the dhcp server built into virt-manager sets up an entire /24 range except for the primary IP, so we'll need to adjust that range also.
 +
 +First, find the MAC address of the virtual you want to set up this way, and get the network list (usually "​default"​)
 +<code bash>
 +# get network name
 +virsh net-list
 +# get MAC address of a virtual'​s network interface
 +virsh  dumpxml ​ //vm_name// | grep 'mac address'​
 +</​code>​
 +
 +Now, edit the DHCP server
 +<code bash>
 +# change default to whatever you got in net-list, if it is different
 +virsh net-edit default
 +</​code>​
 +
 +Look through this list and find the XML block which defines the DHCP server. Adjust the range for automatic assignments to give you room to add  your reservations,​ then add a new line within the dhcp block to assign a sticky IP based on MAC address found above. Below, we have adjusted the //range start// address ufrom 192.168.122.2 to 192.168.122.100. .2-.99 are then available for sticky IP reservations. We then added three lines for vm1, vm2 and vm3, giving them an IP based on their mac addresses
 +
 +<code xml>
 +<​dhcp>​
 +  <range start='​192.168.122.100'​ end='​192.168.122.254'/>​
 +  <host mac='​52:​54:​00:​6c:​3c:​01'​ name='​vm1'​ ip='​192.168.122.11'/>​
 +  <host mac='​52:​54:​00:​6c:​3c:​02'​ name='​vm2'​ ip='​192.168.122.12'/>​
 +  <host mac='​52:​54:​00:​6c:​3c:​03'​ name='​vm3'​ ip='​192.168.122.12'/>​
 +</​dhcp>​
 +</​code>​
 +
 +Save your work, then you need to do something to get it all to begin work. [[https://​serverfault.com/​questions/​627238/​kvm-libvirt-how-to-configure-static-guest-ip-addresses-on-the-virtualisation-ho#​627245]],​ where I stole this idea, has a lot of things to do, but I just rebooted the damned thing and it began working just fine.
 +
 +===== Links =====
 +  * [[https://​www.utappia.org/​2016/​04/​how-to-migrate-your-virtual-box.html]]
 +  * https://​serverfault.com/​questions/​627238/​kvm-libvirt-how-to-configure-static-guest-ip-addresses-on-the-virtualisation-ho#​627245
unix/virtualization/techniques.txt ยท Last modified: 2020/02/19 15:15 by rodolico