A lightweight Python application that uses EasySNMP to automatically discover OSPF routers and neighbors in a network and visualize the resulting topology.
- Discovers OSPF routers starting from a root device
- Recursively queries all OSPF neighbors via SNMPv3
- Builds an OSPF graph using NetworkX and Matplotlib
- Python 3.x
- Net-SNMP installed on the system
- EasySNMP, Matplotlib, Networkx
- SNMPv3 access to network devices
sudo apt update
sudo apt install libsnmp-dev snmp-mibs-downloader
sudo apt install gcc python-dev-is-python3
sudo apt install python3-pip python3-venv
python3 -m venv .ospf
source .ospf/bin/activate
pip install easysnmp matplotlib networkx- Prompts the user for a root router IP address
- Uses SNMPv3 OSPF MIBs to retrieve:
- Local OSPF Router ID
- Neighbor Router IDs
- Neighbor IP addresses
- Recursively queries all discovered neighbors
- Builds a graph of OSPF adjacencies
- Displays the topology as an interactive graph window
.ospf/bin/python ospfD.pyYou will be prompted to enter the IP address of the root OSPF router:
Enter the 'root' device IP address:
Once discovery is complete, a network topology graph will be displayed.
The script uses SNMPv3 with authentication and privacy. Update the SNMPv3 session parameters in the code to match your environment:
security_usernameauth_protocolauth_passwordprivacy_protocolprivacy_password
Example snippet (from the script):
session = Session(
hostname=ip,
version=3,
security_level="auth_with_privacy",
security_username="YOUR_USERNAME",
auth_protocol="SHA",
auth_password="YOUR_AUTH_PASSWORD",
privacy_protocol="AES",
privacy_password="YOUR_PRIV_PASSWORD",
)- Designed for discovery and visualization, not configuration
- Large topologies may take longer to query and render
- Ensure SNMPv3 is enables and configured on devices
- OSPF Router ID:
.1.3.6.1.2.1.14.1.1 - OSPF Neighbor Router IDs:
.1.3.6.1.2.1.14.10.1.3 - OSPF Neighbor IPs:
.1.3.6.1.2.1.14.10.1.1
Provided as-is for learning and network visualization purposes.