| created | "2026-01-01T00:00:00.000Z" |
| modified | "2026-04-25T00:00:00.000Z" |
| reviewed | "2026-04-25T00:00:00.000Z" |
| name | layer2-discovery |
| description | Layer 2 device discovery and topology mapping. Use when finding switch port assignments, enumerating hosts via ARP, or identifying unknown devices by MAC vendor. |
| user-invocable | false |
| allowed-tools | Bash(arp *), Bash(ip *), Bash(bridge *), Bash(ethtool *), Read, Write, Edit, Grep, Glob |
Layer 2 Network Discovery
When to Use This Skill
| Scenario | Use this skill | Alternative |
|---|
| Find which switch port a server is connected to | Yes | |
| Enumerate hosts on the local segment via ARP | Yes | |
| Identify unknown devices by MAC vendor | Yes | |
| Map physical network topology (LLDP/CDP) | Yes | |
| Check if a host is alive when ICMP is blocked | Yes (arping) | |
| Detect duplicate IP addresses | Yes (arping -D) | |
| Scan for open TCP/UDP ports on remote hosts | | network-discovery (RustScan, nmap) |
| Trace the network path to a remote host | | network-diagnostics (trippy) |
| Look up DNS records for a domain | | dns-tools (dog, dig) |
| Load test an HTTP endpoint | | http-load-testing (oha) |
| Monitor per-process bandwidth usage | | network-monitoring (bandwhich) |
| Inspect or configure the host's own IPs, links, or routes | | interface-state (ip) |
Expert knowledge for Layer 2 network topology discovery and neighbor detection, operating below the IP layer for direct link-level visibility.
Core Expertise
Layer 2 vs Layer 3 Discovery
| Layer | Protocol | Information | Use Case |
|---|
| L2 | LLDP/CDP | Switch ports, VLANs, neighbors | Topology mapping |
| L2 | ARP | MAC-to-IP mappings | Local host discovery |
| L3 | ICMP/TCP | IP reachability, ports | Remote host scanning |
Why L2 matters:
- Operates without IP routing - works on isolated networks
- Reveals physical topology (which port connects where)
- Identifies network equipment (switches, routers, phones)
- No firewall interference - L2 frames aren't filtered like IP packets
LLDP/CDP Topology Discovery
lldpd Overview
lldpd is an IEEE 802.1AB (LLDP) implementation that also supports:
- CDP - Cisco Discovery Protocol
- EDP - Extreme Discovery Protocol
- FDP - Foundry Discovery Protocol
- SONMP - SynOptics Network Management Protocol
Architecture:
lldpd - Daemon that sends/receives LLDP frames
lldpcli - CLI to query daemon and configure settings
Installation
sudo apt install lldpd
brew install lldpd
sudo systemctl enable --now lldpd
Essential lldpcli Commands
lldpcli show neighbors
lldpcli show neighbors details
lldpcli show chassis
lldpcli show statistics
lldpcli show interfaces
lldpcli show configuration
Neighbor Output Interpretation
-------------------------------------------------------------------------------
LLDP neighbors:
-------------------------------------------------------------------------------
Interface: eth0, via: LLDP, RID: 1, Time: 0 day, 00:05:32
Chassis:
ChassisID: mac 00:1a:2b:3c:4d:5e
SysName: switch-core-01
SysDescr: Cisco IOS Software, C3750 Software
MgmtIP: 10.0.0.1
Capability: Bridge, on
Capability: Router, off
Port:
PortID: ifname GigabitEthernet0/1
PortDescr: Server Room Rack A
TTL: 120
VLAN: 100, pvid: yes
Key fields:
- ChassisID - Unique switch identifier (usually MAC)
- SysName - Switch hostname
- PortID/PortDescr - Which port you're connected to
- VLAN - VLAN assignment on that port
Configuration
lldpcli configure lldp portidsubtype ifname
lldpcli configure cdp status rx-only
lldpcli configure system description "Application Server"
lldpcli configure ports eth0 lldp portdescription "Primary uplink"
lldpcli configure ports eth1 lldp status disabled
Configuration file: /etc/lldpd.conf or /etc/lldpd.d/*.conf
# /etc/lldpd.conf
configure system description "Production Web Server"
configure lldp portidsubtype ifname
configure cdp status rx-only
ARP Scanning for Host Discovery
arp-scan-rs
Fast, Rust-based ARP scanner for local network host discovery.
cargo install arp-scan
arp-scan -l
arp-scan -i en0 -l
arp-scan -i eth0 192.168.1.0/24
arp-scan -p fast -l
arp-scan -p stealth -l
arp-scan -l --json
arp-scan -l --alive-only
Scan Profiles
| Profile | Timing | Retries | Use Case |
|---|
default | Balanced | 2 | General use |
fast | Aggressive | 1 | Quick enumeration |
stealth | Slow | 1 | Minimize detection |
Output Parsing
arp-scan -l --json | jq -r '.hosts[].ip'
arp-scan -l --json | jq -r '.hosts[] | "\(.ip) \(.mac)"'
arp-scan -l --json | jq '.hosts | length'
arping - Single Host Probe
arping sends ARP requests to a specific host - useful for:
- Checking if host is alive at L2 when ICMP is blocked
- Detecting IP conflicts (multiple responses)
- Waking hosts from sleep states
arping 192.168.1.1
arping -I eth0 192.168.1.1
arping -c 3 192.168.1.1
arping -w 5 192.168.1.1
arping -D 192.168.1.100
Common Patterns
Discover Network Topology
arp-scan -l --json > /tmp/hosts.json
lldpcli show neighbors
lldpcli show neighbors | grep -A 10 "Interface:"
Identify Unknown Devices
arp-scan -l
Check Physical Port Assignment
lldpcli show neighbors | grep -E "(Interface|PortID|PortDescr)"
Monitor for New Neighbors
watch -n 30 'lldpcli show neighbors'
journalctl -u lldpd -f
Scripted Topology Export
lldpcli show neighbors -f json
lldpcli show neighbors -f json | jq '.lldp.interface[] | {
local_if: .name,
remote_chassis: .chassis[].name[].value,
remote_port: .port[].id[].value
}'
Agentic Optimizations
| Context | Command |
|---|
| Quick host list | arp-scan -l --json | jq -r '.hosts[].ip' |
| Count hosts | arp-scan -l --json | jq '.hosts | length' |
| Fast scan | arp-scan -p fast -l --alive-only |
| LLDP neighbors JSON | lldpcli show neighbors -f json |
| Switch port info | lldpcli show neighbors | grep -E "(PortID|PortDescr)" |
| Single host check | arping -c 1 -w 1 192.168.1.1; echo $? |
Quick Reference
arp-scan-rs Flags
| Flag | Long | Description |
|---|
-l | --localnet | Scan local network |
-i | --interface | Specify interface |
-p | --profile | Scan profile (default/fast/stealth) |
| --json | JSON output |
| --alive-only | Only show responding hosts |
lldpcli Commands
| Command | Description |
|---|
show neighbors | List discovered neighbors |
show neighbors details | Full TLV information |
show chassis | Local system info |
show statistics | Frame counters |
show interfaces | Monitored interfaces |
show configuration | Running config |
arping Flags
| Flag | Description |
|---|
-I | Source interface |
-c | Number of requests |
-w | Timeout in seconds |
-D | Duplicate address detection |
-q | Quiet mode |
Troubleshooting
lldpd Not Receiving Neighbors
systemctl status lldpd
lldpcli show interfaces
tcpdump -i eth0 ether proto 0x88cc
ip link show eth0
arp-scan Permission Denied
sudo arp-scan -l
sudo setcap cap_net_raw+ep $(which arp-scan)
No ARP Responses
ip route get 192.168.1.1
ip neigh show
arping -c 3 192.168.1.1
Requirements
sudo apt install lldpd arping
brew install lldpd arping
cargo install arp-scan