[Openstack] Guest VM IP configuration script

Turbo Fredriksson turbo at bayour.com
Wed Aug 31 08:29:16 UTC 2016


On Aug 31, 2016, at 7:15 AM, Van Leeuwen, Robert wrote:

> When you look at the dnsmasq process on a neutron server it is indeed set to static and uses the –dhcp-host options:
> dnsmasq  --dhcp-range=set:tag0,1.1.1.0,static,5529600s  --dhcp-hostsfile=/var/lib/neutron/dhcp/123-4567/host --lots_of_other_options

Using static IPs with DNSMasq isn't horribly difficult, but it takes
a little attention.

This is examples from my own setup. I have all my compute nodes configured
to get DHCP addresses, but in the DHCP server (dnsmasq), I make sure it
gives out static IPs. This is a HP Blade Center, with 16 BL460c/G6 blades:

/etc/dnsmasq.conf
=================
# Network for the iLO interface on the blades
dhcp-range=net:iLO,10.0.1.0,static,infinite

# The default network (anything else - dynamic IPs)
dhcp-range=192.168.69.150,192.168.69.250,12h

# Network for eth1 on the blades
dhcp-range=net:bc1,10.0.4.0,static,infinite

# MAC to IP to HOSTNAME mapping
dhcp-host=78:e7:d1:5e:32:22,10.0.1.1,bladeA01-iLO,infinite
dhcp-host=78:e7:d1:59:f8:ec,10.0.4.1,bladeA01,infinite
[etc]

# Make sure to tag the hosts
dhcp-vendorclass=iLO,CPQRIB3				# iLO class
dhcp-vendorclass=bc1,PXEClient:Arch:00000:UNDI:002001	# PXE boot
dhcp-vendorclass=bc1,d-i				# Debian installer asks with this

# Options for Blade Center 1 - iLO
dhcp-option=iLO,1,255.255.255.0
dhcp-option=iLO,3,10.0.1.254
dhcp-option=iLO,6,10.0.1.254
dhcp-option=iLO,15,domain.tld
dhcp-option=iLO,28,10.0.1.255
dhcp-option=iLO,42,10.0.1.254
dhcp-option=iLO,119,domain.tld.

# Options for Blade Center 1 - blades
dhcp-option=bc1,1,255.255.255.0
dhcp-option=bc1,3,10.0.4.254
dhcp-option=bc1,6,10.0.4.254
dhcp-option=bc1,15,domain.tld
dhcp-option=bc1,28,10.0.4.255
dhcp-option=bc1,42,10.0.4.254
dhcp-option=bc1,119,openstack.domain.tld.

# Options for the default network
dhcp-option=15,domain.tld
dhcp-option=23,50
dhcp-option=27,1
dhcp-option=40,domain
dhcp-option=42,0.0.0.0
dhcp-option=44,192.168.69.8
dhcp-option=45,192.168.69.8
dhcp-option=119,domain.tld

/etc/hosts
=================
10.0.1.1        bladeA01-iLO.domain.tld bladeA01-iLO
10.0.4.1        bladeA01.domain.tld bladeA01b openstack control control1 controller
[etc]


Have a look at http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html
for explanation on these options and their possible values. The "secret"
is actually the "dhcp-vendorclass"! That's what "tags" the request so that
it can then be "routed" (bad word, but it kind'a makes a little sense)
to the right "dhcp-option" and to the correct "dhcp-host" (which, of course
also uses the MAC for selection).



More information about the Openstack mailing list