Understanding dnsmasq

Dnsmasq provides network infrastructure for small networks: DNS, DHCP, router advertisement and network boot. It is designed to be lightweight and have a small footprint, suitable for resource constrained routers and firewalls. It has also been widely used for tethering on smartphones and portable hotspots, and to support virtual networking in virtualisation frameworks.

When we are using Neutron with FLAT manager OR VLAN manager, dnsmasq is the DHCP provider for you. For Compute to operate in IPv4/IPv6 dual-stack mode, use at least dnsmasq v2.63. The nova-network service is responsible for starting dnsmasq processes. For each network namespace in openstack there will be a dnsmasq service exists. Here, lets look on how to understand and troublshoot dnsmasq.

There will be two DHCP service running for each network. They will be deployed in two different controllers. First identity where is our DHCP namespace located.

root@node-28:~# neutron dhcp-agent-list-hosting-net 0178b0f9-30f0-4d6d-83c8-0147097b52a7 #networkID
+————————————–+————————–+—————-+——-+
| id | host | admin_state_up | alive |
+————————————–+————————–+—————-+——-+
| 56593f0a-7b59-4dc9-bc11-379eeedf05af | node-27.mos8.example.com | True | 🙂 |
| fe960f7f-e491-4698-bd8d-036d638960d1 | node-28.mos8.example.com | True | 🙂 |
+————————————–+————————–+—————-+——-+
root@node-28:~#

Lets check the the process running on the controller for this network namespace

root@node-28:~# ps -ef | grep dnsmasq | grep 0178b0f9-30f0-4d6d-83c8-0147097b52a7

nobody 2913 1 0 Aug22 ? 00:00:04 dnsmasq –no-hosts –no-resolv –strict-order –except-interface=lo –pid-file=/var/lib/neutron/dhcp/0178b0f9-30f0-4d6d-83c8-0147097b52a7/pid –dhcp-hostsfile=/var/lib/neutron/dhcp/0178b0f9-30f0-4d6d-83c8-0147097b52a7/host –addn-hosts=/var/lib/neutron/dhcp/0178b0f9-30f0-4d6d-83c8-0147097b52a7/addn_hosts –dhcp-optsfile=/var/lib/neutron/dhcp/0178b0f9-30f0-4d6d-83c8-0147097b52a7/opts –dhcp-leasefile=/var/lib/neutron/dhcp/0178b0f9-30f0-4d6d-83c8-0147097b52a7/leases –dhcp-match=set:ipxe,175 –bind-interfaces –interface=tapb02bd06e-91 –dhcp-range=set:tag0,192.168.1.0,static,600s –dhcp-lease-max=256 –conf-file= –domain=openstacklocal

root@node-28:~#

Well, you will be seeing a lot of informations about this dnsmasq. Like, this, for each network you are having in your environment, there will be a process like this for each of them. We will see what are those files.

Aug22 – The Date in which this service was reloaded. Whenever a new Virtual machine launched, this service will be reloaded (Not restarted) by reading the configuration file.
–pid-file – Process ID of this process
–dhcp-hostsfile Host Table for the Virtual Machines belongs to this DHCP Namespace
–dhcp-leasefile – Lease file, hosts, macid, and IP address of the virtual machines which are attached to this particular controller.
–interface – The tap interface where this DHCP server listening

Lets make sure, the interface is correct by entering into this DHCP namespace

ip netns exec qdhcp-0178b0f9-30f0-4d6d-83c8-0147097b52a7 ip a

The output will be look like the following

root@node-28:~# ip netns exec qdhcp-0178b0f9-30f0-4d6d-83c8-0147097b52a7 ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
51: tapb02bd06e-91: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default
link/ether fa:16:3e:99:5c:31 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.2/24 brd 192.168.1.255 scope global tapb02bd06e-91
valid_lft forever preferred_lft forever
inet 169.254.169.254/16 brd 169.254.255.255 scope global tapb02bd06e-91
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe99:5c31/64 scope link
valid_lft forever preferred_lft forever
root@node-28:~#

Look at the Tap interface in the process and interface in the DHCP namespace, both are Same. Highlighted in Green color.

Now, if you want to make sure the DORA (Discover Offer Respond Acknowledge) process is working fine, lets capture the packets from this interface. For doing this

ip netns exec qdhcp-0178b0f9-30f0-4d6d-83c8-0147097b52a7 bash

Now you are in the DHCP namespace of this particular network. Now, lets capture the Packets from this interface.

tcpdump -i tapb02bd06e-91 -n -w tcpdump-tapb02bd06e-91-node-28-internal-network-dchp-dump port 67 or port 68

Let this command run in the background for a few minutes (10 Minutes). The default lease timeout value is 600S. You can find this value in neutron.conf

root@node-28:~# grep -i dhcp_lease_duration /etc/neutron/neutron.conf
dhcp_lease_duration = 600
root@node-28:~#

OK, Fine lets read this file,

tcpdump -r tcpdump-tapb02bd06e-91-node-28-internal-network-dchp-dump

You will see the output like this

05:25:28.950164 IP 192.168.1.2.bootps > 192.168.1.9.bootpc: BOOTP/DHCP, Reply, length 342
05:29:25.687253 IP 192.168.1.10.bootpc > 192.168.1.2.bootps: BOOTP/DHCP, Request from fa:16:3e:04:70:d9 (oui Unknown), length 300
05:29:25.710935 IP 192.168.1.2.bootps > 192.168.1.10.bootpc: BOOTP/DHCP, Reply, length 343
05:29:49.154524 IP 192.168.1.9.bootpc > 192.168.1.2.bootps: BOOTP/DHCP, Request from fa:16:3e:e0:cf:97 (oui Unknown), length 300
05:29:49.183641 IP 192.168.1.2.bootps > 192.168.1.9.bootpc: BOOTP/DHCP, Reply, length 342
05:33:07.347292 IP 192.168.1.10.bootpc > 192.168.1.2.bootps: BOOTP/DHCP, Request from fa:16:3e:04:70:d9 (oui Unknown), length 300
05:33:07.370042 IP 192.168.1.2.bootps > 192.168.1.10.bootpc: BOOTP/DHCP, Reply, length 343
05:33:21.368664 IP 192.168.1.9.bootpc > 192.168.1.2.bootps: BOOTP/DHCP, Request from fa:16:3e:e0:cf:97 (oui Unknown), length 300
05:33:21.391503 IP 192.168.1.2.bootps > 192.168.1.9.bootpc: BOOTP/DHCP, Reply, length 342
05:36:59.045985 IP 192.168.1.9.bootpc > 192.168.1.2.bootps: BOOTP/DHCP, Request from fa:16:3e:e0:cf:97 (oui Unknown), length 300
05:36:59.070815 IP 192.168.1.2.bootps > 192.168.1.9.bootpc: BOOTP/DHCP, Reply, length 342
05:36:59.615715 IP 192.168.1.10.bootpc > 192.168.1.2.bootps: BOOTP/DHCP, Request from fa:16:3e:04:70:d9 (oui Unknown), length 300

Above, we can see that, All the Requests from Virtula machines, DHCP server properly responds. And above dnsmasq service is up and running as expected.

stacker has written 18 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Humans Only. * Time limit is exhausted. Please reload the CAPTCHA.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>