Project

General

Profile

Bug #3176

Hosts file corrupted when using "Register DHCP leases in DNS forwarder"

Added by Rene Klomp almost 7 years ago. Updated 4 months ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
DNS Forwarder
Target version:
-
Start date:
09/03/2013
Due date:
% Done:

100%

Estimated time:
Affected Version:
2.1
Affected Architecture:
amd64

Description

When the option "Register DHCP leases in DNS forwarder" is enabled the Host Overrides are not working correctly. They are corrupted/truncated.

Disabling the option will solve the problem and give a good hosts file.

Problem is on 2.1-RC1 (amd64) built on Tue Aug 27 16:56:42

corrupted-hosts (1.29 KB) corrupted-hosts Adam Thompson, 10/08/2013 12:08 PM
fixed-hosts (811 Bytes) fixed-hosts Adam Thompson, 10/08/2013 12:08 PM

History

#1 Updated by Phillip Davis almost 7 years ago

I am running:
2.1-RC1 (i386)
built on Sun Sep 1 01:17:51 EDT 2013
FreeBSD 8.3-RELEASE-p10

"Register DHCP leases in DNS forwarder" is enabled. I added some test Host Overrides, they appeared in /etc/hosts OK. Then I connected my new phone to the network. It got a DHCP lease and appears down the end of /etc/hosts OK.
@10.49.80.254 test-entry.np.net.inf.org test-entry
10.49.80.254 test-entry1.np.net.inf.org test-entry1
  1. dhcpleases automatically entered
    10.49.80.214 android-92ef1893ad40d810.np.net.inf.org android-92ef1893ad40d810 # dynamic entry from dhcpd.leases@

What pfSense version are you on?
How do you make the problem happen?
Post the corrupted/truncated /etc/hosts.

#2 Updated by Rene Klomp almost 7 years ago

What pfSense version are you on?

Like in issue description: 2.1-RC1 (amd64) built on Tue Aug 27 16:56:42

How do you make the problem happen?

It just happens. When Register DHCP leases in DNS forwarder is on. Otherwise it does not happen.

Post the corrupted/truncated /etc/hosts.

vi /etc/hosts
127.0.0.1       localhost 
10.10.0.1       xxx
192.168.1.9     xxx
192.168.1.6     xxx
192.168.1.11    xxx
192.168.1.13   xxx
192.168.2.32   xxx
192.168.1.22    xxx
10.168^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
# dhcpleases automatically entered
10.10.255.239  xxx           # dynamic entry from dhcpd.leases
10.10.255.173   xxx         # dynamic entry from dhcpd.leases
...
...

#3 Updated by Rene Klomp almost 7 years ago

Cant reproduce the problem anymore. When i disabled the "DHCP leases in DNS forwarder" my problem was gone but after reenabling it the problem does not come back.

#4 Updated by Chris Buechler almost 7 years ago

  • Status changed from New to Feedback

haven't seen this anywhere or heard of it elsewhere

#5 Updated by Chris Buechler almost 7 years ago

  • Target version deleted (2.1)

#6 Updated by Adam Thompson almost 7 years ago

I just got bitten by this as well, running 2.1-RELEASE (i386). See attached.
I also can verify that turning off the checkbox clears up the corruption, but continues to register dhcpleases in /etc/hosts!
Turning the checkbox back on then makes no difference...

I also tried manually editing /etc/hosts to remove the crap, rebooting, and it was corrupt again upon reboot.

#7 Updated by Jason Crowley over 6 years ago

I've experienced this problem as well in 2.1-RELEASE (i386). First I got the non-ascii characters like Rene Klomp. Then after restarting dnsmasq, the top part of my hosts file (above "# dhcpleases automatically entered") was simply truncated around the 1024-character mark. I followed the following procedure to alleviate the problem.
  1. Disabled "Register DHCP leases in DNS forwarder"
  2. Verified /var/etc/hosts looked correct. I still had the DHCP-lease hosts in it. and truncated information above "# dhcpleases automatically entered"
  3. Restarted dnsmasq
  4. Verified /var/etc/hosts file looked correct. It was good.
  5. Enabled "Register DHCP leases in DNS forwarder"
  6. Verified /var/etc/hosts looked correct. It was still good.

#8 Updated by Daniel Sheridan over 6 years ago

I'm seeing this too (on 2.0). While the corruption is happening, there are two /usr/local/sbin/dhcpleases processes running:

