Saturday, August 1, 2020

Cannot Get Device Hostnames from Command Line Even Though Multiple Networking Scanning Apps Can Do it Just Fine

Okay, I'm probably doing something really dumb here, but nothing I can find online explains how to do. this.

I want to run a command and get a list of devices connected to the same network as the device running the CLI command. This list should include

  • The IP address of the device
  • The MAC address of the device
  • The hostname of the device

The first two are really easy. A simple arp -a command will get me the first two. However, nothing I have tried will get the hostname of the device. I've tried nmap, I've tried host, I've tried ping -a. Nothing works.

nmap gets me something like:

? (192.168.11.1) at aa:bb:cc:dd:ee on en0 ifscope [ethernet]

Now, I know that the question mark at the front their means it wasn't able to find the hostname. But here's the thing: when I run an app like Angry IP Scanner, I can see the hostname of nearly every device on my network: from my laptop, to the apple tv, to my phone. It even gets the name of all my smart plugs.

What the hell are these apps doing under the hood that I'm not doing on the command line? It can't be the fact that these devices don't want to give me their hostnames due to some kind of configuration: other apps are able to get that info just fine.

What am I doing wrong? I am running on OSX



No comments:

Post a Comment