Skip to main content

CLI tool to manage D-Link DSL-2750U router

Project description

router-cli

A command-line tool to manage and monitor D-Link DSL-2750U routers.

Since the router doesn't provide a formal API, this tool works by authenticating with the router's web interface and parsing the HTML status pages to extract information.

Features

  • Zero external dependencies - Uses only Python standard library
  • Colorized output - Highlights known vs unknown devices on your network
  • Comprehensive monitoring - View status, clients, DHCP leases, routes, statistics, and logs
  • Remote management - Reboot the router from the command line
  • ADSL statistics - Monitor line quality metrics (SNR, attenuation, sync rates)
  • Configurable - Define known devices with friendly aliases

Installation

Requires Python 3.11 or higher.

Using uv (recommended)

uv tool install router-cli

Using pip

pip install router-cli

From source

git clone https://github.com/d3vr/router-cli
cd router-cli
uv sync

Configuration

Create a configuration file at ~/.config/router/config.toml:

[router]
ip = "192.168.1.1"
username = "admin"
password = "your_password_here"

# Optional: Define known devices for colorized output
[known_devices]
"AA:BB:CC:DD:EE:FF" = "My Phone"
"11:22:33:44:55:66" = "Smart TV"
"DE:AD:BE:EF:00:01" = "Work Laptop"

The tool searches for configuration in the following locations (in order):

  1. ./config.toml (current directory)
  2. ~/.config/router/config.toml
  3. /etc/router/config.toml

Usage

Quick Overview

router overview

Shows a dashboard with connection status, sync rates, connected devices, and warnings:

============================================================
                      ROUTER OVERVIEW
============================================================

CONNECTION
  ADSL Status:        Showtime
  Sync Rate:          8180 / 1022 Kbps (down/up)
  SNR Margin:         6.5 / 12.0 dB
  Default Gateway:    10.0.0.1
  WAN IP:             203.0.113.45 (Connected)

NETWORK
  Router IP:          192.168.1.1
  SSID:               MyNetwork
  Wireless Clients:   3
  DHCP Leases:        5

DEVICES
  My Phone          AA:BB:CC:DD:EE:FF  192.168.1.100  ⏱ 22:45:30
  Smart TV          11:22:33:44:55:66  192.168.1.101  ⏱ 20:15:45
  unknown-device    CC:DD:EE:FF:00:11  192.168.1.102  ⏱ 18:30:00

WARNINGS
  Unknown devices on network: 1

============================================================

Available Commands

Command Description
router status Display full router status (system, internet, wireless, local network)
router overview Show quick dashboard with highlights
router clients List connected wireless clients
router dhcp Show DHCP leases with expiration times
router stats Show network interface and ADSL statistics
router routes Display the kernel routing table
router logs Show system logs
router reboot Reboot the router

Command Details

Status

router status

Displays comprehensive router information:

  • System info (model, firmware, date/time)
  • Internet info (gateway, DNS servers, WAN connections)
  • Wireless info (SSID, MAC, security mode)
  • Local network (IP, subnet, DHCP status)

Wireless Clients

router clients

Lists all connected wireless devices with association and authorization status.

DHCP Leases

router dhcp

Shows all active DHCP leases with device names, MAC addresses, IP addresses, and lease expiration times.

Network Statistics

router stats

Displays detailed statistics including:

  • LAN interface traffic (bytes, packets, errors, drops)
  • WAN interface traffic
  • ADSL line metrics (sync rate, SNR margin, attenuation, output power)

System Logs

router logs                    # Show all logs
router logs --tail 20          # Show last 20 entries
router logs --level error      # Filter by severity level
router logs -n 10 -l warning   # Combine options

Routing Table

router routes

Displays the kernel routing table with destination, gateway, subnet mask, flags, metric, and service.

Reboot

router reboot

Sends a reboot command to the router.

Known Devices

The [known_devices] section in your config file maps MAC addresses to friendly names. This enables:

  • Color-coded output: Known devices appear in green, unknown in red
  • Friendly names: See "My Phone" instead of a hostname or MAC address
  • Security awareness: Quickly spot unauthorized devices on your network
[known_devices]
"AA:BB:CC:DD:EE:FF" = "My Phone"
"11:22:33:44:55:66" = "Smart TV"

MAC addresses are matched case-insensitively.

Development

See docs/DEVELOPMENT.md for the full development guide.

Quick Start

git clone https://github.com/d3vr/router-cli
cd router-cli
uv sync --all-groups
uv run pytest

Compatibility

  • Python: 3.11+
  • Router: D-Link DSL-2750U (firmware ME_1.00)

This tool may work with other D-Link routers that share a similar web interface, but has only been tested with the DSL-2750U.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

router_cli-0.1.0.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

router_cli-0.1.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file router_cli-0.1.0.tar.gz.

File metadata

  • Download URL: router_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for router_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1b18acaac74f4d81c82a479286185fa89f28895f55f0e30421522f7ef7f325eb
MD5 0ce8b28c65191c52e5ff4f07d6dfb355
BLAKE2b-256 cb302be3a96b4901666c527e3dd6765a0d732fda7e4d7f128a9aa8a86ba22ceb

See more details on using hashes here.

Provenance

The following attestation bundles were made for router_cli-0.1.0.tar.gz:

Publisher: release.yml on d3vr/router-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file router_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: router_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for router_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b51ea98a29a06d2ba50df43b8706cf7e790ca7f709a3b540ecd91e38fbfde5d
MD5 39170a9a01522e35f2228cc96094324a
BLAKE2b-256 12f68566a5437cce416ce1669b5c45d462e0e4a7cf004aa09d340f387de0c664

See more details on using hashes here.

Provenance

The following attestation bundles were made for router_cli-0.1.0-py3-none-any.whl:

Publisher: release.yml on d3vr/router-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page