28599  ??  Is     0:00.01 /usr/local/sbin/dhcpleases -l /var/dhcpd/var/db/dhcpd.leases -d office.adelard.com -p /var/run/dnsmasq.pid -h /var/etc/hosts
30002  ??  S      0:00.10 /usr/local/sbin/dnsmasq --local-ttl 1 --all-servers --rebind-localhost-ok --stop-dns-rebind --dns-forward-max=5000 --cache-size=10000 --dhcp-hostsfile=/var/etc/hosts
32398  ??  Is     0:07.55 /usr/local/sbin/dhcpleases -l /var/dhcpd/var/db/dhcpd.leases -d office.adelard.com -p /var/run/dnsmasq.pid -h /var/etc/hosts
34697  ??  Ss     0:00.01 /usr/local/sbin/dhcpd -user dhcpd -group _dhcp -chroot /var/dhcpd -cf /etc/dhcpd.conf em0 em3

After switching off the "Register DHCP leases in DNS forwarder", only one:
[2.0.3-RELEASE][admin@pfsense.office.adelard.com]/var/etc(39): ps xawww|grep dhcp
 9351  ??  Ss     0:00.06 /usr/local/sbin/dhcpd -user dhcpd -group _dhcp -chroot /var/dhcpd -cf /etc/dhcpd.conf em0 em3
23543  ??  Ss     8:55.92 /usr/sbin/syslogd -s -c -c -l /var/dhcpd/var/run/log -f /var/etc/syslog.conf
32398  ??  Is     0:07.56 /usr/local/sbin/dhcpleases -l /var/dhcpd/var/db/dhcpd.leases -d office.adelard.com -p /var/run/dnsmasq.pid -h /var/etc/hosts

And after switching it back on, still only one:
12040  ??  Ss     0:00.01 /usr/local/sbin/dhcpleases -l /var/dhcpd/var/db/dhcpd.leases -d office.adelard.com -p /var/run/dnsmasq.pid -h /var/etc/hosts
13517  ??  S      0:00.02 /usr/local/sbin/dnsmasq --local-ttl 1 --all-servers --rebind-localhost-ok --stop-dns-rebind --dns-forward-max=5000 --cache-size=10000 --dhcp-hostsfile=/var/etc/hosts
16904  ??  Ss     0:00.00 /usr/local/sbin/dhcpd -user dhcpd -group _dhcp -chroot /var/dhcpd -cf /etc/dhcpd.conf em0 em3
23543  ??  Ss     8:55.93 /usr/sbin/syslogd -s -c -c -l /var/dhcpd/var/run/log -f /var/etc/syslog.conf

#9 Updated by Andrew Newell over 6 years ago

Sorry, I don't have much to add as far as content, but I would like to say that my pfSense box has had the same behavior as everyone else in this thread. Specifically I was trying to resolve a static DHCP entry which was inserted into DNS using the checkbox in the DNS forwarder page, and it was never entered into the hosts file, and sometimes while trying to fix other hosts it would corrupt the file with the ^@ stuff that other people have had in here.
Here's my basic box info:

@
Version 2.1-RELEASE (amd64)
built on Wed Sep 11 18:17:48 EDT 2013
FreeBSD 8.3-RELEASE-p11

You are on the latest version.
Platform pfSense
CPU Type Intel(R) Xeon(TM) CPU 3.20GHz
4 CPUs: 2 package(s) x 1 core(s) x 2 HTT threads
Uptime 57 Days 21 Hours 22 Minutes 29 Seconds
@

Thanks for your hard work!

#10 Updated by Andrew Newell over 6 years ago

I am unfamiliar with this forum so I apologize for my messed up formatting.

#11 Updated by Chris Buechler almost 5 years ago

think this may be related to some edge case where dhcpleases runs multiple times, though I'm not seeing how that could happen, and launching multiple instances on 2.2.4 doesn't make it happen. Granted, I'm looking at 2.2.4 and 2.3, could have been fixed since then.

anyone still encountering this?

#12 Updated by Luiz Souza over 4 years ago

Yeah, this is fixed in the last version of dhcpleases.

#13 Updated by Renato Botelho over 4 years ago

  • Assignee set to Luiz Souza
  • % Done changed from 0 to 100

#14 Updated by Chris Buechler over 4 years ago

  • Status changed from Feedback to Resolved

#15 Updated by Erik Fonnesbeck 4 months ago

Just had something that looks exactly like this happen in 2.4.4-RELEASE-p3 with my overrides list truncated in the middle of an entry (still using the dnsmasq DNS forwarder). Unfortunately, I didn't check to see if there were any duplicate processes before I tried changing configuration to try fixing it (I removed the truncated host override in the GUI and re-added it, thinking maybe there was a configuration error). However, I am getting the duplicate "dhcpleases automatically entered" sections as reported by some. The first copy doesn't seem to update with added or removed leases until the DNS forwarder is restarted, as it only has a copy of the entries from the time it was restarted.

It's possible the truncation is a result of either a race condition or just simply being confused by the duplicate entries as it adds or removes entries.

Also available in: Atom PDF