Project

General

Profile

Bug #79

DNSMasq removed ISC-DHCP Log parsing. Need to write a replacement

Added by Scott Ullrich about 10 years ago. Updated about 9 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
Unknown
Target version:
Start date:
09/08/2009
Due date:
% Done:

100%

Estimated time:
Affected Version:
All
Affected Architecture:

Description

From their notes:

Remove ISC-leasefile reading code. This has been deprecated for a long time,
and last time I removed it, it ended up going back by request of one user.
This time, it's gone for good; otherwise it would need to be re-worked to
support multiple domains (see below).

Associated revisions

Revision 7ea754a8 (diff)
Added by Scott Ullrich almost 10 years ago

Adding script to parse dhcpd log file and populate /etc/hosts so that we can move to a newer dnsmasq. in addition, the current dnsmasq isc parsing is broken so there is not a choice to move either way. Ticket #79

Revision e44c520f (diff)
Added by Sjon Hortensius over 4 years ago

Reorder elements, use events, remove table

refs #79

History

#1 Updated by Jim Pingle almost 10 years ago

It seems that dnsmasq keeps all of these internally.

If we rewrite this with a daemon or cron script of some kind, it would probably have to add these to /etc/hosts without clobbering the existing entries which are kept there. The DHCP lines could probably be tagged with a comment like so:

192.168.1.52 mypc.example.com mypc #DHCP Lease Host "mypc" 

When the hosts file is built in the PHP code, these lines could be stripped out and then a function called at the end to parse the leases file and add them back in. The new program could then just append to the end of the file.

Sound reasonable? I can start tinkering with a parser if there are no objections.

#2 Updated by Scott Ullrich almost 10 years ago

Sounds good to me.

#3 Updated by Scott Ullrich almost 10 years ago

PS: I don't think anything else writes to /etc/hosts except dnsmasq.

#4 Updated by Scott Ullrich almost 10 years ago

system_hosts_generate() generates the /etc/hosts entries for dnsmasq. so it does look like we will need the code to be able to determine if an entry is for dnsmasq or not. #DHCP Lease Host "mypc" would be good.

#5 Updated by Scott Ullrich almost 10 years ago

Wrote this shell script: http://cvs.pfsense.org/~sullrich/rc.parse-isc-dhcpd

Please review.

#6 Updated by Scott Ullrich almost 10 years ago

All code commited. This appears to work but I am concerned that the shell script forks so it doubles the ram usage to about 3 megabytes. need to investigate using lua or some other language that uses less memory (c?).

#7 Updated by Scott Ullrich almost 10 years ago

  • % Done changed from 0 to 20

#8 Updated by Scott Ullrich almost 10 years ago

  • Target version changed from 2.0 to 3

Targeting 3.0 for an enhanced daemon. This seems to work really well.

#9 Updated by Ermal Luçi over 9 years ago

  • Status changed from New to Feedback
  • % Done changed from 20 to 100

Replacement done.

#10 Updated by Ermal Luçi over 9 years ago

  • Target version changed from 3 to 2.0

#11 Updated by Chris Buechler over 9 years ago

  • Status changed from Feedback to Resolved

#12 Updated by Adam Stylinski about 9 years ago

After having left pfsense running for a while my dynamic hostname resolution seems to have vanished.

  1. uptime
    11:58PM up 27 days, 10:54, 2 users, load averages: 0.08, 0.02, 0.01

The following are all static hosts:

  1. cat /etc/hosts
    127.0.0.1 localhost localhost.adamsnet
    192.168.0.1 pfsense.adamsnet pfsense
    129.137.4.127 pohl.adamsnet pohl
    192.168.0.245 macbox.adamsnet macbox
    192.168.0.2 downstairs.adamsnet downstairs
    192.168.0.60 nasbox.adamsnet nasbox
    192.168.0.96 G4box.adamsnet G4box
    192.168.0.116 brynns.adamsnet brynns
    192.168.0.119 freebsdbox.adamsnet freebsdbox
    192.168.0.121 mythtvbox.adamsnet mythtvbox
    192.168.0.124 BRN001BA9151890.adamsnet BRN001BA9151890

