xerxes-nano-poe-ethernet-check.sh
Bash script to check Ethernet interface status, get IP address, and test Internet connectivity.
Hardware: Ethernet cable connected to RJ45 port, PoE 802.3af/at compatible switch. Power jumper set to PoE. Software: Ubuntu Server or JetPack. Execution: chmod +x script.sh && ./script.sh. Check interface name with 'ip link'.
xerxes-nano-poe-ethernet-check.sh
#!/bin/bash
# Script de vérification réseau pour Xerxes Nano (PoE + Gigabit Ethernet)
INTERFACE="eth0" # Ajuster selon ifconfig/ip link
echo "--- Vérification de l'interface $INTERFACE ---"
# Vérifier si l'interface est up
if ip link show $INTERFACE | grep -q "state UP"; then
echo "Interface $INTERFACE : UP"
else
echo "Interface $INTERFACE : DOWN"
exit 1
fi
# Obtenir l'adresse IP
IP=$(ip -4 addr show $INTERFACE | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
if [ -n "$IP" ]; then
echo "Adresse IP : $IP"
else
echo "Aucune adresse IPv4 détectée."
fi
# Test de ping vers 8.8.8.8
echo "Test de connectivité vers 8.8.8.8..."
if ping -c 4 8.8.8.8 > /dev/null; then
echo "Connexion Internet OK."
else
echo "Échec de la connexion Internet."
fi