> Yes. I just added contrib/mactable/macscript to the git repo, which is your > previous script slightly less elegantly modified by me for this > circumstance. I also put back the "make new file then atomically rename" > behaviour since that means anything using this file doesn't risk a race > condition leading to a half-written file. >
I gave a try to the --dhcp-script option of dnsmasq. Following are the findings: Script used: (a little modified version of http://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=blob_plain;f=contrib/mactable/macscript;hb=HEAD): #!/bin/bash STATUS_FILE="/var/lib/libvirt/ dnsmasq/dnsmasq-ip-mac.status" # Script for dnsmasq lease-change hook. # Maintains the above file with a IP address/MAC address pairs, # one lease per line. Works with IPv4 and IPv6 leases, file is # atomically updated, so no races for users of the data. action="$1" mac="$2" # IPv4 ip="$3" expirytime="$DNSMASQ_LEASE_EXPIRES" hostname="$DNSMASQ_SUPPLIED_HOSTNAME" clientid="$DNSMASQ_CLIENT_ID" # ensure it always exists. if [ ! -f "$STATUS_FILE" ]; then touch "$STATUS_FILE" fi if [ -n "$DNSMASQ_IAID" ]; then mac="$DNSMASQ_MAC" # IPv6 clientid="$2" fi # worry about an add or old action when the MAC address is not known: # leave any old one in place in that case. if [ "$action" = "add" -o "$action" = "old" -o "$action" = "del" ]; then if [ -n "$mac" -o "$action" = "del" ]; then sed "/^${ip//./\.} / d" "$STATUS_FILE" > "$STATUS_FILE".new if [ "$action" = "add" -o "$action" = "old" ]; then echo "$expirytime $mac $ip $hostname $clientid" >> "$STATUS_FILE".new fi mv "$STATUS_FILE".new "$STATUS_FILE" # atomic update. fi fi Changes made to libvirt code: diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 8787bdb..7f9a74f 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -1058,6 +1058,7 @@ networkBuildDhcpDaemonCommandLine(virNetworkObjPtr network, cmd = virCommandNew(dnsmasqCapsGetBinaryPath(caps)); virCommandAddArgFormat(cmd, "--conf-file=%s", configfile); + virCommandAddArgFormat(cmd, "--dhcp-script=%s", "/var/lib/libvirt/dnsmasq/macscript.sh"); *cmdout = cmd; ret = 0; cleanup: In dnsmasq version 2.65 (latest on f18 repos), useful variables that were set: In the case of ipv4: $1=add $2=52:54:00:95:41:5d $3=192.168.100.128 DNSMASQ_INTERFACE=virbr0 DNSMASQ_TAGS=virbr0 DNSMASQ_TIME_REMAINING=3600 DNSMASQ_LEASE_EXPIRES=1380745674 In the case of ipv6: $1=add $2=00:01:00:01:19:df:2e:19:52:54:00:24:13:15 $3=2001:db8:ca2:2:1::45 DNSMASQ_INTERFACE=virbr3 DNSMASQ_TAGS=dhcpv6 virbr3 DNSMASQ_SERVER_DUID=00:01:00:01:19:df:29:7e:f0:4d:a2:8c:14:51 DNSMASQ_IAID=2364181 DNSMASQ_TIME_REMAINING=3600 DNSMASQ_LEASE_EXPIRES=1380745131 In the latest dnsmasq version 2.67rc2-3-g889d8a1 (built after cloning from git://thekelleys.org.uk/dnsmasq.git), useful variables that were set: In the case of ipv4: add 52:54:00:1a:a1:55 192.168.100.204 DNSMASQ_INTERFACE=virbr0 DNSMASQ_LEASE_EXPIRES=1380749702 DNSMASQ_TAGS=virbr0 DNSMASQ_TIME_REMAINING=3600 In the case of ipv6: add 00:01:00:01:19:df:3a:8e:52:54:00:7d:49:25 2001:db8:ca2:2:1::f5 DNSMASQ_IAID=8210725 DNSMASQ_INTERFACE=virbr3 DNSMASQ_LEASE_EXPIRES=1380748320 DNSMASQ_MAC=52:54:00:7d:49:25 DNSMASQ_SERVER_DUID= DNSMASQ_TAGS=dhcpv6 virbr3 DNSMASQ_TIME_REMAINING=3600 So, in case of latest dnsmasq code, output in dnsmasq-ip-mac.status: 1380747917 52:54:00:82:5e:09 2001:db8:ca2:2:1::79 1380747943 52:54:00:61:bd:d8 2001:db8:ca2:2:1::88 1380748110 52:54:00:15:1e:05 192.168.100.180 1380748320 52:54:00:7d:49:25 2001:db8:ca2:2:1::f5 00:01:00:01:19:df:3a:8e:52:54:00:7d:49:25 1380749702 52:54:00:1a:a1:55 192.168.100.204 1380749877 52:54:00:73:0a:27 192.168.100.190 1380749879 52:54:00:b7:87:3e 2001:db8:ca2:2:1::3e 00:01:00:01:19:df:40:a6:52:54:00:b7:87:3e 1380749880 52:54:00:bc:55:df 2001:db8:ca2:2:1::8f 00:01:00:01:19:df:40:a6:52:54:00:bc:55:df 1380749880 52:54:00:b7:87:3e 2001:db8:ca2:2:1::3e 00:01:00:01:19:df:40:a6:52:54:00:b7:87:3e Apologies for the long message. Queries: (i) Why is DNSMASQ_SERVER_DUID blank in case of ipv6 (dnsmasq 2.67rc2-3-g889d8a1) ? Is it an issue with libvirt code or dnsmasq? (ii) When will be dnsmasq version 2.67rc2-3-g889d8a1 be out as tarball and when will it be available in the fedora repositories? (I don't know who maintains the package buildings, but a tentative date would be fine) -- Nehal J Wani _______________________________________________ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss