0044_MobaXterm macros: 02.Debian-Network Assessment

2.1 Network Management Services
2.2 Network Hardware
2.3 Interfaces (+ Interface Statistics)
2.4 Physical Link (ethtool)
2.5 Interface Errors
2.6 Bridge / VLAN (+ FDB)
2.7 Bonding Configuration
2.8 Network Configuration (Interfaces/Netplan)
2.9 Routing (+ Tables, Policy & Neighbors)
2.10 DNS Mappings (/etc/hosts)
2.11 Listening Ports (ss)
2.12 Connectivity Checks (Ping & DNS Resolution)
2.13 Proxy Configuration (Env/APT/wget)
2.14 RPC / NFS Services
2.15 Dynamic Routing (FRR/BIRD/OSPFd)
2.16 Time Synchronization (Chrony/NTP)
2.17 Firewall Quick Check (nftables/iptables/UFW)

Root rights need!

Copy–>Past

echo "==================== 02. NETWORK ASSESSMENT ===================="; printf "\n"; echo "2.1 NETWORK MANAGEMENT SERVICES"; echo "NetworkManager   : $(systemctl is-active NetworkManager 2>/dev/null || echo not-installed)"; echo "networking       : $(systemctl is-active networking 2>/dev/null || echo not-installed)"; echo "systemd-networkd : $(systemctl is-active systemd-networkd 2>/dev/null || echo not-installed)"; printf "\n%.0s" {1..3}; echo "2.2 NETWORK HARDWARE"; lspci | grep -Ei 'ethernet|network' || echo "No PCI network adapters found"; printf "\n%.0s" {1..3}; echo "2.3 INTERFACES"; ip -br link; printf "\n"; ip -br addr; printf "\n--- Interface Statistics ---\n"; ip -s link; printf "\n%.0s" {1..3}; echo "2.4 PHYSICAL LINK"; for IF in /sys/class/net/*; do IF=$(basename "$IF"); [ "$IF" = "lo" ] && continue; [ ! -e "/sys/class/net/$IF/device" ] && continue; echo "--- $IF ---"; ethtool "$IF" 2>/dev/null | grep -E 'Speed|Duplex|Auto-negotiation|Link detected' || echo "No ethtool data"; done; printf "\n%.0s" {1..3}; echo "2.5 INTERFACE ERRORS"; for IF in $(ip -o link show | awk -F': ' '{print $2}' | cut -d@ -f1); do [ ! -d "/sys/class/net/$IF/statistics" ] && continue; printf "%-12s RX_ERR:%-8s RX_DROP:%-8s TX_ERR:%-8s TX_DROP:%-8s\n" "$IF" "$(cat "/sys/class/net/$IF/statistics/rx_errors")" "$(cat "/sys/class/net/$IF/statistics/rx_dropped")" "$(cat "/sys/class/net/$IF/statistics/tx_errors")" "$(cat "/sys/class/net/$IF/statistics/tx_dropped")"; done; printf "\n%.0s" {1..3}; echo "2.6 BRIDGE / VLAN"; echo "--- Bridges ---"; ip -br link show type bridge; printf "\n--- Bridge Links ---\n"; bridge link 2>/dev/null; printf "\n--- Bridge VLANs ---\n"; bridge vlan 2>/dev/null; printf "\n--- Forwarding Database ---\n"; bridge fdb show 2>/dev/null | head -80; printf "\n%.0s" {1..3}; echo "2.7 BONDING"; if [ -d /proc/net/bonding ]; then for B in /proc/net/bonding/*; do echo "--- $(basename "$B") ---"; cat "$B"; printf "\n"; done; else echo "No bonding configuration found"; fi; printf "\n%.0s" {1..3}; echo "2.8 NETWORK CONFIGURATION"; echo "--- /etc/network/interfaces ---"; cat /etc/network/interfaces 2>/dev/null || echo "Not found"; printf "\n--- Netplan ---\n"; if compgen -G "/etc/netplan/*.yaml" >/dev/null; then cat /etc/netplan/*.yaml 2>/dev/null; else echo "No netplan configuration"; fi; printf "\n%.0s" {1..3}; echo "2.9 ROUTING"; echo "--- Default Gateway ---"; ip route show default; printf "\n--- Routing Table ---\n"; ip route; printf "\n--- Policy Routing ---\n"; ip rule; printf "\n--- Detailed Routes ---\n"; ip -details route; printf "\n--- Neighbor Table ---\n"; ip neigh; printf "\n%.0s" {1..3}; echo "2.10 DNS"; resolvectl status 2>/dev/null || cat /etc/resolv.conf; printf "\n--- /etc/hosts ---\n"; cat /etc/hosts; printf "\n%.0s" {1..3}; echo "2.11 LISTENING PORTS"; ss -tulpn; printf "\n%.0s" {1..3}; echo "2.12 CONNECTIVITY"; GW=$(ip route | awk '/default/ {print $3; exit}'); echo "Default Gateway : ${GW:-Not configured}"; if [ -n "$GW" ]; then timeout 5 ping -c2 -W2 "$GW"; else echo "Gateway ping skipped"; fi; printf "\n"; DNS=$(awk '/^nameserver/ {print $2; exit}' /etc/resolv.conf); echo "DNS Server : ${DNS:-Unknown}"; if [ -n "$DNS" ]; then timeout 5 ping -c2 -W2 "$DNS"; else echo "DNS server ping skipped"; fi; printf "\n--- Internet (Cloudflare 1.1.1.1) ---\n"; timeout 5 ping -c2 -W2 1.1.1.1; printf "\n--- Internet (Google DNS 8.8.8.8) ---\n"; timeout 5 ping -c2 -W2 8.8.8.8; printf "\n--- DNS Resolution ---\n"; getent hosts google.com || echo "DNS resolution failed"; printf "\n--- Internet by Name ---\n"; timeout 5 ping -c2 -W2 google.com; printf "\n%.0s" {1..3}; echo "2.13 PROXY CONFIGURATION"; echo "--- Environment Variables ---"; env | grep -i proxy || echo "No proxy environment variables"; printf "\n--- APT Proxy ---\n"; grep -R "Acquire::.*Proxy" /etc/apt/apt.conf* 2>/dev/null || echo "No APT proxy configured"; printf "\n--- Systemd Environment ---\n"; systemctl show-environment | grep -i proxy || echo "No systemd proxy variables"; printf "\n--- wget Proxy ---\n"; grep -i proxy ~/.wgetrc /etc/wgetrc 2>/dev/null || echo "No wget proxy configuration"; printf "\n%.0s" {1..3}; echo "2.14 RPC / NFS"; echo "rpcbind : $(systemctl is-active rpcbind 2>/dev/null || echo inactive)"; printf "\n"; timeout 5 rpcinfo -p 2>/dev/null || echo "rpcinfo unavailable"; printf "\n%.0s" {1..3}; echo "2.15 DYNAMIC ROUTING"; echo "FRR   : $(systemctl is-active frr 2>/dev/null || echo not-installed)"; echo "BIRD  : $(systemctl is-active bird 2>/dev/null || echo not-installed)"; echo "OSPFd : $(systemctl is-active ospfd 2>/dev/null || echo not-installed)"; printf "\n%.0s" {1..3}; echo "2.16 TIME SYNCHRONIZATION"; timedatectl; printf "\n"; echo "chronyd           : $(systemctl is-active chronyd 2>/dev/null || echo not-installed)"; echo "chrony            : $(systemctl is-active chrony 2>/dev/null || echo not-installed)"; echo "systemd-timesyncd : $(systemctl is-active systemd-timesyncd 2>/dev/null || echo not-installed)"; echo "ntp               : $(systemctl is-active ntp 2>/dev/null || echo not-installed)"; echo "ntpd              : $(systemctl is-active ntpd 2>/dev/null || echo not-installed)"; printf "\n%.0s" {1..3}; echo "2.17 FIREWALL QUICK CHECK"; echo "nftables : $(systemctl is-active nftables 2>/dev/null || echo inactive)"; printf "\n"; if command -v nft >/dev/null 2>&1; then echo "--- nftables ruleset ---"; nft list ruleset 2>/dev/null | head -80; else echo "nft command not found"; fi; printf "\n--- iptables ---\n"; iptables -L -n -v 2>/dev/null | head -80 || echo "iptables unavailable"; printf "\n--- ip6tables ---\n"; ip6tables -L -n -v 2>/dev/null | head -80 || echo "ip6tables unavailable"; printf "\n--- UFW ---\n"; ufw status verbose 2>/dev/null || echo "UFW not installed"
# ==================== 02. NETWORK ASSESSMENT ====================
echo "==================== 02. NETWORK ASSESSMENT ===================="
printf "\n"

# --- 2.1 NETWORK MANAGEMENT SERVICES ---
echo "2.1 NETWORK MANAGEMENT SERVICES"
echo "NetworkManager   : $(systemctl is-active NetworkManager 2>/dev/null || echo not-installed)"
echo "networking       : $(systemctl is-active networking 2>/dev/null || echo not-installed)"
echo "systemd-networkd : $(systemctl is-active systemd-networkd 2>/dev/null || echo not-installed)"
printf "\n%.0s" {1..3}

# --- 2.2 NETWORK HARDWARE ---
echo "2.2 NETWORK HARDWARE"
lspci | grep -Ei 'ethernet|network' || echo "No PCI network adapters found"
printf "\n%.0s" {1..3}

# --- 2.3 INTERFACES ---
echo "2.3 INTERFACES"
ip -br link
printf "\n"
ip -br addr
printf "\n\n--- Interface Statistics ---\n"
ip -s link
printf "\n%.0s" {1..3}

# --- 2.4 PHYSICAL LINK ---
echo "2.4 PHYSICAL LINK"
for IF in /sys/class/net/*; do
    IF=$(basename "$IF")
    [ "$IF" = "lo" ] && continue
    [ ! -e "/sys/class/net/$IF/device" ] && continue
    echo "--- $IF ---"
    ethtool "$IF" 2>/dev/null | grep -E 'Speed|Duplex|Auto-negotiation|Link detected' || echo "No ethtool data"
done
printf "\n%.0s" {1..3}

# --- 2.5 INTERFACE ERRORS ---
echo "2.5 INTERFACE ERRORS"
for IF in $(ip -o link show | awk -F': ' '{print $2}' | cut -d@ -f1); do
    [ ! -d "/sys/class/net/$IF/statistics" ] && continue
    printf "%-12s RX_ERR:%-8s RX_DROP:%-8s TX_ERR:%-8s TX_DROP:%-8s\n" \
        "$IF" \
        "$(cat "/sys/class/net/$IF/statistics/rx_errors")" \
        "$(cat "/sys/class/net/$IF/statistics/rx_dropped")" \
        "$(cat "/sys/class/net/$IF/statistics/tx_errors")" \
        "$(cat "/sys/class/net/$IF/statistics/tx_dropped")"
done
printf "\n%.0s" {1..3}

# --- 2.6 BRIDGE / VLAN ---
echo "2.6 BRIDGE / VLAN"
echo "--- Bridges ---"
ip -br link show type bridge
printf "\n--- Bridge Links ---\n"
bridge link 2>/dev/null
printf "\n--- Bridge VLANs ---\n"
bridge vlan 2>/dev/null
printf "\n--- Forwarding Database ---\n"
bridge fdb show 2>/dev/null | head -80
printf "\n%.0s" {1..3}

# --- 2.7 BONDING ---
echo "2.7 BONDING"
if [ -d /proc/net/bonding ]; then
    for B in /proc/net/bonding/*; do
        echo "--- $(basename "$B") ---"
        cat "$B"
        printf "\n"
    done
else
    echo "No bonding configuration found"
fi
printf "\n%.0s" {1..3}

# --- 2.8 NETWORK CONFIGURATION ---
echo "2.8 NETWORK CONFIGURATION"
echo "--- /etc/network/interfaces ---"
cat /etc/network/interfaces 2>/dev/null || echo "Not found"
printf "\n--- Netplan ---\n"
if compgen -G "/etc/netplan/*.yaml" >/dev/null; then
    cat /etc/netplan/*.yaml 2>/dev/null
else
    echo "No netplan configuration"
fi
printf "\n%.0s" {1..3}

# --- 2.9 ROUTING ---
echo "2.9 ROUTING"
echo "--- Default Gateway ---"
ip route show default
printf "\n--- Routing Table ---\n"
ip route
printf "\n--- Policy Routing ---\n"
ip rule
printf "\n--- Detailed Routes ---\n"
ip -details route
printf "\n--- Neighbor Table ---\n"
ip neigh
printf "\n%.0s" {1..3}

# --- 2.10 DNS ---
echo "2.10 DNS"
resolvectl status 2>/dev/null || cat /etc/resolv.conf
printf "\n--- /etc/hosts ---\n"
cat /etc/hosts
printf "\n%.0s" {1..3}

# --- 2.11 LISTENING PORTS ---
echo "2.11 LISTENING PORTS"
ss -tulpn
printf "\n%.0s" {1..3}

# --- 2.12 CONNECTIVITY ---
echo "2.12 CONNECTIVITY"
GW=$(ip route | awk '/default/ {print $3; exit}')
echo "Default Gateway : ${GW:-Not configured}"
if [ -n "$GW" ]; then
    timeout 5 ping -c2 -W2 "$GW"
else
    echo "Gateway ping skipped"
fi
printf "\n"
DNS=$(awk '/^nameserver/ {print $2; exit}' /etc/resolv.conf)
echo "DNS Server : ${DNS:-Unknown}"
if [ -n "$DNS" ]; then
    timeout 5 ping -c2 -W2 "$DNS"
else
    echo "DNS server ping skipped"
fi
printf "\n--- Internet (Cloudflare 1.1.1.1) ---\n"
timeout 5 ping -c2 -W2 1.1.1.1
printf "\n--- Internet (Google DNS 8.8.8.8) ---\n"
timeout 5 ping -c2 -W2 8.8.8.8
printf "\n--- DNS Resolution ---\n"
getent hosts google.com || echo "DNS resolution failed"
printf "\n--- Internet by Name ---\n"
timeout 5 ping -c2 -W2 google.com
printf "\n%.0s" {1..3}

# --- 2.13 PROXY CONFIGURATION ---
echo "2.13 PROXY CONFIGURATION"
echo "--- Environment Variables ---"
env | grep -i proxy || echo "No proxy environment variables"
printf "\n--- APT Proxy ---\n"
grep -R "Acquire::.*Proxy" /etc/apt/apt.conf* 2>/dev/null || echo "No APT proxy configured"
printf "\n--- Systemd Environment ---\n"
systemctl show-environment | grep -i proxy || echo "No systemd proxy variables"
printf "\n--- wget Proxy ---\n"
grep -i proxy ~/.wgetrc /etc/wgetrc 2>/dev/null || echo "No wget proxy configuration"
printf "\n%.0s" {1..3}

# --- 2.14 RPC / NFS ---
echo "2.14 RPC / NFS"
echo "rpcbind : $(systemctl is-active rpcbind 2>/dev/null || echo inactive)"
printf "\n"
timeout 5 rpcinfo -p 2>/dev/null || echo "rpcinfo unavailable"
printf "\n%.0s" {1..3}

# --- 2.15 DYNAMIC ROUTING ---
echo "2.15 DYNAMIC ROUTING"
echo "FRR   : $(systemctl is-active frr 2>/dev/null || echo not-installed)"
echo "BIRD  : $(systemctl is-active bird 2>/dev/null || echo not-installed)"
echo "OSPFd : $(systemctl is-active ospfd 2>/dev/null || echo not-installed)"
printf "\n%.0s" {1..3}

# --- 2.16 TIME SYNCHRONIZATION ---
echo "2.16 TIME SYNCHRONIZATION"
timedatectl
printf "\n"
echo "chronyd           : $(systemctl is-active chronyd 2>/dev/null || echo not-installed)"
echo "chrony            : $(systemctl is-active chrony 2>/dev/null || echo not-installed)"
echo "systemd-timesyncd : $(systemctl is-active systemd-timesyncd 2>/dev/null || echo not-installed)"
echo "ntp               : $(systemctl is-active ntp 2>/dev/null || echo not-installed)"
echo "ntpd              : $(systemctl is-active ntpd 2>/dev/null || echo not-installed)"
printf "\n%.0s" {1..3}

# --- 2.17 FIREWALL QUICK CHECK ---
echo "2.17 FIREWALL QUICK CHECK"
echo "nftables : $(systemctl is-active nftables 2>/dev/null || echo inactive)"
printf "\n"
if command -v nft >/dev/null 2>&1; then
    echo "--- nftables ruleset ---"
    nft list ruleset 2>/dev/null | head -80
else
    echo "nft command not found"
fi
printf "\n--- iptables ---\n"
iptables -L -n -v 2>/dev/null | head -80 || echo "iptables unavailable"
printf "\n--- ip6tables ---\n"
ip6tables -L -n -v 2>/dev/null | head -80 || echo "ip6tables unavailable"
printf "\n--- UFW ---\n"
ufw status verbose 2>/dev/null || echo "UFW not installed"