Hi All,

Im on an ubuntu 16.04 machine and was trying to setup a quick dhcp server for a test with some wifi equipment that needs a custom dhcp option (43) and ran into two problems I couldn't find my way around.

The first was serving dhcp in the first place. Had two ethernet interfaces in the machine (both usb), one of which was on a network 192.168.121.0/24 (which im trying to be a dhcp server for) and the other was on a completely different range (itself being provided dhcp). taking the config from what libvirt created on its bridge interface and adjusting appropriately I had a few issues and eventually just had this:

interface=enx00e04c681254
dhcp-range=192.168.121.10,192.168.121.100,12h
dhcp-option=43,15,03:0C:31:39:32:2E:31:36:38:2E:31:32:30:2E:31

But I ran into a very odd issue in that dnsmasq wouldnt serve DHCP on the 192.168.121.1/24 interface until it saw a request on the other interface (for which it had no range), as an example:
root@test:~/tmp# dnsmasq -C dnsmasq.conf --port=0 -d --no-ping
dnsmasq: started, version 2.75 DNS disabled
dnsmasq: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect inotify dnsmasq-dhcp: DHCP, IP range 192.168.121.10 -- 192.168.121.100, lease time 12h dnsmasq-dhcp: no address range available for DHCP request via enx00e04d6801e2
dnsmasq-dhcp: DHCPDISCOVER(enx00e04c681254) 4c:fa:ca:5e:ef:e0
dnsmasq-dhcp: DHCPOFFER(enx00e04c681254) 192.168.121.80 4c:fa:ca:5e:ef:e0
dnsmasq-dhcp: DHCPREQUEST(enx00e04c681254) 192.168.121.80 4c:fa:ca:5e:ef:e0
dnsmasq-dhcp: DHCPACK(enx00e04c681254) 192.168.121.80 4c:fa:ca:5e:ef:e0

it was receiving multiple requests on the enx00e04c681254 interface fairly continuously but never responded until it saw a request on enx00e04d6801e2 (for which it had no ability to provide a lease and shouldn't have been bound to it anyway). Took quite a while to realize this was occuring. Tried various incarnations of the listen, bind, dynamic-bind, etc options, but couldnt find a reason why it might occur (even watching it with strace wasnt very enlightening). There were at this point no other dnsmasq's running on the machine and no firewall.

Second problem I couldnt quite figure out is how to send an custom vendor option that has an ascii encoded ip adddress prefixed with 0x03 and 0x0c (bit of searching found a few people who were struggling with similar) but could never get it to work quite right. initially i just had dhcp-option:43,03:0C:31:39:32:2E:31:36:38:2E:31:32:30:2E:31 (should be 0x3 0xc then ascii for 192.168.120.1), the end result (according to tcpdump) was this:

Vendor-Option Option 43, length 30: 48.51.48.67.51.49.51.57.51.50.50.69.51.49.51.54.51.56.50.69.51.49.51.50.51.48.50.69.51.49

which is actually "03:0C:31" as ascii text.

A bit of searching/reading and i had this (added the length to the option - though im not sure this is actually accurate though it did work): dhcp-option=43,15,03:0C:31:39:32:2E:31:36:38:2E:31:32:30:2E:31 and that resulting in this:

Vendor-Option Option 43, length 15: 3.12.49.57.50.46.49.54.56.46.49.50.48.46.49

which looks correct, but i actually made a mistake here and wanted 192.168.120.2 so i changed it to this: dhcp-option=43,15,03:0C:31:39:32:2E:31:36:38:2E:31:32:30:2E:32 (incremented last digit) and that resulted in this (according to tcpdump):

Vendor-Option Option 43, length 47: 49.53.44.48.51.58.48.67.58.51.49.58.51.57.58.51.50.58.50.69.58.51.49.58.51.54.58.51.56.58.50.69.58.51.49.58.51.50.58.51.48.58.50.69.58.51.50

which is actually "15,03:0C..." it appeared to interpret the option as plain text at that point again?

The way I read the man page, dhcp-option=XX,AA:BB:CC:DD:EE should result in it sending option XX with a length of 5 and each colon-seperated chunk in the data field being a hex value for each of the bytes (AA = hex value of byte 1, etc). Also found a post that suggested dhcp-option=XX,YY,AA:BB:CC... sets the length to be YY (which i dont think is actually true?)

Im not sure if I am misinterpreting the man page or the ubuntu package version of dnsmasq is a little broken (though the ones it uses for things like libvirt work just fine)?


_______________________________________________
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss

Reply via email to