Score:1

is it possible to list LAN names when DNS is managed by ext router?

za flag

I wish to know the computer name associated with a known ip-address. The DNS is managed by my router (WIND3 webcube) and I can see the resolved name using the browser (http://192.168.1.1) Nevertheless, I wish to read the LAN computer names by command line from the console. I've tried <ping -r 192.168.1.255> then <arp -a> as suggested by Bodo; this has shown all IPs & relevant MACs on the LAN except my own; the only hostname shown has been the router name corresponding to 192.168.1.1 - half question has been answered, now I have a way to discover remote IPs on the LAN by console. In addition, using <nmap -sn 192.168.1.0/24>, I can see the full list of IPs on the LAN but still no hostnmes.

At the moment the best solution is running this script:
for x in {101..110}
do nslookup 192.168.1.$x | grep name
done

that shows all active names and relevant IPs (reversed)

Bodo avatar
pt flag
see https://serverfault.com/q/7056
ClaudioKlaus avatar
za flag
I suppose I badly explain what I need - sorry. I try to better explain. I know that the DHCP range is 192.168.1.100 ... 192.168.1.110 because I set it on the router . The best could be a command showing the list of IPaddr & hostname for each host connected, but it would also be acceptable a command for single enquiry i.e. IPaddr corresponding to an hostname or the reverse, hostname corresponding to an IPaddr. At the moment "dig -x <IPaddr>" works for my own IPaddr and for DHCP server IPaddr only, giving my own hostname and the DHCP server's name. For all other IPaddr it returns blank names.
Bodo avatar
pt flag
Please don't use comments to add information, [edit] your question instead. You might have to specify `@server`, see [man dig](https://linux.die.net/man/1/dig). I was not able to use `nslookup`'s `ls` or `dig`'s `axfr` to get a full listing from my router. Querying single addresses works.
Score:2
jp flag

workarounds(using ping, arp table and scans) that should work in most networks but might not report all devices(reports only those devices that echo/respond to the ping).

With ping and arp

ping(for a short while) the broadcast IP address(i.e. the highest, last and unusable IP address in your sub-net e.g. 192.168.1.255) which will in turn result in ping packets being sent to every possible IP address on your network like so:

ping -b 192.168.1.255

Then, run an arp(Address Resolution Protocol) request like so:

arp -a

With nmap

From man nmap:

-sn (No port scan)
  This option tells Nmap not to do a port scan after host discovery,
  and only print out the available hosts that responded to the host
  discovery probes. This is often known as a “ping scan”.

So, you can use it on your network like so:

nmap -sn 192.168.1.0/24

Where 192.168.1.0(the first unusable IP address i.e. 0) is your network address and 24 is your sub-net mask.

Score:1
pt flag

To get the name for a single known IP address from the router you can use

dig @router -x ipaddress +short

for example

dig @192.168.1.1 -x 192.168.1.100 +short

see man dig

I was not able to use dig's query type axfr or nslookup's ls command to get a full listing from my router. This might be a permissions issue.

Of course you can use shell programming to run dig in a loop for a range of IP addresses.

Raffa avatar
jp flag
You probably can do something like `seq -f "192.168.1.%g" 1 254 | xargs -n 1 dig @192.168.1.1 +noall +answer +time=1 -x`
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.