Gateway con Pi: "RTNETLINK answers: File exists" en ifup eth0 y caídas de keepalive tras el arranque
Traducido del English por IA ·
Primera publicación, llevo un tiempo leyendo aquí.Construimos nuestro propio gateway sobre una Raspberry Pi 3B+ (Raspberry Pi OS Bullseye) para una pequeña subestación: lee tres medidores Modbus RTU y los publica en v1/gw/telemetry. La LAN de la subestación no tiene DHCP, así que eth0 necesita una dirección estática. Añadí esto en /etc/network/interfaces:
auto eth0
iface eth0 inet static
address 10.40.2.20
netmask 255.255.255.0
gateway 10.40.2.1
dns-nameservers 10.40.2.1
Tras un reinicio a veces funciona y a veces no. Cuando no funciona, sudo ifup eth0 dice:
RTNETLINK answers: File exists
ifup: failed to bring up eth0
En Hermetry, la pestaña Log del gateway muestra una desconexión por keepalive_timeout en cada arranque, y luego se reconecta unos minutos más tarde, o no se reconecta hasta que inicio sesión en el sitio. ip addr a veces muestra dos direcciones en eth0: la estática y una 169.254.
First post, I have been reading here for a while.
We built our own gateway on a Raspberry Pi 3B+ (Raspberry Pi OS Bullseye) for a small substation: it reads three Modbus RTU meters and publishes them on v1/gw/telemetry. The substation LAN has no DHCP, so eth0 needs a static address. I added this to /etc/network/interfaces:
auto eth0
iface eth0 inet static
address 10.40.2.20
netmask 255.255.255.0
gateway 10.40.2.1
dns-nameservers 10.40.2.1
After a reboot it sometimes works and sometimes not. When it does not, sudo ifup eth0 says:
RTNETLINK answers: File exists
ifup: failed to bring up eth0
In Hermetry the gateway’s Log tab shows a keepalive_timeout disconnect around every boot and then it reconnects some minutes later, or not at all until I log in on site. ip addr sometimes shows two addresses on eth0, the static one and a 169.254 one.
Traducido del English por IA ·
¿Probaste primero con ifdown y luego con ifup?
Did you try ifdown first and then ifup?
Traducido del English por IA ·
Sí, ifdown indica interface eth0 not configured y ifup falla de la misma forma después.
Yes, ifdown says interface eth0 not configured and ifup fails the same way afterwards.
Traducido del English por IA ·
Bullseye usa dhcpcd para la red. /etc/network/interfaces es la forma antigua, yo no mezclaría ambos.
Bullseye uses dhcpcd for networking. /etc/network/interfaces is the old way, I would not mix them.
Traducido del English por IA ·
Daniel tiene razón. Me pasó exactamente esto en una Pi de una estación de bombeo el año pasado. Hay dos cosas configurando eth0: dhcpcd arranca con el sistema, no encuentra ningún servidor DHCP, asigna al puerto una dirección link-local 169.254 y rutas, y luego ifup intenta añadir su propia dirección y ruta por defecto. La ruta ya existe, así que el kernel responde «File exists» y ifup se rinde. Según cuál gane la carrera al arrancar, tu gateway sale o no.Elige uno. En Bullseye eso significa dhcpcd. Quita el bloque de eth0 de /etc/network/interfaces (el archivo debe quedar solo con la línea source) y pon la configuración estática en /etc/dhcpcd.conf:
interface eth0
static ip_address=10.40.2.20/24
static routers=10.40.2.1
static domain_name_servers=10.40.2.1
noipv4ll
Luego limpia sin reiniciar:
sudo ip addr flush dev eth0
sudo systemctl restart dhcpcd
ip addr show eth0
noipv4ll evita la dirección 169.254. Si más adelante pasas a Bookworm, dhcpcd ya no está y haces lo mismo con nmcli, así que anótalo.
Daniel has it. I hit exactly this on a pumping station Pi last year. Two things are configuring eth0: dhcpcd starts at boot, finds no DHCP server and gives the port a 169.254 link-local address plus routes, and then ifup tries to add its own address and default route. The route is already there, so the kernel answers «File exists» and ifup gives up. Depending on which one wins the race at boot, your gateway gets out or not.
Pick one. On Bullseye that means dhcpcd. Remove the eth0 block from /etc/network/interfaces (leave the file with only the source line) and put the static setup in /etc/dhcpcd.conf:
interface eth0
static ip_address=10.40.2.20/24
static routers=10.40.2.1
static domain_name_servers=10.40.2.1
noipv4ll
Then clean up without a reboot:
sudo ip addr flush dev eth0
sudo systemctl restart dhcpcd
ip addr show eth0
noipv4ll stops the 169.254 address. If you move to Bookworm later, dhcpcd is gone and you do the same with nmcli, so keep a note of that.
Traducido del English por IA ·
No sabía que las versiones de Pi OS habían cambiado esto, buena información.
Didn’t know the Pi OS versions changed this, good to know.
Traducido del English por IA ·
Solucionado. Se limpió el archivo interfaces, la configuración estática está en dhcpcd.conf con noipv4ll, y reinicié la Pi diez veces seguidas esta mañana; la pasarela se conectó en pocos segundos en todas las ocasiones. La pestaña Log ahora muestra una sola conexión limpia por arranque.
Fixed. Interfaces file cleaned, static config in dhcpcd.conf with noipv4ll, rebooted the Pi ten times in a row this morning and the gateway connected within a few seconds every time. The Log tab now shows one clean connect per boot.
- Debes estar registrado para responder a este debate.
Únete a la conversación
Inicia sesión para preguntar y responder, dar me gusta a las publicaciones útiles y marcar la respuesta que resolvió tu problema. Cada aportación suma puntos y niveles.

