La Fibre
Télécom => Logiciels et systèmes d'exploitation =>
Tutoriels pour Ubuntu server => Discussion démarrée par: vivien le 08 février 2026 à 21:30:24
-
Configuration du Wi-Fi avec Netplan - typiquement sur un PC sans interface graphique (Ubuntu server) mais équipé d'une carte Wi-Fi
La configuration NEtplan est dans /etc/netplan/00-installer-config.yaml
sudo nano /etc/netplan/00-installer-config.yaml
Netplan utilise le format YAML, qui est extrêmement sensible à l'indentation.
N'utilisez jamais la touche "Tab" dans un fichier YAML, sinon Netplan renverra une erreur. Utilisez uniquement des espaces.
Contrairement à l'Ethernet, le Wi-Fi a besoin du paquet wpasupplicant pour gérer l'authentification (WPA2/WPA3). Il est normalement déjà installé (sudo apt install wpasupplicant sinon).
Exemple de fichier /etc/netplan/00-installer-config.yaml pour une configuration Wi-Fi (l'interface Ethernet n'est pas utilisée) :
network:
version: 2
renderer: networkd
ethernets: {}
wifis:
wlp16s0:
dhcp4: true
dhcp6: false
accept-ra: true
access-points:
"Flybox-3C4F":
password: "Y7tEEFsQUkkE"
Une fois le fichier modifié, n'oubliez pas de tester et d'appliquer la configuration :
sudo netplan try (recommandé pour éviter de perdre la main à distance).
sudo netplan apply (pour appliquer directement).
Tester la configuration sans l'appliquer définitivement : sudo netplan try (Cela annule les changements après 120s si vous ne validez pas, pratique pour ne pas perdre l'accès SSH).
Configuration avec Ethernet + Wi-Fi actif simultanément :
network:
version: 2
renderer: networkd
ethernets:
ens1:
dhcp4: true
dhcp6: false
accept-ra: true
match:
macaddress: 00:1f:29:94:ec:c8
set-name: ens1
wifis:
wlp16s0:
dhcp4: true
dhcp6: false
accept-ra: true
access-points:
"Flybox-3C4F":
password: "Y7tEEFsQUkkE"
-
Pour voir les logs de l'association Wi-Fi
sudo dmesg | grep wlp16s0 (adapter avec le nom de votre interface WI-Fi)
Exemple quand tout se passe bien (WPA2) :
$ sudo dmesg | grep wlp16s0
[ 10.414398] systemd[1]: Expecting device sys-subsystem-net-devices-wlp16s0.device - /sys/subsystem/net/devices/wlp16s0...
[ 18.188950] iwl3945 0000:10:00.0 wlp16s0: renamed from wlan0
[ 23.492383] wlp16s0: authenticate with a8:fb:40:d2:3c:5e (local address=00:1f:3c:63:a6:d6)
[ 23.492392] wlp16s0: send auth to a8:fb:40:d2:3c:5e (try 1/3)
[ 23.494044] wlp16s0: authenticated
[ 23.496464] wlp16s0: associate with a8:fb:40:d2:3c:5e (try 1/3)
[ 23.497972] wlp16s0: RX AssocResp from a8:fb:40:d2:3c:5e (capab=0x1911 status=0 aid=2)
[ 23.499317] wlp16s0: associated
[ 23.584510] wlp16s0: Limiting TX power to 30 (30 - 0) dBm as advertised by a8:fb:40:d2:3c:5e
Exemple d'un problème (non-support du WPA3-TM Transition Mode)
Ma configuration ne fonctionne pas quand le point d'accès est en mode WAP2/WPA3 (WPA3-TM pour Transition Mode). Voici ce que donne sudo dmesg | grep wlp16s0 avec la box en WPA2/WPA3 :
[ 10.658791] systemd[1]: Expecting device sys-subsystem-net-devices-wlp16s0.device - /sys/subsystem/net/devices/wlp16s0...
[ 18.253886] iwl3945 0000:10:00.0 wlp16s0: renamed from wlan0
[ 23.012845] wlp16s0: authenticate with a8:fb:40:d2:3c:5e (local address=00:1f:3c:63:a6:d6)
[ 23.012856] wlp16s0: send auth to a8:fb:40:d2:3c:5e (try 1/3)
[ 23.100612] wlp16s0: authenticate with a8:fb:40:d2:3c:5e (local address=00:1f:3c:63:a6:d6)
[ 23.100626] wlp16s0: send auth to a8:fb:40:d2:3c:5e (try 1/3)
[ 23.146238] wlp16s0: authenticated
[ 23.148479] wlp16s0: associate with a8:fb:40:d2:3c:5e (try 1/3)
[ 23.149695] wlp16s0: RX AssocResp from a8:fb:40:d2:3c:5e (capab=0x1911 status=0 aid=2)
[ 23.150990] wlp16s0: associated
[ 23.202725] wlp16s0: Limiting TX power to 30 (30 - 0) dBm as advertised by a8:fb:40:d2:3c:5e
[ 23.427935] wlp16s0: deauthenticating from a8:fb:40:d2:3c:5e by local choice (Reason: 1=UNSPECIFIED)
[ 23.663361] wlp16s0: authenticate with a8:fb:40:d2:3c:5a (local address=00:1f:3c:63:a6:d6)
[ 23.663610] wlp16s0: send auth to a8:fb:40:d2:3c:5a (try 1/3)
[ 23.737647] wlp16s0: authenticate with a8:fb:40:d2:3c:5a (local address=00:1f:3c:63:a6:d6)
[ 23.737684] wlp16s0: send auth to a8:fb:40:d2:3c:5a (try 1/3)
[ 23.780676] wlp16s0: authenticated
[ 23.782514] wlp16s0: associate with a8:fb:40:d2:3c:5a (try 1/3)
[ 23.786481] wlp16s0: RX AssocResp from a8:fb:40:d2:3c:5a (capab=0x1c11 status=0 aid=2)
[ 23.790129] wlp16s0: associated
[ 23.820247] wlp16s0: Limiting TX power to 30 (30 - 0) dBm as advertised by a8:fb:40:d2:3c:5a
[ 23.896378] wlp16s0: deauthenticating from a8:fb:40:d2:3c:5a by local choice (Reason: 1=UNSPECIFIED)
Pour voir les données remonter en temps réel :
journalctl -u systemd-networkd -f
Quand on applique la configuration pour activer le maximum de détails :
$ sudo netplan --debug apply (ci-dessous je suis dans une configuration avec la box en WPA2)
** (generate:1388): DEBUG: 20:35:46.194: starting new processing pass
** (generate:1388): DEBUG: 20:35:46.195: wlp16s0: adding wifi AP 'Flybox-3C4F'
** (generate:1388): DEBUG: 20:35:46.195: We have some netdefs, pass them through a final round of validation
** (generate:1388): DEBUG: 20:35:46.195: wlp16s0: setting default backend to 1
** (generate:1388): DEBUG: 20:35:46.195: Configuration is valid
** (generate:1388): DEBUG: 20:35:46.195: ens1: setting default backend to 1
** (generate:1388): DEBUG: 20:35:46.195: Configuration is valid
** (generate:1388): DEBUG: 20:35:46.195: using ovs-vsctl at /usr/bin/ovs-vsctl
** (generate:1388): DEBUG: 20:35:46.196: Generating output files..
** (generate:1388): DEBUG: 20:35:46.196: Open vSwitch: definition ens1 is not for us (backend 1)
** (generate:1388): DEBUG: 20:35:46.196: NetworkManager: definition ens1 is not for us (backend 1)
** (generate:1388): DEBUG: 20:35:46.196: Creating wpa_supplicant config
** (generate:1388): DEBUG: 20:35:46.196: wlp16s0: Creating wpa_supplicant configuration file run/netplan/wpa-wlp16s0.conf
** (generate:1388): DEBUG: 20:35:46.196: Creating wpa_supplicant unit /run/systemd/system/netplan-wpa-wlp16s0.service
** (generate:1388): DEBUG: 20:35:46.203: Creating wpa_supplicant service enablement link /run/systemd/system/systemd-networkd.service.wants/netplan-wpa-wlp16s0.service
** (generate:1388): DEBUG: 20:35:46.203: Open vSwitch: definition wlp16s0 is not for us (backend 1)
** (generate:1388): DEBUG: 20:35:46.203: NetworkManager: definition wlp16s0 is not for us (backend 1)
** (generate:1388): DEBUG: 20:35:46.204: _netplan_sysfs_get_driver_by_ifname: Cannot read symlink of /sys/class/net/lo/device/driver.
DEBUG:netplan generated networkd configuration changed, reloading networkd
DEBUG:Cannot call Open vSwitch: Cannot apply OpenvSwitch cleanup: ovs-vsctl is 'not-found'.
DEBUG:no netplan generated NM configuration exists
** (process:1386): DEBUG: 20:35:46.828: starting new processing pass
** (process:1386): DEBUG: 20:35:46.829: wlp16s0: adding wifi AP 'Flybox-3C4F'
** (process:1386): DEBUG: 20:35:46.830: We have some netdefs, pass them through a final round of validation
** (process:1386): DEBUG: 20:35:46.830: wlp16s0: setting default backend to 1
** (process:1386): DEBUG: 20:35:46.831: Configuration is valid
** (process:1386): DEBUG: 20:35:46.831: ens1: setting default backend to 1
** (process:1386): DEBUG: 20:35:46.831: Configuration is valid
DEBUG:Merged config:
b''
DEBUG:Skipping correctly named interface: ens1
DEBUG:Link changes: {}
DEBUG:netplan triggering .link rules for lo
DEBUG:netplan triggering .link rules for ens1
DEBUG:netplan triggering .link rules for wlp16s0
** (process:1386): DEBUG: 20:35:47.156: starting new processing pass
** (process:1386): DEBUG: 20:35:47.156: wlp16s0: adding wifi AP 'Flybox-3C4F'
** (process:1386): DEBUG: 20:35:47.156: We have some netdefs, pass them through a final round of validation
** (process:1386): DEBUG: 20:35:47.157: wlp16s0: setting default backend to 1
** (process:1386): DEBUG: 20:35:47.157: Configuration is valid
** (process:1386): DEBUG: 20:35:47.157: ens1: setting default backend to 1
** (process:1386): DEBUG: 20:35:47.157: Configuration is valid
DEBUG:Merged config:
b''
-
Quelques commandes pour voir les interface :
Configuration avec uniquement du Wi-Fi d'actif :
(https://lafibre.info/testdebit/ubuntu/202602_netplan_configuration_wifi_ubuntu_server.webp)
Ci-dessous, Ethernet et Wi-Fi sont connectés à la même box simultanément
$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 00:1f:29:94:ec:c8 brd ff:ff:ff:ff:ff:ff
altname enp24s0
altname enx001f2994ecc8
3: wlp16s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000
link/ether 00:1f:3c:63:a6:d6 brd ff:ff:ff:ff:ff:ff
altname wlx001f3c63a6d6
$ sudo netplan status --all
Online state: online
DNS Addresses: 127.0.0.53 (stub)
DNS Search: .
● 1: lo ethernet UNKNOWN/UP (unmanaged)
MAC Address: 00:00:00:00:00:00
Addresses: 127.0.0.1/8
::1/128
● 2: ens1 ethernet UP (networkd: ens1)
MAC Address: 00:1f:29:94:ec:c8 (Broadcom Inc. and subsidiaries)
Addresses: 192.168.1.14/24 (dynamic, dhcp)
2a01:cb01:2002:659c::793/128 (dynamic, dhcp)
2a01:cb01:2002:659c:21f:29ff:fe94:ecc8/64 (dynamic, ra)
fe80::21f:29ff:fe94:ecc8/64 (link)
DNS Addresses: 192.168.1.1
fe80::aafb:40ff:fed2:3c4f
Routes: default via 192.168.1.1 from 192.168.1.14 metric 100 (dhcp)
192.168.1.0/24 from 192.168.1.14 metric 100 (link)
192.168.1.1 from 192.168.1.14 metric 100 (dhcp, link)
2a01:cb01:2002:659c::/64 metric 100 (ra)
fe80::/64 metric 256
default via fe80::aafb:40ff:fed2:3c4f metric 100 (ra)
● 3: wlp16s0 wifi/"Flybox-3C4F" UP (networkd: wlp16s0)
MAC Address: 00:1f:3c:63:a6:d6 (Intel Corporation)
Addresses: 192.168.1.159/24 (dynamic, dhcp)
2a01:cb01:2002:659c::3e9/128 (dynamic, dhcp)
2a01:cb01:2002:659c:21f:3cff:fe63:a6d6/64 (dynamic, ra)
fe80::21f:3cff:fe63:a6d6/64 (link)
DNS Addresses: 192.168.1.1
fe80::aafb:40ff:fed2:3c4f
Routes: default via 192.168.1.1 from 192.168.1.159 metric 600 (dhcp)
192.168.1.0/24 from 192.168.1.159 metric 600 (link)
192.168.1.1 from 192.168.1.159 metric 600 (dhcp, link)
2a01:cb01:2002:659c::/64 metric 600 (ra)
fe80::/64 metric 256
default via fe80::aafb:40ff:fed2:3c4f metric 600 (ra)
-
Voir les adresses IP récupérées :
$ ip -4 -c addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: ens1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
altname enp24s0
altname enx001f2994ecc8
inet 192.168.1.14/24 metric 100 brd 192.168.1.255 scope global dynamic ens1
valid_lft 85659sec preferred_lft 85659sec
3: wlp16s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
altname wlx001f3c63a6d6
inet 192.168.1.159/24 metric 600 brd 192.168.1.255 scope global dynamic wlp16s0
valid_lft 85660sec preferred_lft 85660sec
$ ip -6 -c addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 state UNKNOWN qlen 1000
inet6 ::1/128 scope host noprefixroute
valid_lft forever preferred_lft forever
2: ens1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000
inet6 2a01:cb01:2002:659c::793/128 scope global dynamic noprefixroute
valid_lft 85653sec preferred_lft 42453sec
inet6 2a01:cb01:2002:659c:21f:29ff:fe94:ecc8/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 86020sec preferred_lft 42820sec
inet6 fe80::21f:29ff:fe94:ecc8/64 scope link proto kernel_ll
valid_lft forever preferred_lft forever
3: wlp16s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000
inet6 2a01:cb01:2002:659c::3e9/128 scope global dynamic noprefixroute
valid_lft 85658sec preferred_lft 42458sec
inet6 2a01:cb01:2002:659c:21f:3cff:fe63:a6d6/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 86020sec preferred_lft 42820sec
inet6 fe80::21f:3cff:fe63:a6d6/64 scope link proto kernel_ll
valid_lft forever preferred_lft forever
$ ip -4 -c route show
default via 192.168.1.1 dev ens1 proto dhcp src 192.168.1.14 metric 100
default via 192.168.1.1 dev wlp16s0 proto dhcp src 192.168.1.159 metric 600
192.168.1.0/24 dev ens1 proto kernel scope link src 192.168.1.14 metric 100
192.168.1.0/24 dev wlp16s0 proto kernel scope link src 192.168.1.159 metric 600
192.168.1.1 dev ens1 proto dhcp scope link src 192.168.1.14 metric 100
192.168.1.1 dev wlp16s0 proto dhcp scope link src 192.168.1.159 metric 600
$ ip -6 -c route show
2a01:cb01:2002:659c::/64 dev ens1 proto ra metric 100 expires 86008sec pref medium
2a01:cb01:2002:659c::/64 dev wlp16s0 proto ra metric 600 expires 86008sec pref medium
fe80::/64 dev ens1 proto kernel metric 256 pref medium
fe80::/64 dev wlp16s0 proto kernel metric 256 pref medium
default nhid 1456823651 via fe80::aafb:40ff:fed2:3c4f dev ens1 proto ra metric 100 expires 1408sec pref medium
default nhid 1218230533 via fe80::aafb:40ff:fed2:3c4f dev wlp16s0 proto ra metric 600 expires 1408sec pref medium
-
En cas de désactivation logicielle du Wi-Fi :
Installer rfkill qui permet de gérer cette activation / désactivation : sudo apt install rfkill
$ rfkill list
0: hp-wifi: Wireless LAN
Soft blocked: no
Hard blocked: no
1: hp-bluetooth: Bluetooth
Soft blocked: no
Hard blocked: no
2: hci0: Bluetooth
Soft blocked: no
Hard blocked: no
3: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no
Si vous voyez "Soft blocked: yes", voici la commande pour débloquer le Wi-Fi :
sudo rfkill unblock wifi
Définition du pays (c'est plus pour les cas où la carte Wi-Fi du Linux va servir de point d'accés :
sudo echo "REGDOMAIN=FR" > /etc/default/crda
-
Exemple de log où on voit la perte de la box internet (j'ai simplement redémarré la box à t = 93 secondes via le menu de l'interface pour redémarer la box)
$ sudo dmesg | grep wlp16s0
[ 10.664195] systemd[1]: Expecting device sys-subsystem-net-devices-wlp16s0.device - /sys/subsystem/net/devices/wlp16s0...
[ 18.368414] iwl3945 0000:10:00.0 wlp16s0: renamed from wlan0
[ 23.672265] wlp16s0: authenticate with a8:fb:40:d2:3c:5e (local address=00:1f:3c:63:a6:d6)
[ 23.672273] wlp16s0: send auth to a8:fb:40:d2:3c:5e (try 1/3)
[ 23.674032] wlp16s0: authenticated
[ 23.674487] wlp16s0: associate with a8:fb:40:d2:3c:5e (try 1/3)
[ 23.676053] wlp16s0: RX AssocResp from a8:fb:40:d2:3c:5e (capab=0x1911 status=0 aid=2)
[ 23.677432] wlp16s0: associated
[ 23.716958] wlp16s0: Limiting TX power to 30 (30 - 0) dBm as advertised by a8:fb:40:d2:3c:5e
[ 93.165434] wlp16s0: deauthenticating from a8:fb:40:d2:3c:5e by local choice (Reason: 3=DEAUTH_LEAVING)
[ 97.173797] wlp16s0: authenticate with a8:fb:40:d2:3c:5e (local address=00:1f:3c:63:a6:d6)
[ 97.173810] wlp16s0: send auth to a8:fb:40:d2:3c:5e (try 1/3)
[ 97.175553] wlp16s0: authenticated
[ 97.176647] wlp16s0: associate with a8:fb:40:d2:3c:5e (try 1/3)
[ 97.178340] wlp16s0: RX AssocResp from a8:fb:40:d2:3c:5e (capab=0x1911 status=0 aid=2)
[ 97.179985] wlp16s0: associated
[ 97.214412] wlp16s0: Limiting TX power to 30 (30 - 0) dBm as advertised by a8:fb:40:d2:3c:5e
[ 139.902243] wlp16s0: disassociated from a8:fb:40:d2:3c:5e (Reason: 4=DISASSOC_DUE_TO_INACTIVITY)
[ 139.921194] wlp16s0: authenticate with a8:fb:40:d2:3c:5e (local address=00:1f:3c:63:a6:d6)
[ 139.921205] wlp16s0: send auth to a8:fb:40:d2:3c:5e (try 1/3)
[ 140.125536] wlp16s0: send auth to a8:fb:40:d2:3c:5e (try 2/3)
[ 140.333516] wlp16s0: send auth to a8:fb:40:d2:3c:5e (try 3/3)
[ 140.541528] wlp16s0: authentication with a8:fb:40:d2:3c:5e timed out
[ 141.088963] wlp16s0: authenticate with a8:fb:40:d2:3c:5a (local address=00:1f:3c:63:a6:d6)
[ 141.089123] wlp16s0: send auth to a8:fb:40:d2:3c:5a (try 1/3)
[ 141.293539] wlp16s0: send auth to a8:fb:40:d2:3c:5a (try 2/3)
[ 141.501538] wlp16s0: send auth to a8:fb:40:d2:3c:5a (try 3/3)
[ 141.709524] wlp16s0: authentication with a8:fb:40:d2:3c:5a timed out
[ 196.223525] wlp16s0: authenticate with a8:fb:40:d2:3c:5a (local address=00:1f:3c:63:a6:d6)
[ 196.223545] wlp16s0: send auth to a8:fb:40:d2:3c:5a (try 1/3)
[ 196.230358] wlp16s0: authenticated
[ 196.231585] wlp16s0: associate with a8:fb:40:d2:3c:5a (try 1/3)
[ 196.236051] wlp16s0: RX AssocResp from a8:fb:40:d2:3c:5a (capab=0x1c11 status=0 aid=1)
[ 196.238544] wlp16s0: associated
[ 196.305950] wlp16s0: Limiting TX power to 30 (30 - 0) dBm as advertised by a8:fb:40:d2:3c:5a
[ 302.983844] wlp16s0: authenticate with a8:fb:40:d2:3c:5e (local address=00:1f:3c:63:a6:d6)
[ 302.983866] wlp16s0: send auth to a8:fb:40:d2:3c:5e (try 1/3)
[ 302.985636] wlp16s0: authenticated
[ 302.986560] wlp16s0: associate with a8:fb:40:d2:3c:5e (try 1/3)
[ 302.988298] wlp16s0: RX AssocResp from a8:fb:40:d2:3c:5e (capab=0x1911 status=0 aid=2)
[ 302.990127] wlp16s0: associated
[ 303.004126] wlp16s0: Limiting TX power to 30 (30 - 0) dBm as advertised by a8:fb:40:d2:3c:5e