Finding LAN Devices

#linux #ssh #network

Table of Contents

Finding Devices on Your Local Network in Linux

Sometimes you need to find:

Linux provides several useful commands for exploring your local network.


Viewing Network Interfaces

The first thing you usually want to know is:

Use:

ip addr

Example output:

2: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP>
    inet 192.168.1.23/24

This tells us:

A /24 subnet usually means the network range is:

192.168.1.0/24

Understanding the Subnet

If your machine has:

192.168.1.23/24

then:

Usually:


Viewing Known Devices with ip neigh

Linux maintains a neighbor table containing devices your machine has recently communicated with.

View it using:

ip neigh

Example:

192.168.1.1 dev wlan0 lladdr 34:60:f9:aa:bb:cc REACHABLE
192.168.1.5 dev wlan0 lladdr 11:22:33:44:55:66 STALE

Explanation:

This command is useful for quickly seeing devices already known to the system.


Using arp -a

Older systems often use:

arp -a

Example:

router (192.168.1.1) at 34:60:f9:aa:bb:cc [ether] on wlan0

This shows similar information to ip neigh.

ip neigh is considered the modern replacement.


Scanning the Entire Network with nmap

nmap is one of the most useful network scanning tools available.

Install it:

Arch / Artix

sudo pacman -S nmap

Debian / Ubuntu

sudo apt install nmap

Ping Scan with nmap -sn

To discover active devices on your network:

nmap -sn 192.168.1.0/24

Explanation:

Sometimes nmap can also identify the device vendor:


Raspberry Pi USB Gadget Networking

If SSH over USB is enabled on a Raspberry Pi, plugging it into a Linux computer may create a USB network interface.

Check interfaces:

ip addr

You may see:

Typical addresses:

DeviceIP
Host PC192.168.7.1
Raspberry Pi192.168.7.2

Connect using:

ssh pi@192.168.7.2

or:

ssh username@raspberrypi.local

Discovering .local Hostnames with Avahi

Linux systems can use mDNS (multicast DNS) for hostname discovery.

Install:

Arch / Artix

sudo pacman -S avahi nss-mdns

Start the service:

sudo systemctl enable --now avahi-daemon

Browse devices:

avahi-browse -at

This may show:


Useful One-Liners

Show only IPv4 addresses

ip -4 addr

Show routing table

ip route

View active listening ports

ss -tulpn

Ping a device

ping 192.168.1.1