Hacker Public Radio

HPR3052: Locating computers on a network


Listen Later

Locating computers on a network
Sometimes you may wish to locate a device on your network. It might be to find rogue devices, or to locate a new device be that a printer, an Internet of Things light bulb, or whatever. In my case I was trying to track down a RaspberryPi. Raspbian now lists the IP Addresses assigned to it when it first starts, but that requires a monitor to be connected.
Locating using your router.
This is by far the easiest way to find a new device but it is also the most manual. If you have access to the (WiFi) Router/DHCP server on your network then this should be a matter of logging in and getting the address from the menu area probably called Network or LAN or something like that. So first list all the computers that are on the network. Then turn on your pi, and see if a new one has joined. If you're lucky it may even be labeled Raspberry Pi Foundation.
In my case I want to locate these devices automatically using a script. So below we will explore some ways that you can approach the problem of locating devices on your network. All of them rely on trying to find the mapping between an Ethernet MAC Address, and a IP Address. It will help to understand a little about how Ethernet works. This is a nice short overview, How does Ethernet work? (animated) by Janos Pasztor
ARP
I don't know the network device you will be using so I'd like to share a few ways of doing this using the ARP protocol. This provides a mapping between a device's permanent MAC address and their, often temporarily, assigned IP address.
When your computer 192.168.1.1 wants to talk to another device it will need to know the Ethernet MAC address of the other device. Let's assume it wants to connect to the local printer 192.168.1.2 that is on the same network, and it knows its IP Address. If your computer has already heard the printer communicate on the network, it will have already added the printer's IP address and MAC Address to its so called ARP table. Over time older entries will be removed from this table either because they are too old, or there were too many entries.
Linux has a command called arp which will show you a list of the IP addresses mapped to the MAC/HWaddress address.
# arp -n
Address HWtype HWaddress Flags Mask Iface
192.168.1.254 ether ff:ee:dd:cc:bb:aa C eno1
192.168.1.2 ether 00:11:22:33:44:55 C eno1
192.168.1.1 ether 00:aa:bb:cc:dd:ee C eno1
From a Internet Protocol (IP) point of view all your devices in your house are probably in the same Subnet(work). But what if you need to communicate outside your network? For example to ping a well known server 8.8.8.8 to check if you have an Internet Connection. The IP settings also include a Default gateway to send all traffic not intended for the local network.
Finding the Default gateway
Your computer will have many IP Addresses configured but it's a good bet that the network you and your new pi are on is the same
...more
View all episodesView all episodes
Download on the App Store

Hacker Public RadioBy Hacker Public Radio

  • 4.2
  • 4.2
  • 4.2
  • 4.2
  • 4.2

4.2

34 ratings


More shows like Hacker Public Radio

View all
The Infinite Monkey Cage by BBC Radio 4

The Infinite Monkey Cage

2,087 Listeners

Click Here by Recorded Future News

Click Here

415 Listeners

Hacker And The Fed by Chris Tarbell & Hector Monsegur

Hacker And The Fed

168 Listeners