reseau-ethernet.sh

Placas Libre Computer Amlogic — libre-amlogic (buque insignia: Le Potato AML-S905X-CC) · Archivo : reseau-ethernet.sh · Lenguaje : Bash · Uso : Configurer une adresse IP statique sur le port Ethernet

En una instalación fija, una IP estática evita buscar la placa en el listado DHCP. El script crea (o corrige) un perfil manual de NetworkManager en el puerto Ethernet y luego verifica la pasarela con ping.

Hardware necesario

Una Libre Computer « Le Potato » (Amlogic S905X, 2 GB) con Armbian, alimentada a 5 V/2,5 A micro-USB, con su conector de 40 pines compatible Raspberry Pi. Un cable Ethernet al router/switch.

Cableado

Cable RJ45 en el puerto Ethernet de la placa. Elegir una dirección fuera del rango DHCP para evitar conflictos.

Funcionamiento

nmcli connection add define ipv4.method manual con dirección/pasarela/DNS; connection up lo aplica. El ping de control valida la capa 3 al momento. En Armbian: sudo apt install gpiod libgpiod-utils python3-gpiod; los pines del conector se llaman « 7J1 Header PinN » en gpioinfo. Solo 3,3 V, ningún pin tolerante a 5 V.

Para ir más lejos

Añadir un segundo DNS, un dominio de búsqueda (ipv4.dns-search), o volver al perfil DHCP al mudarse (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"

← Volver a la ficha