reseau-ethernet.sh
In a fixed installation, a static IP avoids hunting the board in the DHCP lease list. The script creates (or fixes) a manual NetworkManager profile on the Ethernet port, then pings the gateway to verify.
Hardware
An Orange Pi 3B (Rockchip RK3566, 4 Cortex-A55, 2-8 GB) running Armbian, with an M.2 socket for NVMe/SATA SSD and gigabit Ethernet. One Ethernet cable to the router/switch.
Wiring
RJ45 cable on the board Ethernet port. Pick an address outside the DHCP range to avoid conflicts.
How it works
nmcli connection add sets ipv4.method manual with address/gateway/DNS; connection up applies it. The control ping validates layer 3 immediately.
Running it
On Armbian: apt install gpiod python3-gpiod; identify the 40-pin header GPIO chip with gpiodetect and gpioinfo, then run the script (sudo the first time).
Variants
Add a second DNS, a search domain (ipv4.dns-search), or flip the profile back to DHCP when moving (ipv4.method auto).
reseau-ethernet.sh
#!/bin/bash
# IP statique sur Ethernet via nmcli (plus propre que ifconfig a la main).
# Usage : ./reseau-ethernet.sh 192.168.1.50/24 192.168.1.1 8.8.8.8
set -e
IP="${1:?Usage: $0 IP/prefixe passerelle DNS [interface]}"
PASSERELLE="${2:?passerelle requise}"
DNS="${3:?DNS requis}"
echo "== Interfaces =="
ip -brief link
DEV="${4:-$(ip -brief link | awk '$2=="up" && $1!~"lo|wl"{print $1; exit}')}"
[ -n "$DEV" ] || { echo "aucune interface up"; exit 1; }
echo "== Profil statique sur $DEV =="
nmcli connection add type ethernet con-name statique-$DEV ifname "$DEV" \
ipv4.method manual ipv4.addresses "$IP" \
ipv4.gateway "$PASSERELLE" ipv4.dns "$DNS" || \
nmcli connection modify statique-$DEV \
ipv4.addresses "$IP" ipv4.gateway "$PASSERELLE" ipv4.dns "$DNS"
nmcli connection up statique-$DEV
echo "== Resultat =="
ip -4 -brief addr show "$DEV"
ping -c 2 -W 2 "$PASSERELLE" && echo "passerelle joignable"