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.10 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
# Use MAC addresses for devices with stable MACs
# Use hostnames for devices with random MACs (like Android)
[known_devices]
"AA:BB:CC:DD:EE:FF" = "My Phone"
"11:22:33:44:55:66" = "Smart TV"
"android-abc123" = "John's Pixel"

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

Global Options

All commands support these global options:

router --ip 192.168.1.1 --user admin --pass secret status
router --json clients
Option Environment Variable Description
--ip ADDRESS ROUTER_IP Router IP address
--user USERNAME ROUTER_USER Username for authentication
--pass PASSWORD ROUTER_PASS Password for authentication
--json - Output in JSON format (for scripting)

Configuration priority: CLI flags > environment variables > config file > defaults

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 or hostnames 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]
# By MAC address (for devices with stable MACs)
"AA:BB:CC:DD:EE:FF" = "My Phone"
"11:22:33:44:55:66" = "Smart TV"

# By hostname (for devices with random MACs, like some Android phones)
"android-abc123def" = "John's Pixel"
"Galaxy-S24" = "Sarah's Phone"

MAC addresses are identified by their format (XX:XX:XX:XX:XX:XX) and matched case-insensitively.

Hostnames are useful for Android and iOS devices that use MAC address randomization for privacy. These devices typically maintain a consistent hostname even when their MAC changes. Hostnames are also 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.10+
  • 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.3.0.tar.gz (19.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.3.0-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: router_cli-0.3.0.tar.gz
  • Upload date:
  • Size: 19.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.3.0.tar.gz
Algorithm Hash digest
SHA256 25ed3351fbcc4c2c4f9852d649680ccc85933ee22d755e24c2df82b92ea89f56
MD5 ae73fa86c58030645554990120497bb2
BLAKE2b-256 2302c24e56680eaf3aa5518025573dcf1541a34c428e2d5a98d9caf5e2045fc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for router_cli-0.3.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.3.0-py3-none-any.whl.

File metadata

  • Download URL: router_cli-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 23.4 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3baccdf84d7ab5f0b1a6a844a398ed49163459324d01682675b1eb2ee6a6e179
MD5 964762ae3e8abaa595cf0c553a3e1b3f
BLAKE2b-256 ef6e487d54cd9f8c90fb556225e07e053d6e2d947e2143bb05dcf764afafb727

See more details on using hashes here.

Provenance

The following attestation bundles were made for router_cli-0.3.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