Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
14
rated 0 times [  14] [ 0]  / answers: 1 / hits: 40592  / 3 Years ago, sat, october 16, 2021, 6:34:10

I had been struggling to get reverse DNS working using nslookup on Ubuntu 12.04. Here is the output of the nslookup command and the content of the different network related configuration files.



What could be the possible reason for the nslookup not working? Also, why do I need an internet connection to get a reverse lookup work for an entry in the /etc/hosts file?



training@guest1:/etc/network$ nslookup 192.168.1.101
Server: 8.8.8.8
Address: 8.8.8.8#53
server can't find 101.1.168.192.in-addr.arpa.: NXDOMAIN

training@guest1:/etc/network$ cat /etc/hosts
127.0.0.1 localhost
#127.0.1.1 Slave1
192.168.1.101 MyUbuntuLaptop

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

training@guest1:/etc/network$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.201
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4

training@guest1:/etc/network$ ping MyUbuntuLaptop
ping MyUbuntuLaptop (192.168.1.101) 56(84) bytes of data.
64 bytes from MyUbuntuLaptop (192.168.1.101): icmp_req=1 ttl=64 time=0.113 ms
64 bytes from MyUbuntuLaptop (192.168.1.101): icmp_req=2 ttl=64 time=0.222 ms

More From » resolution

 Answers
4

About private addresses


The IP addresses you're trying to resolve to names (the reverse lookups) are so-called private addresses, as defined in RFC 1918. In short, the following IPv4 range of addresses are defined in there:



  • 10.0.0.0/8

  • 172.16.0.0/12

  • 192.168.0.0/16


Opposed to public addresses, these aren't routed across the Internet and are solely to be used behind NAT in a private network. Many people are using this and therefore absolutely not unique. For this reason it is of no interest to have public DNS servers respond to reverse lookup requests for private ones.


Why it isn't working


Google and all other public DNS servers on the Internet aren't interested in private addresses as they're not routable over the Internet. So, basically, you're doing it wrong by asking a server totally not responsible for your network.


In case you were looking to override this with a local configuration like in /etc/hosts, this won't work:



Local DNS server


If you want to be able to do reverse lookups within your private LAN, then you'll have to set up your own DNS server with the appropriate records and have all your local clients using this DNS server. You may already be running one, but you didn't specify anything of it in your question and if you have, you appear not to be using it.


A quick all-in-one solution I can recommend is Dnsmasq Install Dnsmasq. It's a DHCP and DNS server in one1 with the advantage of using the hostname for DHCP also in DNS. From the manpage of dnsmasq is the following excerpt:



Dnsmasq accepts DNS queries and either answers them from a small,
local, cache or forwards them to a real, recursive, DNS server. It
loads the contents of /etc/hosts so that local hostnames which do not
appear in the global DNS can be resolved and also answers DNS queries
for DHCP configured hosts.



Setting up a complete Dnsmasq is a bit out of the scope here as it will replace your current DHCP server, which I don't know is an accepted solution. Anyway, for this part of the configuration this setting will be important:


domain=mydomain.lan,192.168.1.0/24,local

In which you tell it to serve the 192.168.1.0/24 network with short hostnames to use the mydomain.lan domain name and will not be forwarded to the upstream recursive DNS server. Result will be that a machine with the hostname myhost requesting a dynamic address will be automatically used in the local resolver and listens to queries myhost.mydomain.lan and the reverse pointer will resolve likewise.


I'm not aware of a "How do I set up Dnsmasq for a home network the good way?" question on this site. If you or others are interested, I'll be happy to Q&A it.


1 Actually even more, like TFTP server as well.


[#33100] Sunday, October 17, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
amelican

Total Points: 162
Total Questions: 116
Total Answers: 108

Location: Guam
Member since Mon, May 29, 2023
1 Year ago
amelican questions
Sun, Aug 14, 22, 01:26, 2 Years ago
Mon, Apr 24, 23, 18:12, 1 Year ago
Wed, Apr 5, 23, 04:30, 1 Year ago
Thu, Sep 1, 22, 02:14, 2 Years ago
Mon, Sep 19, 22, 23:08, 2 Years ago
;