1

I am having problem with viewing hostnames of devices located in my LAN. On my first laptop (Ubuntu 18.04 LTS Desktop edition) result of following command:

arp -a

Is exactly what I want:

X (192.168.56.243) at 40:a3:cc:99:2d:66 [ether] on wlan0
test-test-test (192.168.56.146) at 48:bf:6b:e3:bf:5a [ether] on wlan0
TP-Link_Archer_ (192.168.56.1) at 10:7b:44:40:61:70 [ether] on wlan0

Using nmap, I am able to scan my LAN using this command:

nmap -sn 192.168.56.0/24

And I get the perfect results with hostnames:

Starting Nmap 7.60 ( https://nmap.org ) at 2018-08-07 09:07 EDT
Nmap scan report for TP-Link_Archer_ (192.168.56.1)
Host is up (0.0054s latency).
Nmap scan report for ZZ (192.168.56.156)
Host is up (0.00045s latency).

However, on another laptop with Debian 9 x64 Minimal installed, the whole hostnames part is missing. Whenever I issue arp -a, I get the following:

? (192.168.56.243) at 40:a3:cc:99:2d:66 [ether] on wlan0
? (192.168.56.146) at 48:bf:6b:e3:bf:5a [ether] on wlan0
? (192.168.56.1) at 10:7b:44:40:61:70 [ether] on wlan0

Moreover, scanning with nmap -sn 192.168.56.0/24 produces this output:

Starting Nmap 7.60 ( https://nmap.org ) at 2018-08-07 09:17 EDT
Nmap scan report for 192.168.56.1
Host is up (0.0054s latency).
Nmap scan report for 192.168.56.156
Host is up (0.00045s latency).

I have honestly no idea what is going on, most likely I am missing something in Debian Minimal installation, which is installed in Ubuntu. But I have no clue where to find the missing part so Debian machine can start showing me hostnames.

Any ideas?

EDIT: My /etc/nsswitch.conf is exactly this:

root@zxcv:/home/test# cat /etc/nsswitch.conf
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd:         compat
group:          compat
shadow:         compat
gshadow:        files

hosts:          files dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

However I've setup a VM with bridged network adapter, installed same version of Debian Minimal, and I am able to get the hostnames for all IPs. The question now is, which packets/modules/services is the failing Debian missing, which prevents from getting hostnames?

  • 1
    Is reverse name resolution working correctly on the Debian laptop? It needs it to convert IP addresses (gleaned from the ARP cache) to host-names. – garethTheRed Aug 7 '18 at 13:40
  • @garethTheRed How can I check if it is working correctly? So far host 192.168.561 on debian gives me Host 1.0.168.192.in-addr.arpa. not found: 3(NXDOMAIN) – RedS Aug 7 '18 at 13:51
0

You don't have access to the DNS server that can translate IP addresses to names.

There are other ways to associate host names and IP addresses, but if you have more than one computer, DNS is your best answer.

And in reply to your comment, yes, /etc/resolv.conf should contain the address of the DNS server. In a small network this is often the same as the router.

1

arp is interrogating your system to determine how it can translate IP's to hostnames. If you use the -n switch it'll forgo this and simply show the IPs without any translation to hostnames.

Like most tools in Linux, arp uses NS (Name Service Switch) to do the lookups. If you strace your arp command you can see it looking these things up:

$ strace -s 2000 arp -a
...
open("/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 5

After looking in this file arp will discover how it's suppose to look up hostnames.

$ grep hosts: /etc/nsswitch.conf
#hosts:     db files nisplus nis dns
hosts:      files dns myhostname

This says to look in files 1st, then inquire to DNS 2nd... The word files here means to use the system's /etc/hosts file. You can tap into how NS would do this by using the getent hosts command.

Example

On my VM of CentOS 7 for example:

$ arp -a
? (10.0.2.3) at 52:54:00:12:35:03 [ether] on eth0
gateway (10.0.2.2) at 52:54:00:12:35:02 [ether] on eth0
$ arp -an
? (10.0.2.3) at 52:54:00:12:35:03 [ether] on eth0
? (10.0.2.2) at 52:54:00:12:35:02 [ether] on eth0

If we inquire to getent looking for the 10.0.2.2 IP:

$ getent hosts 10.0.2.2
10.0.2.2        gateway

The IPs, if not present locally in any files, will be looked up in DNS next. Since my IPs are all private IPs to this VM, and they're not explicitly in my VM's defined DNS, which is incidentally defined here:

$ more /etc/resolv.conf
# Generated by NetworkManager
nameserver 10.0.2.3

NOTE: arp is left with no other choice than to show you a question mark, because it failed to find any name to use.

  • If my /etc/resolv.conf doesnt contain router's IP address (which acts as DNS server), could it be the cause of problems? – RedS Aug 7 '18 at 16:21
  • @RedS - that would be the next thing I'd try as well. – slm Aug 7 '18 at 16:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.