reseau-ethernet.sh

ODROID-M1 (Hardkernel) · File : reseau-ethernet.sh · Language : Bash · Use case : Configurer une adresse IP statique sur le port Ethernet

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 ODROID-M1 (Rockchip RK3568B2, 4 Cortex-A55, 4-8 GB) running Armbian or Ubuntu Hardkernel, with M.2 NVMe, SATA 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; the RK3568’s two GPIO chips (gpiochip0/gpiochip3) show in gpiodetect, map the pin with gpioinfo.

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"

← Back to the board