As you can see there are plenty of dynamic hosts:

  1. cat /var/dhcpd/var/db/dhcpd.leases
  2. All times in this file are in UTC (GMT), not your local timezone. This is
  3. not a bug, so please don't ask about it. There is no portable way to
  4. store leases in the local timezone, so please don't request this as a
  5. feature. If this is inconvenient or confusing to you, we sincerely
  6. apologize. Seriously, though - don't ask.
  7. The format of this file is documented in the dhcpd.leases(5) manual page.
  8. This lease file was written by isc-dhcp-V3.0.7

lease 192.168.1.25 {
starts 6 2010/06/26 22:07:28;
ends 0 2010/06/27 00:07:28;
tstp 0 2010/06/27 00:07:28;
binding state free;
hardware ethernet c4:17:fe:a4:3e:92;
uid "\001\304\027\376\244>\222";
}
lease 192.168.1.21 {
starts 0 2010/07/04 01:07:53;
ends 0 2010/07/04 03:07:53;
tstp 0 2010/07/04 03:07:53;
binding state free;
hardware ethernet 00:22:5f:c8:f6:20;
uid "\001\000\"_\310\366 ";
}
lease 192.168.1.23 {
starts 0 2010/07/04 02:11:56;
ends 0 2010/07/04 04:11:56;
binding state active;
next binding state free;
hardware ethernet 00:01:02:c9:3a:76;
uid "\001\000\001\002\311:v";
client-hostname "wap1";
}
lease 192.168.1.19 {
starts 0 2010/07/04 02:14:33;
ends 0 2010/07/04 04:14:33;
binding state active;
next binding state free;
hardware ethernet 00:1f:3c:c1:bf:28;
uid "\001\000\037<\301\277(";
client-hostname "zephyr";
}
lease 192.168.1.22 {
starts 0 2010/07/04 03:07:54;
ends 0 2010/07/04 05:07:54;
binding state active;
next binding state free;
hardware ethernet 00:50:da:b9:7e:b6;
uid "\001\000P\332\271~\266";
client-hostname "wap2";
}
lease 192.168.0.244 {
starts 0 2010/02/14 20:17:42;
ends 0 2010/02/14 20:57:07;
tstp 0 2010/02/14 20:57:07;
binding state free;
hardware ethernet 00:1b:21:19:ec:63;
uid "\001\000\033!\031\354c";
}
lease 192.168.0.41 {
starts 6 2010/02/20 04:50:56;
ends 6 2010/02/20 04:56:11;
tstp 6 2010/02/20 04:56:11;
binding state free;
hardware ethernet 00:0c:29:87:40:fc;
}
lease 192.168.0.243 {
starts 3 2010/02/24 20:22:02;
ends 3 2010/02/24 21:11:15;
tstp 3 2010/02/24 21:11:15;
binding state free;
hardware ethernet 00:1b:21:19:ec:63;
}
lease 192.168.0.240 {
starts 3 2010/02/24 21:25:07;
ends 3 2010/02/24 23:25:07;
tstp 3 2010/02/24 23:25:07;
binding state free;
hardware ethernet 08:00:27:54:7e:f8;
}
lease 192.168.0.238 {
starts 0 2010/03/14 19:42:05;
ends 0 2010/03/14 21:42:05;
tstp 0 2010/03/14 21:42:05;
binding state free;
hardware ethernet 08:00:27:ec:4f:9e;
}
lease 192.168.0.75 {
starts 3 2010/03/17 16:10:27;
ends 3 2010/03/17 18:10:27;
tstp 3 2010/03/17 18:10:27;
binding state free;
hardware ethernet 00:0c:29:79:87:5b;
uid "\001\000\014)y\207[";
}
lease 192.168.0.235 {
starts 1 2010/03/22 03:38:58;
ends 1 2010/03/22 05:38:58;
tstp 1 2010/03/22 05:38:58;
binding state free;
hardware ethernet 00:0c:29:55:52:0e;
}
lease 192.168.0.234 {
starts 1 2010/03/22 03:40:23;
ends 1 2010/03/22 05:40:23;
tstp 1 2010/03/22 05:40:23;
binding state free;
hardware ethernet 08:00:27:81:b6:d8;
}
lease 192.168.0.242 {
starts 5 2010/04/30 04:33:41;
ends 5 2010/04/30 06:33:41;
tstp 5 2010/04/30 06:33:41;
binding state free;
hardware ethernet 00:24:21:61:b3:3d;
uid "\001\000$!a\263=";
}
lease 192.168.0.241 {
starts 5 2010/05/28 21:27:45;
ends 6 2010/05/29 21:27:45;
tstp 6 2010/05/29 21:27:45;
binding state free;
hardware ethernet 08:00:27:0c:9e:0d;
}
lease 192.168.0.233 {
starts 5 2010/06/04 22:03:02;
ends 6 2010/06/05 00:03:02;
tstp 6 2010/06/05 00:03:02;
binding state free;
hardware ethernet 00:0c:29:c9:68:26;
uid "\001\000\014)\311h&";
}
lease 192.168.0.230 {
starts 2 2010/06/15 22:17:47;
ends 3 2010/06/16 00:17:47;
tstp 3 2010/06/16 00:17:47;
binding state free;
hardware ethernet 00:24:1d:20:64:12;
}
lease 192.168.0.237 {
starts 1 2010/06/21 21:51:50;
ends 1 2010/06/21 21:53:50;
tstp 1 2010/06/21 21:53:50;
binding state free;
hardware ethernet e1:6c:d6:ae:52:90;
uid "\001\341l\326\256R\220";
}
lease 192.168.0.236 {
starts 1 2010/06/21 21:51:51;
ends 1 2010/06/21 21:53:51;
tstp 1 2010/06/21 21:53:51;
binding state free;
hardware ethernet e9:eb:b3:a6:db:3c;
uid "\001\351\353\263\246\333<";
}
lease 192.168.0.15 {
starts 4 2010/06/24 01:22:30;
ends 4 2010/06/24 03:22:30;
tstp 4 2010/06/24 03:22:30;
binding state free;
hardware ethernet 00:0c:29:ad:ad:eb;
}
lease 192.168.0.231 {
starts 5 2010/06/25 21:53:01;
ends 5 2010/06/25 23:53:01;
tstp 5 2010/06/25 23:53:01;
binding state free;
hardware ethernet 00:24:1d:20:64:12;
uid "\001\000$\035 d\022";
}
lease 192.168.0.232 {
starts 6 2010/07/03 20:45:41;
ends 6 2010/07/03 22:45:41;
tstp 6 2010/07/03 22:45:41;
binding state free;
hardware ethernet 00:1f:d0:81:7e:37;
uid "\001\000\037\320\201~7";
}
lease 192.168.0.93 {
starts 0 2010/07/04 02:32:44;
ends 0 2010/07/04 04:32:44;
binding state active;
next binding state free;
hardware ethernet 00:11:24:d6:92:d8;
client-hostname "powerbook";
}
lease 192.168.0.239 {
starts 0 2010/07/04 02:55:13;
ends 0 2010/07/04 04:55:13;
binding state active;
next binding state free;
hardware ethernet 00:1b:21:19:ec:63;
client-hostname "mythbox3";
}
lease 192.168.0.82 {
starts 0 2010/07/04 03:10:12;
ends 0 2010/07/04 05:10:12;
binding state active;
next binding state free;
hardware ethernet 00:e0:b8:38:ad:8e;
uid "\001\000\340\2708\255\216";
client-hostname "bsdtop";
}
lease 192.168.1.23 {
starts 0 2010/07/04 03:11:56;
ends 0 2010/07/04 05:11:56;
binding state active;
next binding state free;
hardware ethernet 00:01:02:c9:3a:76;
uid "\001\000\001\002\311:v";
client-hostname "wap1";
}
lease 192.168.1.19 {
starts 0 2010/07/04 03:14:33;
ends 0 2010/07/04 05:14:33;
binding state active;
next binding state free;
hardware ethernet 00:1f:3c:c1:bf:28;
uid "\001\000\037<\301\277(";
client-hostname "zephyr";
}
lease 192.168.0.93 {
starts 0 2010/07/04 03:32:44;
ends 0 2010/07/04 05:32:44;
binding state active;
next binding state free;
hardware ethernet 00:11:24:d6:92:d8;
client-hostname "powerbook";
}
lease 192.168.0.239 {
starts 0 2010/07/04 03:55:13;
ends 0 2010/07/04 05:55:13;
binding state active;
next binding state free;
hardware ethernet 00:1b:21:19:ec:63;
client-hostname "mythbox3";
}

Here is the process still being displayed in ps:
root 4356 0.0 0.1 3316 1060 ?? Is 6Jun10 0:00.02 /usr/local/sbin/dhcpleases -l /var/dhcpd/var/db/dhcpd.leases -d adamsnet -p /var/run/dnsmasq.p

Sadly I think we may need to reopen this problem for feedback :(.

Also available in: Atom PDF