Passively discovers which Cisco switch port your machine is connected to by sniffing CDP (Cisco Discovery Protocol) packets. Reports device hostname, IP addresses, connected port, VLANs, IOS version, platform, duplex, PoE, and QoS info.
Run this in the directory where you want the tool installed:
curl -sSL https://raw.githubusercontent.com/vherolf/discover-switchport/main/install.sh | bashSupports Debian/Ubuntu and macOS (Homebrew). Installs all system and Python dependencies, clones the repo, creates a venv, and on Linux sets the required capture capabilities on the Python binary so no sudo is needed at runtime. Running the command again updates everything in place.
Debian/Ubuntu:
sudo apt install -y git python3 python3-venv python3-pip libpcap-dev \
libxcb-keysyms1 libxcb-image0 libxcb-render-util0 libxcb-cursor0 libxcb-icccm4 libcap2-bin
git clone https://github.com/vherolf/discover-switchport.git
cd discover-switchport
python3 -m venv venv
venv/bin/pip install -r requirements.txt
sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' venv/bin/python3macOS:
brew install git python3
git clone https://github.com/vherolf/discover-switchport.git
cd discover-switchport
python3 -m venv venv
venv/bin/pip install -r requirements.txtOn macOS packet capture requires
sudounless you grant your terminal Full Disk Access or use a dedicated capture tool.
cd discover-switchport
venv/bin/python3 switchport-scanner-gui.py- Interface is auto-detected on start; change it in the dropdown if needed
- Press Start — CDP packets appear in the table as they arrive
- New connections are highlighted green and written to CSV automatically
- Press Browse… to choose a different CSV output path
cd discover-switchport
venv/bin/python3 switchport-scanner.py
venv/bin/python3 switchport-scanner.py -i eth0
venv/bin/python3 switchport-scanner.py -i eth0 -o /tmp/scan.csv| Flag | Default | Description |
|---|---|---|
-i / --interface |
auto-detect | Network interface to sniff |
-cf / --capturefilter |
ether dst 01:00:0c:cc:cc:cc |
BPF capture filter |
-o / --output |
cdp_discovery.csv |
CSV output path |
sudo bash build.shProduces dist/switchport-scanner-gui. Use switchport-scanner.desktop and launch-scanner.sh to integrate it into your desktop environment.
sudo tcpdump -nn -v -i eth0 -s 1500 'ether[20:2] == 0x2000'