HowTo setup Local DNS/DHCP Plugin

    • Offizieller Beitrag

    not sure if it really matters but it lets you match the CNAME and the primary name, so if hostname is 'foobar' and you put additionals as 'foobar' it takes it with no issues

    That was one place where there isn't much error checking. You can also put the same name in for the cname over and over (foobar, foobar, foobar). And when it does a check for uniqueness of the cnames, it doesn't break the string apart to see if there is duplicates. It just checks the whole string. I guess it wouldn't be hard to see if the name is the cnames field. Trying to avoid implementing the cnames check though :D


    Let me know what you find about the segfaulting and I will try to fix that.

    omv 7.0.4-2 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.10 | compose 7.1.2 | k8s 7.0-6 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • Still tracking down what it is that makes the difference here, but here's the output of systemctl status dnsmasq.service immediately after running omv-mkconf dnsmasq:


    At this point I've narrowed it down to something in /etc/dnsmasq.d/omv.conf, but I still can't place what. Running a diff on the two files, the only things that are actively different are the CNAME entries - everything else is configured identically, and most of the CNAME stuff is just the order it's running in.

  • That was one place where there isn't much error checking. You can also put the same name in for the cname over and over (foobar, foobar, foobar). And when it does a check for uniqueness of the cnames, it doesn't break the string apart to see if there is duplicates. It just checks the whole string. I guess it wouldn't be hard to see if the name is the cnames field. Trying to avoid implementing the cnames check though :D
    Let me know what you find about the segfaulting and I will try to fix that.


    Okay, I'm at a total loss on the segfault. Something is really bizarre here, and it's specifically to do with the CNAME stuff. As I said, the problem file is /etc/dnsmasq.d/omv.conf, and when I compare the two files (old one, directly stolen from my original OMV 2.x install by the way, and new one generated by omv-mkconf dnsmasq) everything except for the CNAMEs is identical; most of the CNAMEs are just in different order.


    On the off chance I'd flubbed something I went through the list looking for malformed CNAME entries, and didn't find any. I also manually added a CNAME entry to the one static item that didn't have one (from the first report I made) in case that was it, and it didn't make a difference.


    Next, I deleted about 2/3s of the CNAME entries, tried again and still no dice. Regenerated the config with omv-mkconf, deleted the third of the entries I'd left previously and left the 2/3s I'd deleted, no change. Deleted all the CNAME entries entirely and it started right up. I also checked for weird whitespace and didn't find any in the generated config.


    Here's where it gets weird. I regenerated the config again, inserted all the CNAME entries from my old 2.x omv.conf file, and deleted all the entries that omv-mkconf generated... and it works. I'm completely baffled by it. The other thing is, when I do a diff on the old file with the new file after changing the CNAME entries to match, the only differences are extra blank lines between sections in the old file that aren't there in the new.


    As far as I can tell there's really almost no difference between the generated CNAME entries (beyond their specific content, but they're formed the same way) and the ones from the old 2.x file. Same whitespace (that is, none) per line, same formatting, just... one works, the other doesn't.


    If you want me to try something else, I gladly will. I need to check but I think I have an image of the entire OMV 2.x SD card (that install was on the same RPi) so I can probably even dig out the 2.x config.xml section for comparison if you need it.

  • Random thought. I don't recall when, in the middle of all this, that I uploaded openmediavault-dnsmasq 3.1.2, but I uploaded through the update management interface as opposed to uninstalling 3.1.1 and reinstalling 3.1.2. Is it possible that might be causing this CNAME mess? Because 3.1.2 also was causing a socket error (see below) when I tried to login to the web UI. I'm reinstalling it now to see if that fixes the issue, but an apt-get purge openmediavault-dnsmasq allowed me to login to the web UI with no other changes.


    EDIT: Alright, purged 3.1.2 like I said, cleared the 3.1.2 .deb out of the cache, re-uploaded 3.1.1, reinstalled it through the web UI, and the CNAME issue is still there. However, I'm not getting the socket error, so there's that. Wish I had better news on the segfault, but...


    Socket error:


    • Offizieller Beitrag

    Weird. The config file creation (omv-mkconf dnsmasq) hasn't changed since OMV 2.x (other than using variable for config and adding newline flag for xmlstarlet version difference).


    The engined error was a typo in my new code. Fixed in 3.1.3 I would install it from the command line just in case.

    omv 7.0.4-2 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.10 | compose 7.1.2 | k8s 7.0-6 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • Weird. The config file creation (omv-mkconf dnsmasq) hasn't changed since OMV 2.x (other than using variable for config and adding newline flag for xmlstarlet version difference).


    The engined error was a typo in my new code. Fixed in 3.1.3 I would install it from the command line just in case.

    That's the other odd thing too, it didn't happen at once. From what I can tell, when you add a Static Entry, after each one it goes, updates the config.xml, then regenerates the config, yes? I'm 99% positive that it was working for at least the first few entries, because I tested it (mostly because I got tired of remembering to type IPs instead of hostnames) and was able to access hosts via web browser.


    I can go in and clear the XML entries one at a time to see if I can figure out what happened once my daughter's in bed.

    • Offizieller Beitrag

    From what I can tell, when you add a Static Entry, after each one it goes, updates the config.xml, then regenerates the config, yes?

    I just noticed that I never finished porting the function that is executed after each new entry is added. So, I think it may be hup'ing the process instead of restarting it. Let me look at that in a little bit.

    omv 7.0.4-2 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.10 | compose 7.1.2 | k8s 7.0-6 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

    • Offizieller Beitrag

    I can go in and clear the XML entries one at a time to see if I can figure out what happened once my daughter's in bed.

    Would it be bad to just reload dnsmasq each time an entry is added/edited? It would still be restarted when a setting was changed.

    omv 7.0.4-2 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.10 | compose 7.1.2 | k8s 7.0-6 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • Would it be bad to just reload dnsmasq each time an entry is added/edited? It would still be restarted when a setting was changed.


    Reload configs as opposed to restart you mean? Would make a lot of sense to me.


    Work was a pain in the ass today so I haven't even had a chance to try 3.1.3 yet for you; I'm also beating my head against a Pi Zero setup for a RetroPie that my wife wanted me to try setting up, so once I get that to stop being a bitch, I should be able to poke at it.

  • So, to report on the changes to date. For one, I decided to be a rebel without a clue and updated to 3.1.3 by uploading through the Update Management screen and doing an upgrade. Worked flawlessly, no errors on web UI or SSH (which may or may not have been related to the 3.1.2 issue).


    Went into the Static Entries tab, created a test entry with no CNAME and a bogus IP address (for my network, at least) and clicked Save; UI threw an error indicating that the systemctl restart dnsmasq.service command had failed, referring me to journalctl -xn and so on. Not sure on the order of operations, but since it was restarting to apply, I would say that means the CNAME issue is resolved as well.


    For the Static Entries thing with reload vs. restart, is there any particular reason (including "massive rewrite not worth heartburn") we can't have the entries generate an Apply prompt like changes to the Settings tab causes? It's of limited utility overall - the only time you're really going to mass-update is when you're setting up or adding a new clutch of VMs or something somewhere - but adding hosts vpn0 through vpn9 when I set up OpenVPN on my EdgeRouter so I didn't have to wait for SSH to time out on DNS requests was on the tedious end.


    I did get a chance to go into my old 2.x image that the original config files came from and I can't see anything at all different between the entries in /etc/openmediavault/config.xml between the two versions. Also, you mentioned the possibility that it's HUPing instead of restarting for some reason, but the problem occurs when I manually do systemctl start dnsmasq.service with the 3.x generated /etc/dnsmasq.d/omv.conf in place, but the 2.x generated loads fine.


    The only thing that I'm seeing anywhere different - and I didn't mention it because replacing the file in question didn't change anything - is that the etc/dnsmasq-hosts file now has three spaces, instead of one tab, separating the IP and the hostname. Can't see why that'd make a difference, but it's the only oddity I've come across that I didn't mention. Whether it's spaces or tabs in that file, it still fails to start with 3.x's omv.conf, and starts right up with 2.x's omv.conf. Permissions and ownership are the same on both files.

    • Offizieller Beitrag

    For the Static Entries thing with reload vs. restart, is there any particular reason (including "massive rewrite not worth heartburn") we can't have the entries generate an Apply prompt like changes to the Settings tab causes?

    If we use the Apply prompt, dnsmasq would have to be restarted and could not be reloaded -OR- dnsmasq would have to be reloaded when settings changed. Doesn't bother me which one but I would guess dnsmasq needs to be restarted when settings are changed.


    you mentioned the possibility that it's HUPing instead of restarting for some reason

    I noticed the Debian 8 systemd unit file HUPs the process when reloading. So, that shouldn't be the issue either.


    is that the etc/dnsmasq-hosts file now has three spaces, instead of one tab, separating the IP and the hostname

    This must be a difference in the new version of xmlstarlet on Debian 8? Not sure.


    it still fails to start with 3.x's omv.conf, and starts right up with 2.x's omv.conf

    All I can think is that it is a difference between dnsmasq 2.62 on Debian 7 and dnsmasq 2.72 on Debian 8. Probably means the config file format needs to be changed but I don't know what to change.

    omv 7.0.4-2 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.10 | compose 7.1.2 | k8s 7.0-6 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • If we use the Apply prompt, dnsmasq would have to be restarted and could not be reloaded -OR- dnsmasq would have to be reloaded when settings changed. Doesn't bother me which one but I would guess dnsmasq needs to be restarted when settings are changed.

    I would say go with Apply and do a restart. Honestly, at the moment you're waiting on the restart for every entry, so only having one wait for more than one entry would run smoother IMO.


    This must be a difference in the new version of xmlstarlet on Debian 8? Not sure.

    Maybe, but since it's not breaking anything that I can tell, probably not worth tracking down. Just mentioned it for completeness' sake.


    All I can think is that it is a difference between dnsmasq 2.62 on Debian 7 and dnsmasq 2.72 on Debian 8. Probably means the config file format needs to be changed but I don't know what to change.

    I don't see how, since I'm using a dnsmasq 2.62 omv.conf file as the one that works, and the configs generated seem to be identical.


    Here's the CNAME config for my Cisco access point from the old OMV 2.x file:


    Code
    cname=ap,argos
    cname=ap.shadowmatrix.org,argos.shadowmatrix.org


    Here's the same entry in the OMV 3.x generated file:



    Code
    cname=ap,argos
    cname=ap.shadowmatrix.org,argos.shadowmatrix.org


    Like I said, there's no difference even in terms of whitespace.


    I'm going to attach the two configs (omv.conf.old is from Wheezy, omv.conf.new is the problematic one from Jessie) for you to reference if you'd like. Meanwhile, I'm going to manually wipe the CNAME entries out and see if I can get DNSMasq to load without them, then start adding them and testing as I go to see if I can identify something specific.

  • FOUND IT!


    We can thank 3.1.1 for this one. In order to get the entire house up and running as quickly as possible, since it wouldn't let me leave blank CNAME entries, I was just coming up with something at random for the first few, then I decided I was just going to put in the A record hostname as a CNAME. So when I went to put in the IPMI entry for my primary fileserver, I did that - in this case "ipmi-korval" for both hostname and CNAME. I was re-entering without them, when it sort of hit me over the head that this was a potential bad thing. Tried doing it again, after the save it was dead with the segfault just like before. Edited the static entry to remove the CNAME, and after the save dnsmasq was running again.


    So, at heart it looks like a bug (feature? I could see it being intentional but you'd think it'd log something about it) in dnsmasq itself. You could maybe-possibly put a check in to reject a CNAME that matches the hostname, but that'd be a bandaid and now that 3.1.3 works fine with the blank CNAMEs, it shouldn't come up.


    Sorry to drive you batty on this man, but it sure feels good to figure out what was going on. Guess I'll wander on over to the dnsmasq folks and see if that's a reported bug.


    Let me know if there's anything else you need me to test and I'll get to it as soon as I can.

    • Offizieller Beitrag

    Let me know if there's anything else you need me to test and I'll get to it as soon as I can.

    Do you think I should change the code to restart when a new entry is added then?

    omv 7.0.4-2 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.10 | compose 7.1.2 | k8s 7.0-6 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • Do you think I should change the code to restart when a new entry is added then?

    Honestly, I think going the Apply route and doing a restart then would both be more uniform from a UI perspective, and less clunky feeling when adding multiple entries.


    Of course, I've added a lot of static entries in the past week, so that may be looming larger in my mind than it otherwise might, but I do remember wondering why it was different back when I first started using it.

    • Offizieller Beitrag

    think going the Apply route and doing a restart then would both be more uniform from a UI perspective, and less clunky feeling when adding multiple entries.

    I agree with that. Does dnsmasq "lose" dynamic dhcp leases when it is restarted?

    omv 7.0.4-2 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.10 | compose 7.1.2 | k8s 7.0-6 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

    • Offizieller Beitrag

    Nope, it stores them in /var/lib/misc/dnsmasq.leases so there won't be any loss on a restart. Which explains why I didn't lose any of my lease information when I cleared all the static entries last night.

    New version here

    omv 7.0.4-2 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.10 | compose 7.1.2 | k8s 7.0-6 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • New version here

    Excellent. Shall test out with the VPN entries I've been holding back because they're incredibly tedious. :)


    BTW, reported the bug with the CNAMEs to Simon Kelly of dnsmasq and he patched it. Unfortunately, it'll take a while for Debian to pick it up and bring it into Jessie, if ever.

  • No problems found so far; added 6 host entries (2 with CNAMEs just because) and edited three existing entries, all much more quickly than before, and watched systemctl status as I hit apply. Dnsmasq restarted without a hitch and all the changes are showing up in nslookup, so looks good to me.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!