GitHub - publicarray/z-nettool: simple network diagnostic script

2 min read Original article ↗

When cables aren’t labeled and documentation is missing, simple network troubleshooting can take far longer than it should. Questions like "Which switch and port am I connected to?" or "Is this link negotiating at Gigabit?" come up all the time.

This cross-platform tool brings together common network checks in one place to help you diagnose issues faster from the client's point of view, no need to log into every switch (for those not yet on cloud managed network environments).

Download the Latest Release

Features

  • Network interface discovery with speed/duplex status
  • LLDP/CDP neighbor discovery
  • DHCP information gathering
  • Plain text report

Usage

# network report
sudo ./netool

# network report
sudo ./netool -i eth0

Example Report

Select interface:
  1) Embedded LOM 1 Port 1
  2) Local Area Connection* 10
  3) Ethernet 3
  4) vEthernet (HPE Virtual Switch Adapter #1 - Virtual Switch)
Enter number (1..4): 4
Interface:  vEthernet (HPE Virtual Switch Adapter #1 - Virtual Switch)
MAC:        94:40:C9:12:2F:49
IP:         192.168.30.100/24
Link:       up [ethernet 1.00 Gbps]

Switch / VLAN Info (LLDP)
  System: USW-24-PoETechBenchCenter
  Port:   Port 23
  VLAN:   30
  Chassis:E4:38:83:87:AF:6C

Connectivity Tests
  Ping 8.8.8.8:   8.0 ms
  Ping 1.1.1.1:   8.0 ms
  DNS Lookup:     google.com 142.250.76.110
  HTTPS Test:     200

DHCP Lease / Server Detection
DHCP: sending DISCOVER and listening for OFFER...
  Sent DISCOVER (xid=0x30a5e0eb)
  Listening for 30s...

  DHCP OFFER:
    Your IP:   192.168.30.100
    Server ID: 192.168.30.1
    Router:    192.168.30.1
    DNS:       172.64.36.1 172.64.36.2
    Lease:     24h 0m

Zig build

https://ziglang.org/documentation/0.14.1/#Build-Mode

zig build -Doptimize=ReleaseSmall
# Intel macOS:
zig build -Dtarget=x86_64-macos -Dcpu=baseline -Doptimize=ReleaseSmall
# Apple Silicon:
zig build -Dtarget=aarch64-macos -Dcpu=baseline -Doptimize=ReleaseSmall
# Windows:
zig build -Dtarget=x86_64-windows -Dcpu=baseline -Doptimize=ReleaseSmall
# Linux:
zig build -Dtarget=x86_64-linux -Dcpu=baseline -Doptimize=ReleaseSmall

Requirements

  • Root/Administrator privileges
  • Zig 0.15.2
  • Linux: lldpctl