CLI tool and Python library for multi-vendor switch management and network topology discovery.
Quick links:
pip install networkmgmt| Module | Description |
|---|---|
| networkmgmt.switchctrl | Multi-vendor switch management (Cisco, MikroTik, QNAP, Netgear Pro/Plus) |
| networkmgmt.snmp | Shared SNMPv2c/v3 core (optional pysnmp) used by the Netgear Pro vendor |
| networkmgmt.discovery | Network topology discovery (ARP, DNS, SNMP, LLDP, nmap, traceroute) |
| networkmgmt.snmp_vlan_dump | SNMP VLAN-port dump for Netgear switches |
| Vendor | Model(s) | Transport | Notes |
|---|---|---|---|
| cisco | Catalyst 1200 (C1200-8T-D) | SSH CLI only | 8 GE ports (gi1–gi8), no REST API, enable password required |
| mikrotik | RouterOS v7+ switches | REST API + SSH CLI | REST for monitoring, SSH for configuration |
| qnap | QSW-M408 series | REST API + SSH CLI | Monitoring and VLAN via REST (declarative apply_port_membership, 0.3 s request delay), port/LACP via Cisco-style SSH CLI; no PVID |
| netgear | Smart Managed Pro: S3300 stack, GS108Tv2, M4300 class | SNMPv3 (v2c fallback), web UI for static routes only | VLAN incl. PVID, port admin, LAG read-only, routing interfaces, management IP, static routes, save_config() |
| netgear_plus | Smart Managed Plus: GS105E, GS108E, GS305E | Web UI via optional netgear-tool | Declarative 802.1Q incl. removal, PVID, port admin; no LACP, no sensors |
networkmgmt is an orchestrator that dispatches to three sub-CLIs. Each sub-CLI can also be invoked directly:
| Orchestrator command | Direct script | Description |
|---|---|---|
networkmgmt switchctrl ... | networkmgmt-switchctrl | Multi-vendor switch management |
networkmgmt discover ... | networkmgmt-discover | Network topology discovery |
networkmgmt vlan-dump ... | networkmgmt-vlan-dump | SNMP VLAN-port dump |
pip install .
Optional extras:
pip install networkmgmt[snmp] # pysnmp: netgear (Smart Managed Pro) vendor
pip install networkmgmt[netgear-plus] # netgear-tool: netgear_plus (Smart Managed Plus) vendor
pip install networkmgmt[discovery] # scapy: ARP scan in networkmgmt-discover
pip install networkmgmt[all] # everything above
Discover local network topology via ARP scanning, reverse DNS, MAC vendor lookup, SNMP bridge tables, LLDP, optional nmap service detection, and traceroute. Outputs Mermaid flowcharts or JSON.
# Basic discovery (auto-detect interface)
networkmgmt-discover -i eth0
# or: networkmgmt discover -i eth0
# With nmap service detection (requires root for ARP scan)
sudo networkmgmt-discover -i eth0 --nmap -o topology.md
# JSON output
networkmgmt-discover -i eth0 --format json -o topology.json
# Multi-subnet scan
networkmgmt-discover -i eth0,vlan100 -o multi.md
# SNMP L2 topology (query switch MAC tables), SNMPv2c per switch
networkmgmt-discover -i eth0 --switches 192.0.2.38:public,192.0.2.19
# SNMPv3 for every switch without :community (v2c entries can be mixed in)
networkmgmt-discover -i eth0 --switches 192.0.2.38,192.0.2.150,192.0.2.19:public \
--snmp-user admin --snmp-auth-key 'AUTHPASS' --snmp-auth-protocol sha512
# LLDP-based topology
networkmgmt-discover -i eth0 --lldp-collect /tmp/lldp
# Manual topology + diagram style
networkmgmt-discover -i eth0 --topology 192.0.2.50:192.0.2.19:g3 -d hierarchical
# Traceroute to external targets
networkmgmt-discover -i eth0 -t 8.8.8.8,1.1.1.1
sudo networkmgmt-discover -i eth0 -t 192.0.2.0/24
| Option | Description |
|---|---|
-i / --interface | Network interface(s), comma-separated (default: auto-detect) |
-t / --targets | Traceroute targets: IPs, CIDR (192.168.1.0/24), or range (192.168.1.1-254) |
--nmap | Enable nmap service detection |
--top-ports | nmap top ports to scan (default: 100) |
-o / --output | Output file (default: stdout) |
--format | mermaid (default) or json |
--timeout | Scan timeout in seconds (default: 10) |
--max-hops | Max traceroute hops (default: 30) |
--trace-local | Tracepath to all LAN hosts to detect switch hierarchy |
--switches | SNMP L2 discovery: IP[:community],... (default community: public) |
--snmp-user | SNMPv3 user for --switches entries without :community |
--snmp-auth-key | SNMPv3 auth passphrase (or $SNMP_AUTH_KEY) |
--snmp-auth-protocol | md5, sha, sha256, sha512 (default) |
--snmp-priv-key | SNMPv3 privacy passphrase (or $SNMP_PRIV_KEY); unset = authNoPriv |
--snmp-priv-protocol | des, aes128 (default) |
--snmp-timeout | SNMP timeout per request in seconds (default: 5) |
--snmp-retries | SNMP retries per request (default: 1) |
--lldp-collect | SSH into hosts, collect lldpctl JSON to directory |
--lldp-dir | Read existing LLDP JSON files from directory |
--topology | Manual L2 topology: HOST:SWITCH:PORT,... |
-d / --diagram-style | auto (default), flat, categorized, hierarchical |
--direction | Mermaid flowchart direction: LR or TD (default: auto) |
--elk | Use ELK layout engine for large diagrams |
-v / --verbose | Verbose logging |
See the README on GitHub.
Dumps VLAN membership (tagged/untagged), PVIDs and link state per port from Q-BRIDGE-MIB capable switches (tested on Netgear S3300 stacks and GS108Tv2) as a terminal table, Markdown or Mermaid diagram.
# SNMPv2c
networkmgmt vlan-dump 192.0.2.38 public
networkmgmt vlan-dump 192.0.2.38 public -m -o s3300.md -d trunks
# SNMPv3 (defaults sha512/aes128; authNoPriv when --snmp-priv-key is missing)
networkmgmt vlan-dump 192.0.2.38 --snmp-user admin --snmp-auth-key 'AUTHPASS'
# GS108Tv2: the web login is the SNMPv3 user, md5/sha + des only
networkmgmt vlan-dump 192.0.2.150 --snmp-user admin --snmp-auth-key 'WEBPASS' \
--snmp-auth-protocol sha --snmp-priv-key 'WEBPASS' --snmp-priv-protocol des
SNMP_AUTH_KEY='AUTHPASS' networkmgmt vlan-dump 192.0.2.38 --snmp-user admin --snmp-timeout 10 --snmp-retries 2
dot1qVlanStaticTable; the dump merges them in from dot1qVlanCurrentTable, static entries win.SNMP authentication failed. With SNMPv3 this often surfaces only as a timeout, so the message names user, auth and privacy settings as the likely cause.networkmgmt-switchctrl --vendor <VENDOR> --host <IP> --password <PW> [options] <command>
# or: networkmgmt switchctrl --vendor <VENDOR> --host <IP> --password <PW> [options] <command>
| Option | Description |
|---|---|
--vendor | Switch vendor (cisco, mikrotik, netgear, netgear_plus, qnap) |
--host | Switch IP address or hostname |
--password | Admin password (required except for netgear with --community or --snmp-user) |
--username | Username (default: admin; netgear: alias for --snmp-user) |
--enable-password | Enable password (Cisco: required; QNAP: auto-generated if omitted) |
--ssh-port | SSH port (default: 22) |
--rest-port | REST API port (default: 443) |
--ssh-username | SSH username (vendor-specific default if omitted) |
--ssh-password | SSH password (vendor-specific default if omitted) |
--verify-ssl | Verify SSL certificates for REST API |
-v / --verbose | Enable debug logging |
All options are command-line flags; each is rejected for vendors it does not belong to.
| Option | Vendor | Description |
|---|---|---|
--community | netgear | SNMPv2c community (fallback when no --snmp-user is given) |
--snmp-user | netgear | SNMPv3 user |
--auth-key | netgear | SNMPv3 authentication passphrase (default: --password) |
--auth-protocol {md5,sha,sha256,sha512} | netgear | SNMPv3 authentication protocol (default: sha512; GS108Tv2: md5 or sha) |
--priv-key | netgear | SNMPv3 privacy passphrase (omit for authNoPriv) |
--priv-protocol {des,aes128} | netgear | SNMPv3 privacy protocol (default: aes128; GS108Tv2: des) |
--web-password | netgear | Web UI password for static routes (default: --password) |
--password | netgear_plus | Web UI password (the only option this vendor needs) |
--vlan-backend {rest,ssh} | qnap | VLAN backend (default: rest; ssh if SSH options are given) |
--rest-delay | qnap | Seconds between REST requests (default: 0.3) |
monitor — Show system info, sensors, ports, and LACP statusSections a vendor does not implement (Netgear sensors, LACP on netgear_plus) are reported as not supported and skipped; the rest is still printed.
# Cisco Catalyst 1200
networkmgmt-switchctrl --vendor cisco --host 192.168.1.254 \
--username admin --password <PW> --enable-password <EN> monitor
# QNAP QSW
networkmgmt-switchctrl --vendor qnap --host 192.168.1.1 --password <PW> monitor
# Netgear Smart Managed Pro, SNMPv3 (S3300: sha512 + aes128 are the defaults)
networkmgmt-switchctrl --vendor netgear --host 192.168.1.38 --snmp-user monitor \
--auth-key <AUTH> --priv-key <PRIV> monitor
# Netgear GS108Tv2: web login is the SNMPv3 user, md5/sha + des only
networkmgmt-switchctrl --vendor netgear --host 192.168.1.150 --snmp-user admin \
--auth-key <WEBPW> --auth-protocol sha --priv-key <WEBPW> --priv-protocol des monitor
# Netgear, SNMPv2c
networkmgmt-switchctrl --vendor netgear --host 192.168.1.38 --community public vlan list
# Netgear Smart Managed Plus
networkmgmt-switchctrl --vendor netgear_plus --host 192.168.1.5 --password <PW> vlan list
vlan — VLAN management# Create VLAN
networkmgmt-switchctrl --vendor cisco --host 192.168.1.254 \
--username admin --password <PW> --enable-password <EN> \
vlan create 100 --name servers
# List VLANs
networkmgmt-switchctrl --vendor cisco ... vlan list
# Delete VLAN
networkmgmt-switchctrl --vendor cisco ... vlan delete 100
port — Port configuration# Configure port (Cisco uses gi1-gi8, QNAP uses GigabitEthernet1/0/1)
networkmgmt-switchctrl --vendor cisco --host 192.168.1.254 \
--username admin --password <PW> --enable-password <EN> \
port config gi1 --speed 1000 --duplex full
# Disable a port
networkmgmt-switchctrl --vendor cisco ... port config gi3 --shutdown
example — Quick connectivity testnetworkmgmt-switchctrl --vendor cisco --host 192.168.1.254 \
--username admin --password <PW> --enable-password <EN> example
See the README on GitHub.
gi1 through gi8 (not GigabitEthernet1/0/1)vlan database mode (not configure terminal > vlan {id})channel-group {id} mode auto (not mode active)get_sensor_data() always returns fan_speed=0vlan_backend="rest"); SSH if ssh_username, ssh_password or enable_password is given (or vlan_backend="ssh")rest_delay (default 0.3 s) between requestsguest / guest123netgear)snmp_user, auth_key, priv_key) preferred, SNMPv2c (community) as fallback; needs pysnmp (networkmgmt[snmp])<unit>/g<n>NotImplementedErrorswitch.routing — VLAN routing interfaces, management IP/gateway and static routes; static routes need web_password (web UI)switch.save_config() — writes are running-config only until savednetgear_plus)netgear-tool package (networkmgmt[netgear-plus]); single web session, use the client as a context managerswitch.vlan.reconcile(...) (create, edit, PVID, delete, read-back check), ensure_vlan, ensure_vlan_absent, ensure_port_vlansNotImplementedError)admin, auth key = web password) and only md5/sha with des work.commitFailed.agentSaveConfig under 4526.11 (not 4526.10).commitFailed), which allows at most 4 sessions.untagged also sets the PVID, and 802.1Q mode must be on.lldp/neighbors/status; there is no PVID.The ansible/ directory contains stand-alone Ansible modules (no collection packaging) for Netgear Smart Managed Plus and Pro switches and QNAP QSW switches. They encode the same hardware findings as networkmgmt.switchctrl, but target playbooks: declarative, idempotent, with check mode and diff. See ansible/README.md.
See the README on GitHub.
See the README on GitHub.
This project is licensed under the LGPL where applicable/possible — see LICENSE.md. Some files/parts may use other licenses: MIT | GPL | LGPL. Always check per‑file headers/comments.
This is a development/experimental project. For production use, review security settings, customize configurations, and test thoroughly in your environment. Provided "as is" without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. Use at your own risk.
Content type
Image
Digest
sha256:3d579e783…
Size
120.9 MB
Last updated
1 day ago
docker pull xomoxcc/networkmgmt