Netdisco: Effortless Network Topology Automation and Switch Port Management

Network tutorial - IT technology blog
Network tutorial - IT technology blog

The Nightmare of “Where Does This Cable Go?”

I once managed a network for a 100-person office and a small datacenter with about 30 switches and routers, ranging from Cisco and HP to Juniper. The most common sight was me crouching in the server room with a flashlight whenever there was an issue or someone moved desks. SSHing into each switch and typing show mac address-table or show cdp neighbors was a total nightmare.

The most stressful part was when the boss asked: “Which port is the device with IP 192.168.1.50 plugged into?”. If you’re still struggling with an Excel “Network Map” updated 2 years ago, trust me, you’re making your life harder than it needs to be.

Why Manual Management is Always a “Mission Impossible”

A network is a living entity. It changes daily: new devices, re-patched ports, or replaced faulty switches. Maintaining diagrams with Visio or Excel usually fails because:

  • Data is always outdated: If a technician forgets to update it just once after moving a cable, the entire documentation becomes junk.
  • Slow tracing: Manually logging into 10 devices to find a MAC address can waste 30 precious minutes.
  • Lack of correlation: You have the IP but don’t know the Port; you have the Port but don’t know which VLAN it belongs to without logging in directly.

Solutions for SysAdmins

Typically, administrators use a few different methods:

  1. Nmap Scanning: You know which machines are online but are completely “blind” to their physical port location.
  2. Using Zabbix or LibreNMS: Great for bandwidth monitoring. However, their topology mapping and deep port management features are often quite weak.
  3. Netdisco: This is a specialized “weapon.” It answers exactly: “What is plugged in where, and how are the switches connected?”

Netdisco: The “Perfect Match” for Infrastructure Management

Netdisco is an open-source tool for network management that uses SNMP to automatically collect data. It doesn’t just list devices; it maps the network, tracks IP/MAC history, and manages VLANs centrally.

The most valuable feature is the lightning-fast search. Just type a part of an IP or MAC, and the system identifies it: Switch A, Port Gi0/1, VLAN 10. You’ll save at least 80% of the time spent searching for devices on the network.

Prerequisites

  • An Ubuntu 22.04 or Debian 12 virtual machine.
  • Sudo privileges.
  • Network devices with SNMP enabled (v2c or v3).

Detailed Netdisco Installation Steps

Forget the old-school way of manually installing complex Perl libraries. We’ll use a modern script to save time.

Step 1: Install Dependencies

sudo apt update
sudo apt install -y curl modern-perl postgresql-all graphviz libdbd-pg-perl libsnmp-perl libssl-dev libcrypt-openssl-rsa-perl

Step 2: Create a Dedicated User

Never run Netdisco as root. That’s a golden rule of security.

sudo useradd -m -p x -s /bin/bash netdisco
sudo su - netdisco

Step 3: Install Netdisco App

In the netdisco user terminal, run the following command:

mkdir ~/bin
curl -L https://cpanmin.us | perl - --notest --local-lib ~/perl5 App::Netdisco

# Update PATH so the system recognizes commands
echo 'export PATH=$PATH:$HOME/bin' >> ~/.bashrc
source ~/.bashrc

Step 4: Database Setup

Netdisco uses PostgreSQL for storage. You need to create the database and user (run with sudo):

sudo -u postgres psql -c "CREATE USER netdisco WITH PASSWORD 'your_password_here';"
sudo -u postgres psql -c "CREATE DATABASE netdisco OWNER netdisco;"

Step 5: System Configuration

Switch back to the netdisco user and create the configuration file at ~/environments/deployment.yml:

mkdir ~/environments
nano ~/environments/deployment.yml

Paste the following content and make sure to edit the DB and SNMP information:

database:
  name: 'netdisco'
  user: 'netdisco'
  pass: 'your_password_here'
  host: 'localhost'

snmp_auth:
  - community: 'your_public_string'
    read: true

Step 6: Initialize Data

~/bin/netdisco-deploy

This command will automatically create tables, download MIBs (libraries for identifying Cisco, HP, etc., devices), and create an admin account for the web interface.

Enable Services

Netdisco operates with two components: the Web interface and the network-scanning Backend.

~/bin/netdisco-web start
~/bin/netdisco-daemon start

Now, open your browser and go to http://Server-IP:5000.

Pro Tips for Mastering Netdisco

1. The “Seeding” Technique

When first installed, Netdisco will be empty. You need to provide the IP of your first Core device:

~/bin/netdisco-do discover -d 10.0.0.1

Thanks to CDP/LLDP protocols, Netdisco will automatically “discover” satellite switches and add them to the map. You don’t need to add every switch manually.

2. Automated Scanning Schedule

To keep the data accurate, set up a scan schedule in the deployment.yml file:

schedule:
  discoverall: '0 1 * * *'   # Scan the entire system at 1 AM
  macwalk: '*/30 * * * *'    # Update computer locations every 30 minutes
  arpwalk: '*/20 * * * *'    # Update IP/MAC tables every 20 minutes

3. The Power of Port Control

If the SNMP configuration has Write permissions, you can perform Shut/No-Shut on ports directly from the web interface. This feature is extremely useful for quickly isolating a computer spreading malware when you don’t have time to open an SSH terminal.

Conclusion

Netdisco doesn’t completely replace Zabbix, but it is the missing piece for managing physical infrastructure. In my experience, deploying Netdisco reduces the stress of troubleshooting connectivity by 70%. If you’re managing more than 10 switches, install it today to escape the exhaustion of manual “cable hunting.”

Share: