Hostnames in Device list or ARP list?

Discussion in 'Tomato Firmware' started by WRD - EasyTomato, Jul 9, 2012.

  1. WRD - EasyTomato

    WRD - EasyTomato Networkin' Nut Member

    Does anyone know why devices with Static IP address asignments don't have hostnames?

    What about the the ARP list (Tools->WOL)? That doesn't seem to have any hostnames at all.

    If anyone could shed some light on either of these questions I'd really appreciate it. Bonus points if you've got idea of how to get static hostnames (provided they exist of course)!

  2. Diexgo

    Diexgo Serious Server Member

    I can see the hostnames in my WRT54GS with tomato v1.28.7633.3-Toastman. I have set some machines with static IP, and fill in the name i wanted in "Basic --> Static DHCP/ARP" under the Hostnames column. When some of these machines are connected, i can see the hostname in "Status --> Device List". It is also shown in "Tools --> WOL"
  3. WRD - EasyTomato

    WRD - EasyTomato Networkin' Nut Member

    Yeah I can fill them in manually as you said, but those statically assigned computers have hostnames and I want em!! :) (automatically)
  4. koitsu

    koitsu Network Guru Member

    I wish I knew what you were talking about. Proof is provided in my below two screenshots.

    The hostnames are assigned when you enter them in the GUI itself (see first screenshot; you actually enter them there). They also correlate with DNS hostnames for your LAN, assuming the DNS server/resolver you use is the router. They do not need to be FQDNs; shorthand is actually the proper way (dnsmasq will answer for both the shorthand and FQDN versions). Proof of the latter:

    $ cat /etc/resolv.conf
    search home.lan
    $ host koitsu.home.lan
    koitsu.home.lan has address
    $ host koitsu
    koitsu.home.lan has address
    $ host koitsu.
    koitsu has address
    (Note the trailing dot in the last "host" command; it's to stop use of the "search" path order from resolv.conf)

    Attached Files:

  5. WRD - EasyTomato

    WRD - EasyTomato Networkin' Nut Member

    Some hostnames get pulled automatically in the device list. I know I can manually set any hostname, but we need to get as many automatically as possible.

    It's more or less the same question that is asked in the post below (oops), only I'd like to know why it can't automatically get hostnames form static IPs (not static ARP assignments from the router)? Is there a way to do this? I'd love to be able to pull the name and put it in the list for all devices.

    Also Apple products and some andoid devices don't show a hostname even with a dynamic IP? Anyway way to get these? (do they even have them set?)

  6. koitsu

    koitsu Network Guru Member

    For any kind of IP address -> FQDN ("name") resolution to happen, there has to be DNS. I'm pretty sure you know this (it's implied by some of your statements). For those IP->FQDN mappings to occur (they're called PTR records, by the way), there has to be a DNS server that is configured with a list -- a manually maintained list -- of what all those PTR records point to. But for things to be consistent, you also need to create A records.

    So what you're talking about is purely 100% DNS-related. That's it. You're asking about DNS. And I hope you know a bit about DNS -- if not, before proceeding you should probably read up on it + understand how it works a bit more. If so, fantastic.

    dnsmasq on TomatoUSB can do this for you. However, it is quite crude compared to an actual DNS server (such as ISC BIND / named), but it does work. I will also warn you that the syntax for some of this is cryptic, and there is no "pretty GUI" for it at this time. If you want a purely GUI-maintained method, then static DHCP (what you incorrectly call "static ARP" -- static ARP is a different thing, please don't call static DHCP allocations "static ARP". There is a world of difference) is your best choice. It will take care of all the annoyances for you.

    Else, you need to take the time to read the full man page documentation for dnsmasq to understand what options do what and what their syntaxes are.

    What you want is under Advanced -> DHCP/DNS, specifically the textarea labelled Dnsmasq Custom configuration. This is where you can set up manual DNS entries for individual IP addresses (e.g. will resolve to "bob" or "bob.home.lan", and "bob" or "bob.home.lan" will resolve to dnsmasq has a single directive, host-record, that lets you set up both the A record and the PTR record simultaneously. Here's an example of what you'd put in there for some hosts:

    ...and so on.

    In actual DNS zones (assuming you can read/understand those), these equate to the following:

    zone.home.lan zone file:
    bob.                  IN A
    bob.home.lan.          IN A
    moms-laptop.           IN A
    moms-laptop.home.lan.  IN A
    vmware-linux.          IN A
    vmware-linux.home.lan. IN A zone file:
    100    IN PTR bob.home.lan.
    101    IN PTR moms-laptop.home.lan.
    130    IN PTR vmware-linux.home.lan.
    dnsmasq seems to use a TTL of 0 for all of its records (that's extremely dangerous, BTW. It should really be using a TTL of 1. There are known resolvers which break horribly when using a TTL of 0. We found this out at my previous job, where our enterprise-grade HTTP caching proxies actually broke (cached DNS indefinitely) when a customer used a TTL of 0 in their zones. I should really talk to the dnsmasq author about changing the default to 1).

    You might be asking why there are "two entries" per IP address, e.g. "bob" and "bob.home.lan". The reason has to do with dnsmasq's crappy support for FQDNs and the local domain name. The "Domain name" field under Basic -> Identification is used but only on some things, not all. I've found it to be very inconsistent in where it gets used by dnsmasq. The dnsmasq documentation does reflect this fact, however. Even the expand-hosts option states it doesn't apply to things like CNAMEs (and that bit me on my own network at one point, sigh).

    PTR records always return the FQDN, even for entries in static DHCP which are configured as "foo". But for forward records (A records), it seems to vary.

    If you're going to ask me next: "do I have to do this for every single IP?", the answer is yes. Welcome to how DNS works around the entire Internet -- there is always someone who maintains this stuff (I'm a UNIX SA so I happen to be one such person).

    Finally, and above all else: I make no guarantees that every part of the TomatoUSB GUI uses DNS resolution (PTR record lookup) when displaying something with an IP address.

    I hope this answers your question, or at least gets you on the right path.
  7. WRD - EasyTomato

    WRD - EasyTomato Networkin' Nut Member

    So before I dive into what you wrote on DNS stuff(thanks for the effort btw), I'm still a little confused on the logic here.

    You say
    But with a freshly flashed and nvram cleared Tomato, when I boot up and go to the device list I see device names filled out (screenshot attached).

    I've set nothing manually in the router and but I can see the computer's name (at least windows machines). Seems to me the router must have resolved the hostname on it own as I didn't tell it anything.

  8. koitsu

    koitsu Network Guru Member

    That may be caused by use of DHCP. DHCP clients can send their supposed hostname to the server, and the server (DHCP server) can do whatever it wants with it. dnsmasq may end up injecting those hostnames into its local list of records to return for DNS. That's the only theory I can think of. WINS is almost certainly not involved here.

    And that is purely, 100%, speculative on my part, and also means that the behaviour is 100% based on the DHCP client sending along the relevant DHCP option portion of the packet.
  9. bigbug

    bigbug Serious Server Member

    Hi koitsu,

    I'm using Shibby's version of tomato. In my DHCP device list (your first pic), the hostnames showed up automatically without my entry. But under WOL list, the hostnames are all blank as yours.

    My guess is that these 2 programs were written by different people. In the device list screen the author has added the function to retrieve the hostnames, while the author of the WOL screen didn't bother. What do you think? Otherwise I'm interested to know how I can get the hostnames display in the WOL list.

  10. koitsu

    koitsu Network Guru Member

    Speculative (meaning I would need to look at actual packet captures to confirm this is what's going on):

    The hostnames themselves might be being handled by dnsmasq (which isn't just a DNS proxy daemon, it also is a DHCP server for handing out IPs on your lan) as part of the DHCP negotiation protocol.

    DHCP clients (your computers, laptops, etc.) can transmit their own hostname to the DHCP server (dnsmasq) as part of the DHCP Option header within DHCP packets (specifically Option 12 per RFC 2132. This is exactly what the DHCP client for *IX called dhclient uses for its dhcp-client-identifier config item). Again: the DHCP client sends to the hostname it wants to the DHCP server (which can, believe it or not, either honour or reject that request).

    Assuming the DHCP server honours Option 12, the string provided would be registered within dnsmasq as part of DNS, i.e. there becomes an IP-to-hostname mapping available via DNS resolution (PTR record).

    This may be how your system hostnames are appearing under Basic -> DHCP/ARP/BW without any static entries assigned. This is different (in methodology per se) than if you were to enter the hostname yourself in the GUI.

    I have personally never tried adding a static DHCP entry without a hostname specified.

    That said -- it may be that the code used to generate the hostnames under Tools -> WOL gets the hostnames from what was entered in the Hostname field of Basic -> DHCP/ARP/BW and not via actual DNS resolution. I would need to look at the underlying code for the Tools -> WOL feature to determine how/where it gets the hostname from.

    You could test my theory by filling out one of the Hostname fields for a system under Basic -> DHCP/ARP/BW (put in a hostname like "testingtomato") then see if it shows up under Tools -> WOL. If it does, then it's safe to say that the code for Tools -> WOL doesn't use DNS for resolution but instead keys off of the Hostname field in Basic -> DHCP/ARP/BW (which as I described above, is not the same thing as if the DHCP client submits Option 12).

    The solution to the problem might seem obvious: "okay, so just change the code to do DNS lookups for the IPs shown and voila!" Yes, that would functionally work, however there are edge cases where that is a Very Bad Item. Consider the situation where someone has disabled dnsmasq (this is somewhat common believe it or not) -- that means all DNS requests would get punted upstream to their ISP, so their ISP would start seeing DNS resolution requests for PTR records such as when quite honestly those type of lookups shouldn't make it out across the WAN. So as you can see, the solution, despite being "obvious", can also be fairly tricky depending on how the router is configured by the user.

    Sorry for making this out to be more complex than it might really be, but all these kinds of edge cases have to be considered.

    Anyway, can you do me a favour? Telnet or SSH into your router, log in, and provide output from the following two commands for me: cat /etc/dnsmasq/hosts/hosts and cat /etc/dnsmasq/dhcp/dhcp-hosts. Please also tell me which IP addresses DO NOT have the Hostname field filled out under Basic -> DHCP/ARP/BW.

    If dnsmasq populates either of those files with the Option 12-provided string/hostname, then I would say Tools -> WOL could be improved/fixed to provide the hostname without using DNS lookups (which would be the Right Thing(tm)).
  11. bigbug

    bigbug Serious Server Member

    I tried, the first command returns all IP addresses and host names. The second command returns nothing. What does that tell you?
  12. koitsu

    koitsu Network Guru Member

    It tells me that Tools -> WOL could indeed be improved/fixed to provide the DHCP client-provided hostname (via Option 12) without using DNS lookups to accomplish the task. :)

    You know the mantra in the open-source world, right? "Patches are welcome..."
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice