virt-manager: is it possible to assign specific IP addresses to certains VMs via the virtual DHCP?
AFAIK virt-manager
can only assign MAC-addresses. So what you would need to do is setup your DHCP server to map those to specific IP addresses.
Even if a different machine (e.g. your router) normally provides DHCP addresses, but cannot be easily modified programmatically, you can set a DHCP server up on the hosts of the VMs, that serves only to specific MAC addresses and as long as those are not in the range the other DHCP server gives out, you will not run into a problem.
Update prompted by Pavel's comment, you can set IP addresses via libvrt (although I rather have all my IP addresses in one spot)
...
<mac address='00:16:3E:5D:C7:9E'/>
<domain name="example.com"/>
<dns>
<txt name="example" value="example value" />
<forwarder addr="8.8.8.8"/>
<forwarder addr="8.8.4.4"/>
<srv service='name' protocol='tcp' domain='test-domain-name' target='.' port='1024' priority='10' weight='10'/>
<host ip='192.168.122.2'>
<hostname>myhost</hostname>
<hostname>myhostalias</hostname>
</host>
</dns>
<ip address="192.168.122.1" netmask="255.255.255.0">
<dhcp>
<range start="192.168.122.100" end="192.168.122.254" />
<host mac="00:16:3e:77:e2:ed" name="foo.example.com" ip="192.168.122.10" />
<host mac="00:16:3e:3e:a9:1a" name="bar.example.com" ip="192.168.122.11" />
</dhcp>
</ip>
<ip family="ipv6" address="2001:db8:ca2:2::1" prefix="64" />
<route family="ipv6" address="2001:db9:ca1:1::" prefix="64" gateway="2001:db8:ca2:2::2" />
Related videos on Youtube
Comments
-
fstab over 1 year
using
virt-manager
quite successfully. I am wondering if it's possible to specify in the virtual DHCP server, that some virtual machines will have a specific IP address (maybe via MAC address mapping?).Any ideas on how to do this? Otherwise I have to resort to simpler, and less elegant solutions, such as configuring the ip address from inside the VMs.
-
Pavel Šimerda over 9 yearsDoesn't libvirt start its own instance of dnsmasq?
-
Anthon over 9 years@PavelŠimerda I have never tried that way, but that seems to be a possibility for assigning the IP statically as well.