- Go 99.9%
- Shell 0.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo/workflows | ||
| cmd/dellctl | ||
| docs | ||
| internal | ||
| scripts | ||
| .gitignore | ||
| .golangci.yml | ||
| .goreleaser.yaml | ||
| AGENTS.md | ||
| CHANGELOG.md | ||
| CLAUDE.md | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| mise.toml | ||
| README.md | ||
| releasaurus.toml | ||
| renovate.json | ||
dellctl
CLI for Dell Networking X-Series (X1026P) smart switches over their web XML API.
The X1026P has no usable remote API. Its telnet CLI is a reduced subset. It cannot set switchport modes, VLAN names or DHCP. Its web UI is a JavaScript app. dellctl talks to the same XML endpoints that the web UI uses. It names its commands after Cisco IOS / Dell OS6, so they read like a switch CLI. The goal is full coverage: every setting and every status page of the web UI has a command.
dellctl is written against firmware 3.0.1.9. Other X-Series models and firmware probably share the API, but they are untested.
Install
Download a release archive for your OS and architecture from https://git.dcunha.io/Exikle/dellctl/releases. Compare it with checksums.txt, and put dellctl on your PATH. The archives are named dellctl_<version>_<os>_<arch>.tar.gz (.zip on Windows) for linux, darwin and windows on amd64 and arm64.
To install with mise, use the command below. The Forgejo backend of mise needs the API URL of the instance.
mise use -g 'forgejo:Exikle/dellctl[api_url=https://git.dcunha.io/api/v1]'
or in mise.toml:
[tools]
"forgejo:Exikle/dellctl" = { version = "latest", api_url = "https://git.dcunha.io/api/v1" }
To install with Go:
go install git.dcunha.io/Exikle/dellctl/cmd/dellctl@latest
Or build from source:
mise run build # binary at ./bin/dellctl
dellctl --version prints the release version.
Configure
dellctl reads settings from flags first, then the environment, then the config file. For the password, the order is --password, DELLCTL_PASSWORD, password_command, password.
export DELLCTL_HOST=192.0.2.10
export DELLCTL_USER=admin # default admin
export DELLCTL_PASSWORD=...
| Var | Flag | Default | Notes |
|---|---|---|---|
DELLCTL_HOST |
--host |
-- | address or host:port |
DELLCTL_USER |
--user |
admin |
|
DELLCTL_PASSWORD |
--password |
-- | prefer the env var or password_command. Never printed. |
DELLCTL_CA_FILE |
--ca-file |
-- | PEM bundle. Turns certificate checks on |
The factory default login is admin / admin. Change it.
An optional file holds named switches. The file is ~/.config/dellctl/config.yaml (or $XDG_CONFIG_HOME/dellctl/config.yaml, or the file that --config names):
default: lab
switches:
lab:
host: 192.0.2.6
user: admin
password_command: ["op", "read", "op://Vault/lab-switch/password"]
core:
host: 192.0.2.7
password_command: ["op", "read", "op://Vault/core-switch/password"]
insecure: false
ca_file: /etc/ssl/core-switch.pem
password_command is an argument list. dellctl runs it directly without a shell, so quoting, pipes and ~ expansion do not work. The standard output of the command, without trailing newlines, is the password. The command runs only when neither --password nor DELLCTL_PASSWORD is set. It takes priority over a plain password: entry. If the command fails or prints nothing, dellctl stops with an error that names the command and its exit status. dellctl never shows the output of the command. A plain password: in the file still works, but keep it out of version control.
Pick a switch with --switch core. If the file has no default: and lists exactly one switch, dellctl uses that switch.
The switch ships a self-signed certificate, so --insecure defaults to true. To verify the certificate, pass --ca-file (or set insecure: false in the config).
Global flags
| Flag | Meaning |
|---|---|
--json |
JSON output for the show commands |
--dry-run |
print the XML a write would POST and exit 0. Sends nothing |
--yes |
confirm dangerous operations (reload, ip interface, copy ... image) |
--timeout |
per-request timeout (default 120s) |
--switch, --config, --host, --user, --insecure, --ca-file |
connection |
--dry-run still logs in and reads. Some writes need the current state, for example trunk allowed vlan set. It never POSTs.
Every show command prints a table by default and prints JSON with --json. It never prints secrets. Every write supports --dry-run. Commands that can cut off management access show a warning and need --yes.
Commands
Ports are written gi1/0/3, 1/0/3 or 3. Ranges and lists work: gi1/0/1-4,7.
Command index by area
Each area has its own reference page. The page lists every command and its flags. It also lists the API sections that the area uses, the web UI page that the area replaces and what the area does not cover.
| Area | Covers | Reference |
|---|---|---|
| core | session, firmware transfers, show running-config, the commands below |
docs/core.md |
| system | system information, hostname and general device settings | docs/system.md |
| mgmt-security | users, passwords, authentication, access profiles, TACACS+, RADIUS | docs/mgmt-security.md |
| files-logs | firmware and configuration files, backup, restore, logs | docs/files-logs.md |
| stats-diag | interface and RMON counters, cable test, optical diagnostics | docs/stats-diag.md |
| vlan-advanced | protocol VLANs, GVRP, GARP, private VLAN, voice VLAN | docs/vlan-advanced.md |
| ports | port configuration, jumbo frames, protected ports, mirroring, UDLD | docs/ports.md |
| mac-poe | static and dynamic MAC tables, PoE, Green Ethernet | docs/mac-poe.md |
| stp-lag | spanning tree (STP, RSTP, MSTP), LAG and LACP | docs/stp-lag.md |
| lldp | LLDP and LLDP-MED | docs/lldp.md |
| l3 | IPv4 and IPv6 addressing, routing mode, routes, ARP | docs/l3.md |
| qos | CoS and DSCP mapping, queues, bandwidth, policers, policies | docs/qos.md |
| security | 802.1X, storm control, port security, dynamic ARP inspection, ACLs | docs/security.md |
| snmp | SNMP global settings, views, access, users, communities, notifications | docs/snmp.md |
| multicast | IGMP and MLD snooping, multicast groups, multicast TV VLAN | docs/multicast.md |
| dhcp-sflow | DHCP snooping, relay and server, sFlow | docs/dhcp-sflow.md |
The table gives the scope of each area. The page for an area exists after that area has landed.
Show
dellctl show version firmware, boot code, model, serial, MAC, uptime
dellctl show vlan [--id N] VLAN, name, tagged ports, untagged ports
dellctl show interfaces status [<ports>]
port, link, speed, duplex, mode, PVID/native
dellctl show interfaces switchport <port> mode and VLAN membership of one port
dellctl show ip interface VLAN interfaces and the default gateway
dellctl show running-config [--raw] IOS-style text of the non-default settings of every area
dellctl show raw <Section>... raw XML of any wcd section
dellctl show bootvar active / next image, both versions, boot code
dellctl show copy-status progress of the last file transfer
show raw takes the section names exactly as the API spells them. It also accepts query arguments, so every section stays reachable:
dellctl show raw PoEPSEInterfaceList
dellctl show raw 'VLANMembershipList&VLANID=1001' VLANList
show running-config calls the renderer that every area registers and merges the lines. interface gi1/0/5 and interface port-channel 1 each appear once, with the lines of all areas. The output has blocks, and the children in a block have a one-space indent. --raw keeps the old behavior: it prints the mapped sections as XML.
VLANs
dellctl vlan create <ids> [--name NAME] 1001 or 1001,1005-1007
dellctl vlan name <id> <name>
dellctl vlan delete <ids>
dellctl vlan auth-not-required <ids> enable|disable
vlan delete refuses VLAN 1. It also refuses a VLAN that carries the management IP interface, unless you give --yes.
Ports
dellctl interface <ports> switchport mode access|trunk|general|customer
dellctl interface <ports> switchport mode private-vlan promiscuous|host
dellctl interface <ports> switchport access vlan N|none
dellctl interface <ports> switchport access multicast-tv vlan N|none
dellctl interface <ports> switchport trunk native vlan N|none
dellctl interface <ports> switchport trunk allowed vlan add|remove|set <list>
dellctl interface <ports> switchport general pvid N
dellctl interface <ports> switchport general acceptable-frame-type all|tagged-only|untagged-only
dellctl interface <ports> switchport general ingress-filtering enable|disable
dellctl interface <ports> switchport general allowed vlan add|remove|set <list> tagged|untagged
dellctl interface <ports> switchport general forbidden vlan add|remove|set <list>
dellctl interface <ports> switchport customer vlan N|none
dellctl interface <ports> switchport reserved-vlan N|none
dellctl interface <ports> description TEXT
switchport mode reads the port and sends one set of the mode, like Save in the web UI. The VLAN lists of the mode that the port leaves stay on the switch, as in the UI. If a port is already in the requested mode, dellctl does not change it. access vlan, trunk native vlan and trunk allowed vlan read the port first. They refuse if the port is in a different mode, so change the mode before you change the VLANs. trunk allowed vlan set sends only the difference: a delete for the VLANs to drop and a set for the VLANs to add, in one request. The web UI edits the list in the same way.
General-mode lists follow the rules of the UI. A port can join only VLANs that exist. A VLAN is in only one of the tagged, untagged and forbidden lists. The none forms (multicast TV VLAN, customer VLAN, reserved VLAN) send a restore of the VLAN entry of the port. Then they send a set that applies the rest of the current settings of the port again. What restore resets on the switch is unverified (see docs/core.md).
The areas add the other port keywords (speed, duplex, LLDP, spanning-tree, storm control, power, ...). If you give dellctl interface an unknown keyword, it lists the keywords that are compiled in.
LAGs
There is one way to address a LAG, as in IOS (interface port-channel N): dellctl port-channel <lags> <keyword> .... These commands run the same command: interface port-channel 3 ..., interface po3 ... and interface lag3 .... LAGs are 3, lag3, po3 or port-channel3. Ranges and lists work (1-3,5). The words after the list are the words that interface <ports> takes, for the keywords that an area has a LAG page for:
dellctl port-channel <lags> description TEXT | no description
dellctl port-channel <lags> [no] shutdown
dellctl port-channel <lags> speed 10|100|1000|auto
dellctl port-channel <lags> flow-control on|off|auto
dellctl port-channel <lags> advertise max|10,100,1000
dellctl port-channel <lags> mode static|lacp
dellctl port-channel <lags> [no] spanning-tree <setting>
dellctl port-channel <lags> switchport mode access|trunk|general|customer|private-vlan ...
dellctl port-channel <lags> [no] gvrp enable|vlan-creation|registration
dellctl port-channel <lags> [no] voice-vlan static|auto [secured]
dellctl port-channel <lags> [no] port-security|access-group|arp-inspection|protocol-filter ...
dellctl port-channel <lags> [no] dhcp-snooping trust
dellctl port-channel <lags> [no] qos cos N | traffic-shape CIR [CBS] | service-policy input NAME
dellctl port-channel --help lists the keywords that are compiled in. LAG membership is channel-group (see docs/stp-lag.md).
Multicast TV VLAN
dellctl bridge multicast tv-vlan mapping add|remove <vlan> <group-ip>
dellctl show bridge multicast tv-vlan mapping|membership [--vlan N]
dellctl interface <ports> switchport access multicast-tv vlan N|none (receiver VLAN of a port; port-channel for a LAG)
Management address
dellctl ip interface vlan <N> dhcp --yes
dellctl ip interface vlan <N> static <ip/prefix> [--gateway IP] --yes
dellctl ip interface vlan <N> remove --yes
dellctl ip default-gateway <ip|none> --yes
These commands refuse to run without --yes. They move the address that you are connected to. If you cannot reach the new address from where you are, you are locked out. Then you need the console port or the reset button. Move the address in two steps. First put the new VLAN on the uplink. Then keep the old address until the new address answers.
Save, reboot, firmware
dellctl write memory copy running config to startup config
dellctl reload --yes reboot (unsaved changes are lost)
dellctl show bootvar image slots, active and next-boot image, boot code
dellctl show copy-status progress of the last file transfer
dellctl boot system image-1|image-2 image to boot next; takes effect at reload
dellctl copy file://<path> image --yes upload a software image over HTTP
dellctl copy file://<path> boot --yes upload boot code over HTTP
dellctl copy tftp://IP/NAME image|boot --yes the switch pulls the file itself
Config changes are live at once. They survive a reboot only after write memory.
An upload writes the inactive image slot. copy follows the transfer in the same way as the web UI. It polls the transfer status of the switch and prints progress on stderr. It ends with success or with the own error message of the switch (--no-wait returns at once). Dell's release notes give this order: copy the boot code (.rfb, destination boot) before the software image (.ros, destination image). Then run boot system for the new slot and run reload. copy also moves configuration files (see docs/files-logs.md). After a firmware upgrade, the first boot can spend 10 to 15 minutes to update the CPLD. Do not cut power.
How the API works
The web UI is a single-page app, and everything it does is plain HTTPS requests. dellctl is a client for those requests.
-
Transport: HTTPS with a self-signed certificate on an old TLS stack. dellctl enables the legacy RSA/CBC suites that Go leaves off by default. The server is GoAhead-Webs. It resets the TCP connection right after a response, so a read error after a complete body is not an error. dellctl writes each request as HTTP/1.0 on its own connection, like the
curl --http1.0calls that were used to work this out. Some static files come back gzip-compressed without aContent-Encodingheader, so dellctl looks for the gzip magic bytes. Large reads sometimes stall or cut off in the middle of the body. dellctl retries a read that does not end in</ResponseData>. -
Base path: Everything lives under a prefix that is different for each device, like
/cs4e4296f1/.GET /answers302with that prefix inLocation. dellctl discovers the prefix and does not hard-code it. -
Login:
GET <base>config/System.xml?action=login&user=U&password=Preturns XML with<statusCode>: 0 ok, 4 bad credentials, 5 too many users, 9 password expired, 10 and 12 weak password, 13 password will expire. If the login works, the response headersessionID: UserId=<client-ip>&<hex>&;path=/is the session. The value before;pathgoes back as the cookiesessionID=<value>. dellctl percent-escapes#,%,&and+in credentials, as the login page does. -
Logout: The
logoff()function of the UI doesGET ./System.xml?action=logout. The URL is relative to the page that also serveswcd. So dellctl requests<base>System.xml?action=logoutwith the session cookie when it finishes. The reply is a redirect or HTML, not aResponseDatadocument. The switch has a small user table. A session that you do not end keeps a slot until it times out. -
Read:
GET <base>wcd?{Section1}{Section2&filter=(field=value)}with literal braces. The answer is<ResponseData><DeviceConfiguration><Section type="section">.... The names of the record elements are different for each section (Entry,VLAN,ifEntry,GWEntry). A section whose children are all plain fields is a single record.<statusCode>4</statusCode>withRequest Is not authenticatedmeans that the session expired. Then dellctl logs in again and retries once. -
Write:
POST <base>wcd?{Section}withContent-Type: application/x-www-form-urlencoded; charset=UTF-8and a body like this:<?xml version='1.0' encoding='utf-8'?><DeviceConfiguration><VLANList action="set"><VLAN><VLANID>1001</VLANID><VLANName>HME</VLANName></VLAN></VLANList></DeviceConfiguration>actionisset,add,deleteorrestore. The UI sendsrestorewith only the key to clear single-VLAN fields. How muchrestoreresets is unverified. Send only the fields that change.<statusCode>0</statusCode>is success. Several blocks can share one document and run in order. For list-valued fields such astrunkMemberVLANs,setadds the listed VLANs anddeleteremoves them. So to edit a list, send a delete block and a set block. -
File transfers: Local files go to
POST https://<host>/http_uploadfile?action=N&filename=NAMEasmultipart/form-data, with the file in the fieldsrcFileName. This URL is outside the prefix of the device and needs the session cookie.Nis the destination: 8 software image, 9 boot code, 1 new configuration file, 2 running configuration, 3 startup configuration. TFTP, USB and flash copies are aFileCopywrite instead. Both kinds run in the background. TheLoadStatussection reports them (copyStatusType1 or 2 in progress withbytesTransfered, 3 or 4 failed witherrorMessage, 5 done). AdeleteofLoadStatus(unitID0) clears the record. Backups go the other way throughGET /Http_download?action=N. -
Session cookies: The web UI also sends the cookies
userStatus,DeviceModeandPriviligeLevel. dellctl sends onlysessionID. -
Older MIB-style endpoints: A few pages use
device/<Name>_MIB.xmlGETs and form POSTs instead ofwcd. The areas that need them use the helpers ininternal/domain/wire/mib_*.go(the pages) andinternal/adapters/switchhttp/mib_*.go(the requests).
Mapped sections
The reference page of each area lists the sections that the area uses. These are the sections that the core commands use:
| Section | Used by |
|---|---|
SystemGlobalSetting |
show version, show bootvar (boot code) |
VLANList |
show vlan; vlan create, vlan name, vlan delete |
VLANMembershipList |
show vlan (&VLANID=N, per-VLAN tagged and untagged ports) |
VLANInterfaceISList |
show interfaces; interface ... switchport ... |
Standard802_3List |
show interfaces status; interface ... description |
IPv4InterfaceList |
show ip interface; ip interface vlan |
IPv4GatewayList |
show ip interface; ip interface vlan ... --gateway |
ImageUnitList |
show bootvar, boot system |
GlobalActions |
write memory (copyCnfRun2Start) |
Reload |
reload |
FileCopy |
copy tftp://... image |
LoadStatus |
copy, show copy-status |
/http_uploadfile |
copy file://<path> image (multipart POST outside wcd) |
Switchport mode codes in switchportModeAdmin: 10 general, 11 access, 12 trunk, 13 and 14 private VLAN (promiscuous, host), 15 customer. owner in the IP sections: 1 static, 2 DHCP. Duplex (duplexOperMode): 1 half, 2 full, 3 hybrid, 4 unknown. Speed (speedOper): 10, 100, 1000, 10000 Mb/s, with 4294967295 as the 10G marker.
Performance
VLANInterfaceISList is the slow section. The switch needs about a minute to render the whole table, so the default --timeout is 120s. To fetch a single port, use the key form VLANInterfaceISList&interfaceName=gi1/0/3. It is fast. (The &filter=(...) form is ignored and returns the whole table.) dellctl uses the key form wherever it needs one port: every interface ... write that reads the port first, show interfaces switchport and show interfaces status <ports>. Commands that need every port (show interfaces status without --interface, show running-config) wait for the minute once per run. In scripts, use the single-port forms.
Known gaps
- The port VLAN table renders in about a minute (switch firmware).
show running-configandshow interfaces statuswithout--interfacewait for it once per run. Nothing in the API is faster for the whole table. - One HTTP management session at a time is reliable on this firmware. If you run dellctl in parallel, it can hit "too many users".
- The HTTP upload and the logout path follow the script of the web UI, but they have not been run against hardware in this release. The multipart field name
srcFileNameis the id of the file input of the upload form in the UI script. The HTML of the form itself is not part of the shipped scripts. If the switch refuses a real upload,copy file://<path> image --dry-runshows the exact request. - There is no text configuration in the API. The registered renderers build
show running-configfrom the sections, and it lists only non-default settings. A setting that an area does not render does not appear there. Useshow rawfor those settings.
Development
mise run test # go test -race ./...
mise run lint # gofmt check and go vet
mise run golangci # golangci-lint
mise run build
mise run ci # lint and test: what CI runs
The tests run the write paths against an httptest fake of the switch. The tests assert the exact XML body of each command.
Feature areas add commands from their own files and do not touch the shared ones. The shared files are: registerRoot, registerShow, registerShowInterfaces, registerShowIP, registerInterface/registerInterfaceNo and registerRunningConfig in internal/entry/cli/registry.go. The subcommand hooks for the shared parents (clear, no, test, ip, ipv6, show ipv6), the rich registerInterfaceEx and the port-channel LAG keywords are in internal/entry/cli/core_hooks.go, core_portrun.go and core_lag.go (see docs/core.md, "Registry for areas").
License
MIT