A Flask-based web application that discovers network topology using CDP and LLDP protocols. Automatically detects device types and recursively maps network neighbors.
- Web Interface - Easy-to-use HTML form for discovery
- Interactive Network Diagrams - Beautiful, interactive visualizations with color-coded nodes and interface labels
- Multi-Protocol - Discovers neighbors via both CDP and LLDP
- Multi-Vendor Support - Cisco, Arista, Juniper, Palo Alto, MikroTik, Fortinet, HPE, Dell, Extreme, Ubiquiti, Barracuda
- Smart Detection - YAML-based device type detection
- Recursive Discovery - Automatically crawls neighbors (routers/switches only)
- Device Type Filtering - Choose which devices to include (routers, switches, phones, servers, APs)
- Interface Mapping - Shows local and remote interface connections
- Management IPs - Displays IP addresses for discovered devices
- Text-Based Map - Clean ASCII tree visualization
- Docker Ready - Containerized for easy deployment
- Docker and Docker Compose
- Network access to devices
- SSH credentials with appropriate privileges
- Devices with CDP and/or LLDP enabled
# Clone or extract the project
cd neighbor-mapper-v2
# Start the application
docker-compose up -d
# View logs
docker-compose logs -f
# Stop the application
docker-compose downAccess the web interface at: http://localhost:8000
# Build the image
docker build -t neighbor-mapper .
# Run the container
docker run -d -p 8000:8000 --name neighbor-mapper neighbor-mapper
# View logs
docker logs -f neighbor-mapper# Install dependencies
pip install -r requirements.txt
# Run the application
cd app
python app.py- Open Web Interface - Navigate to http://localhost:8000
- Enter Seed Device - Provide IP address of starting device
- Select Device Type - Choose the Netmiko device type from dropdown
- Enter Credentials - SSH username and password
- Set Depth - Choose how many hops to discover (1-5)
- Start Discovery - Click "Start Discovery" button
- View Results - See topology map with devices, interfaces, and IPs
CORE-SW-01 (192.168.1.1)
โโ[CDP+LLDP] Gi1/0/1 โ Gi1/0/48 (192.168.1.10)
โ DIST-SW-01 (192.168.1.10)
โ โโ[CDP+LLDP] Gi1/0/10 โ Gi0/1 (192.168.1.20)
โ ACCESS-SW-01 (192.168.1.20)
โโ[CDP+LLDP] Gi1/0/2 โ Gi1/0/48 (192.168.1.11)
DIST-SW-02 (192.168.1.11)
Edit config/device_type_patterns.yaml to add or modify device type patterns:
device_types:
cisco_ios:
platforms:
- catalyst
- c3750
- c2960
system_descriptions:
- "Cisco IOS Software"
priority: 50Pattern Matching:
platforms: Match against CDP platform stringsystem_descriptions: Match against LLDP system descriptionpriority: Higher priority patterns are preferred (0-100)
Add New Patterns:
- Edit
config/device_type_patterns.yaml - Add platform or description patterns
- Restart the container:
docker-compose restart
In config/device_type_patterns.yaml:
discovery:
max_depth: 3 # Default maximum hops
connection_timeout: 15 # SSH connection timeout (seconds)
command_timeout: 30 # Command execution timeout (seconds)Control which devices are crawled:
allowed_capabilities:
- Router # Full word
- Switch
- R # Abbreviated
- S
- B # Bridge (switch)Devices without these capabilities (like phones, access points) are ignored.
neighbor-mapper-v2/
โโโ app/
โ โโโ app.py # Flask application
โ โโโ discovery.py # Topology discovery engine
โ โโโ parsers.py # CDP/LLDP parsers
โ โโโ device_detector.py # Device type detection
โโโ config/
โ โโโ device_type_patterns.yaml # Detection patterns
โโโ templates/
โ โโโ index.html # Web interface
โโโ logs/ # Application logs
โโโ Dockerfile # Container definition
โโโ docker-compose.yml # Docker Compose config
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
-
Initial Connection
- SSH to seed device using provided credentials
- Extract hostname from prompt
-
Neighbor Discovery
- Run
show cdp neighbors detail - Run
show lldp neighbors detail - Parse outputs to extract neighbor information
- Run
-
Device Type Detection
- Match platform strings against YAML patterns
- Determine appropriate Netmiko device type
- Check capabilities (Router/Switch only)
-
Recursive Crawl
- Queue neighbors for discovery
- Repeat process for each neighbor
- Track visited devices to avoid loops
- Respect maximum depth setting
-
Topology Rendering
- Build adjacency graph
- Generate ASCII tree visualization
- Show interface mappings and IPs
Logs are written to logs/app.log and displayed in the container output.
View logs:
# Docker Compose
docker-compose logs -f
# Docker
docker logs -f neighbor-mapper
# Local file
tail -f logs/app.logLog Levels:
- INFO: Discovery progress, device connections
- WARNING: Failed CDP/LLDP queries, skipped devices
- ERROR: Connection failures, authentication errors
- Check: CDP/LLDP enabled on devices
- Command:
show cdp neighbors/show lldp neighbors - Fix:
cdp run/lldp runin global config
- Check: Username/password correct
- Check: Account has privilege level 15 or appropriate access
- Fix: Test SSH manually:
ssh user@device-ip
- Check: Network connectivity to device
- Check: SSH enabled and accessible
- Fix: Verify firewall rules, ping device
- Check: Pattern matching in YAML config
- Fix: Add specific platform pattern for your device
- Example: Add
c9300-24pto cisco_xe platforms
- Check: Device capabilities
- Reason: Only Router/Switch devices are crawled
- Fix: Verify device is reporting R or S capability
- Credentials: Passwords are not stored, only used during discovery
- Network Access: Ensure container can reach network devices
- SSH Keys: Currently uses password auth (key auth can be added)
- HTTPS: Consider adding TLS/SSL for production use
- Authentication: Add web app authentication for production
- SSH Only: Telnet not supported
- Cisco Focus: Best tested on Cisco devices
- Single Credential: Uses same credentials for all devices
- No Persistence: Discovery results not saved (add database for this)
- Text Output: No graphical topology (can add vis.js, D3, etc.)
- Save topologies to database
- Export to formats (JSON, GraphML, CSV)
- Graphical topology visualization
- Multiple credential sets
- SSH key authentication
- Web authentication/authorization
- REST API endpoints
- Scheduled discoveries
- Change detection
- More vendor support
Open source - feel free to modify and extend!
To add support for new device types:
- Edit
config/device_type_patterns.yaml - Add platform/description patterns
- Set appropriate priority
- Test and submit PR
- Start small: Use depth=1 for initial testing
- Check logs: Monitor logs during discovery
- Update patterns: Add patterns as you discover new device types
- Test credentials: Verify SSH access before running discovery
- Network segments: May need to run from jump host if devices are isolated
This project was developed with Claude Code, Anthropic's AI coding assistant (claude-sonnet-4-6). The application logic, parsers, visualizations, and supporting infrastructure were all written through an iterative, conversational development process with Claude as the primary code author.