0

I have several Raspberry Pi deployments that I want to be able to remotely query over the network for their hostname.

I've found that if I enable SMB via Samba that I can successfully query with a NetBios lookup. For security reason I would assume not to introduce SMB on these system for the sole purpose of hostname identification.

It should also be noted that these systems are not part of a domain and do not register with DNS.

Is there any known methods out there that will allow me to query an IP address and return the hostname (as defined in /etc/hostname) of a linux based system?

9
  • Use ssh to the remote rpi and use a command to retrieve the hostname (hostname, uname -n ...). Secure by design, especially with a key. Or is there something preventing this that isn't in the question?
    – A.B
    Dec 11, 2018 at 18:51
  • I have have about 50 devices connected through WiFi and will receive their IP from DHCP. The devices will move around often and assigning a static IP will get away from the zero touch setup we currently use. I want to be able to scan multiple subnet ranges to find the specific hostname I am looking for then SSH to it.
    – Brandon763
    Dec 11, 2018 at 19:47
  • My alternative would be to document the MAC address for each device / hostname then search for the MAC when needed. It would be best if I would run a program like AngryIP Scanner each time I was looking for a device.
    – Brandon763
    Dec 11, 2018 at 19:52
  • Can't you get the information from the DHCP server then? The device can send (or receive) its hostname to (from) it.
    – A.B
    Dec 11, 2018 at 20:09
  • 1
    If you don't want to use the ssh protocol (which is already installed), you can install a snmp server. OID 1.3.6.1.2.1.1.5 should give the information. avahi/zeroconf mught be an other method which might allow broadcast or multicast. Whatever you do you have to install something to get the hostname. It won't come from a ping.
    – A.B
    Dec 12, 2018 at 16:12

1 Answer 1

0

I explored the SNMP route and it looks like that is as good as it will get. I created a bat file that did SNMPGETs on 254 addresses then parsed the results. I used SNMP Softwares tool (snmpsoft.com/shell-tools/snmp-get) to accomplish this in Windows. The min timeout value is 1 second so it takes a couple of mins to run but not an issue, wouldn't want it much lower. Thanks AB.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .