Alors voilà le remède de cheval.
Avant de couper la tête à systemd-networkd, on va s'assurer qu'il est au moins un peu en cause
Le fichier interfaces devrait ressembler à ceci ...
Code: Select all
cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
... et son répertoire supplémentaire devrait être vide :
Code: Select all
ls -l /etc/network/interfaces.d
total 0
Dnsmasq ne devrait pas être installé :
Cette commande ne devrait rien renvoyer.
S'arrêter ici, et au rapport, en cas de divergence.
Si tout est nominal (façon SNAFU), on va essayer de se débrouiller sans systemd, avec dhcpcd uniquement :
Code: Select all
sudo systemctl disable systemd-networkd
sudo cp /etc/dhcpcd.conf /etc/dhcpcd.orig
Ensuite créér ce nouveau fichier pour dhcpcd :
Code: Select all
sudo nano /etc/dhcpcd.conf
# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.
debug
# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel
# Inform the DHCP server of our hostname for DDNS.
hostname
# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
#duid
# Persist interface configuration when dhcpcd exits.
persistent
# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit
# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu
# Most distributions have NTP support.
#option ntp_servers
# A ServerID is required by RFC2131.
require dhcp_server_identifier
# Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
slaac private
# https://www.raspberrypi.org/forums/viewtopic.php?f=65&t=269128
interface wlan0
# Don't bridge: done by hostapd
# Block client mode (wpa_supplicant)
nohook wpa_supplicant
# No route, no IP on bridge members
noipv4
noipv6
noipv6rs
interface eth0
env parent_bridge=bridge0
# No route, no IP on bridge members
noipv4
noipv6
noipv6rs
interface bridge0
# This block because the interface is not discovered automatically
# bridge0 will be configured via DHCP
# Remove this block and you get an anonymous bridge (no IP)
# Example static IP configuration:
#interface eth0
#static ip_address=192.168.0.10/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1
# It is possible to fall back to a static IP if DHCP fails:
# define static profile
#profile static_eth0
#static ip_address=192.168.1.23/24
#static routers=192.168.1.1
#static domain_name_servers=192.168.1.1
# fallback to static profile on eth0
#interface eth0
#fallback static_eth0
(le gros de l'action se passe au milieu du fichier, désormais)
Il faut créér un nouveau fichier de script dhcpcd:
Code: Select all
sudo nano /lib/dhcpcd/dhcpcd-hooks/90-bridging
# Manages bridge devices and member interfaces
# Triggered by low-level events PREINIT/CARRIER|STOP/NOCARRIER/DEPARTED if
# $interface has defined the parent_bridge environment value (in dhcpcd.conf)
# E.g.:
# interface eth0
# env parent_bridge=br0
# ...
#
# interface br0
# ...
[ -n "${parent_bridge:-}" ] || return 0
# Create bridge $parent_bridge if needed
bridge_create_try(){
[ -e "/sys/class/net/${parent_bridge}" ] && return 0
# Default settings, no STP. Caveat emptor.
# We up the bridge ourselves to ensure anonymous bridge mode works, i.e.
# "interface ${parent_bridge}" is no specified in dhcpcd.conf
ip link add name ${parent_bridge} type bridge && \
ip link set ${parent_bridge} up
}
# Delete bridge $parent_bridge if empty
bridge_delete_try(){
for member in "/sys/class/net/${parent_bridge}/lower_"*; do
[ -e "${member}" ] && return 0
done
ip link del ${parent_bridge}
}
# Associate $interface with bridge
bridge_member_start(){
bridge_create_try
[ -e "/sys/class/net/${parent_bridge}/lower_${interface}" ] && return 0
ip link set ${interface} master ${parent_bridge}
}
# Release $interface from bridge
bridge_member_stop(){
[ -e "/sys/class/net/${parent_bridge}" ] || return 0
[ -e "/sys/class/net/${parent_bridge}/lower_${interface}" ] && \
ip link set ${interface} nomaster
bridge_delete_try
}
case "${reason}" in
'PREINIT'|'CARRIER') bridge_member_start ;;
'STOP'|'DEPARTED'|'NOCARRIER') bridge_member_stop ;;
esac
(dhcpcd va appeler ce script sur évènements; selon la configuration dans dhcpcd.conf, le type d'interface, le type d'évènement, le pont sera créé ou supprimé automatiquement)
Ensuite, rebooter. Avec un peu de chance, une interface "bridge0" devrait acquérir une adresse IP par DHCP.
Si tout marche, supprimer/commenter la ligne "debug" au début de dhcpcd.conf, éventuellement supprimer les 2 fichiers nommés "br0" qui sont dans /etc/systemd/network (ne pas supprimer le fichier 99-default.link).
Rebouter une dernière fois pour valider que tout fonctionne encore.