We have built a LibreNMS instance where we have our /etc/hosts file containing private IP addresses and hostnames without FQDN. When adding a new device to LibreNMS, we enter the hostname as it is entered in /etc/hosts and LibreNMS does it’s magic. Polling works fine, with each device being accessed by it’s private IP address as noted in /etc/hosts. However we noticed in the logs that for some reason the “resolved IP” for the device comes up with the publicly resolved IP address of our FQDN.
Why wouldn’t the content of /etc/hosts not override the public DNS result?
Short answer: because it doesn’t work that way.
I auto generate DNS entries, checkout hosts2bind-zone-file and running bind locally.
We’ll give it a look. Thanks!
You cannot look up the reverse IP for entries in /etc/hosts.
You would need to create a DNS server, it can be on the same server as LibreNMS if you like.
OK, maybe I should be looking at/asking this another way.
In the device ov erview page there is an item called “Resolved IP” What is the IP being resolved from? If it was the hostname in the initial config and matching an entry in .etc/hosts, then we should get our private IP and we do see that IP being polled properly. The “Resolved IP” field however is displaying the IP address of our to level FQDN. LibreNMS has resolved properly the device hostname entered into /etc/hosts in advance of adding the device as it does every polling cycle, but also as part of it’s polling cycle LibreNMS is looking for something else as part of the “Resolved IP” field that answers back as our FQDN. As a result, all devices have the same “Resolved IP” displaying in the Overview tab, even though they are all being polled at different private IPs (correctly resolved from /etc/hosts).
So, what source information is used as input to the IP resolution request for “Resolved IP” field?
I believe you are confusing DNS lookup and reverse IP lookup. Dns lookup can be overridden with /ets/hosts. It does nothing for reverse IP lookup which will query DNS. The only way I know to get around this is to setup your own DNS server. Again, I might recommend hosts2bind-zone-file and running bind locally.