Skip to content

pdudotdev/ospfD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

OSPF Network Discovery with Python and SNMP

A lightweight Python application that uses EasySNMP to automatically discover OSPF routers and neighbors in a network and visualize the resulting topology.

✨ Features

  • Discovers OSPF routers starting from a root device
  • Recursively queries all OSPF neighbors via SNMPv3
  • Builds an OSPF graph using NetworkX and Matplotlib

🛠 Requirements

  • Python 3.x
  • Net-SNMP installed on the system
  • EasySNMP, Matplotlib, Networkx
  • SNMPv3 access to network devices

Python dependencies

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

🚀 How It Works

  1. Prompts the user for a root router IP address
  2. Uses SNMPv3 OSPF MIBs to retrieve:
    • Local OSPF Router ID
    • Neighbor Router IDs
    • Neighbor IP addresses
  3. Recursively queries all discovered neighbors
  4. Builds a graph of OSPF adjacencies
  5. Displays the topology as an interactive graph window

▶️ Usage

.ospf/bin/python ospfD.py

You 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.

🔐 SNMP Configuration

The script uses SNMPv3 with authentication and privacy. Update the SNMPv3 session parameters in the code to match your environment:

  • security_username
  • auth_protocol
  • auth_password
  • privacy_protocol
  • privacy_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",
)

📌 Notes / Limitations

  • Designed for discovery and visualization, not configuration
  • Large topologies may take longer to query and render
  • Ensure SNMPv3 is enables and configured on devices

📎 OIDs Used

  • 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

📜 License

Provided as-is for learning and network visualization purposes.

About

A lightweight Python application that uses EasySNMP to automatically discover OSPF routers and neighbors in a network and visualize the resulting topology.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages