LinuCエヴァンジェリストの鯨井貴博@opensourcetechです。
はじめに
今回はubuntu22.04におけるnetplanのwi-fi設定に関するメモです。
netplanの設定
OS情報の確認。
ubuntu@kvm2ubuntu:~$ cat /etc/os-release PRETTY_NAME="Ubuntu 22.04.1 LTS" NAME="Ubuntu" VERSION_ID="22.04" VERSION="22.04.1 LTS (Jammy Jellyfish)" VERSION_CODENAME=jammy ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=jammy
Wi-fiに関するnetplanの設定。
00-installer-config-wifi.yamlというファイルです。
ubuntu@kvm2ubuntu:~$ cd /etc/netplan ubuntu@kvm2ubuntu:/etc/netplan$ ls 00-installer-config-wifi.yaml 00-installer-config.yaml 99-installer-config.yaml ubuntu@kvm2ubuntu:/etc/netplan$ cat 00-installer-config-wifi.yaml # This is the network config written by 'subiquity' network: wifis: wlx00029e4bbb7f: access-points: myaccesspoint: password: "myappassword" addresses: - 192.168.100.12/24 gateway4: 192.168.100.1 nameservers: addresses: - 8.8.8.8 - 8.8.4.4 - 192.168.100.1 search: [] wlx0089ccfa0b89: access-points: myaccesspoint: password: "myappassword" addresses: - 192.168.100.13/24 gateway4: 192.168.100.1 nameservers: addresses: - 8.8.8.8 - 8.8.4.4 - 192.168.100.1 search: [] version: 2
設定の適用
netplan applyで適用します。
ubuntu@kvm2ubuntu:/etc/netplan$ sudo netplan --debug apply [sudo] password for ubuntu: ** (generate:2974): DEBUG: 12:03:00.185: starting new processing pass ** (generate:2974): DEBUG: 12:03:00.186: wlx00029e4bbb7f: adding wifi AP 'myaccesspoint' ** (generate:2974): WARNING **: 12:03:00.186: `gateway4` has been deprecated, use default routes instead. See the 'Default routes' section of the documentation for more details. ** (generate:2974): DEBUG: 12:03:00.186: wlx0089ccfa0b89: adding wifi AP 'myaccesspoint' ** (generate:2974): WARNING **: 12:03:00.186: `gateway4` has been deprecated, use default routes instead. See the 'Default routes' section of the documentation for more details. ** (generate:2974): DEBUG: 12:03:00.186: starting new processing pass ** (generate:2974): WARNING **: 12:03:00.186: `gateway4` has been deprecated, use default routes instead. See the 'Default routes' section of the documentation for more details. ** (generate:2974): DEBUG: 12:03:00.187: starting new processing pass ** (generate:2974): WARNING **: 12:03:00.187: `gateway4` has been deprecated, use default routes instead. See the 'Default routes' section of the documentation for more details. ** (generate:2974): DEBUG: 12:03:00.187: We have some netdefs, pass them through a final round of validation ** (generate:2974): WARNING **: 12:03:00.187: Problem encountered while validating default route consistency.Please set up multiple routing tables and use `routing-policy` instead. Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in wlx00029e4bbb7f but also in wlx0089ccfa0b89 ** (generate:2974): DEBUG: 12:03:00.187: wlx00029e4bbb7f: setting default backend to 2 ** (generate:2974): DEBUG: 12:03:00.187: Configuration is valid ** (generate:2974): DEBUG: 12:03:00.187: wlx0089ccfa0b89: setting default backend to 2 ** (generate:2974): DEBUG: 12:03:00.187: Configuration is valid ** (generate:2974): DEBUG: 12:03:00.187: enp4s0: setting default backend to 2 ** (generate:2974): DEBUG: 12:03:00.187: Configuration is valid ** (generate:2974): DEBUG: 12:03:00.188: Generating output files.. ** (generate:2974): DEBUG: 12:03:00.188: networkd: definition wlx00029e4bbb7f is not for us (backend 2) ** (generate:2974): DEBUG: 12:03:00.188: openvswitch: definition wlx00029e4bbb7f is not for us (backend 2) ** (generate:2974): DEBUG: 12:03:00.188: networkd: definition wlx0089ccfa0b89 is not for us (backend 2) ** (generate:2974): DEBUG: 12:03:00.188: openvswitch: definition wlx0089ccfa0b89 is not for us (backend 2) ** (generate:2974): DEBUG: 12:03:00.188: networkd: definition enp4s0 is not for us (backend 2) ** (generate:2974): DEBUG: 12:03:00.188: openvswitch: definition enp4s0 is not for us (backend 2) DEBUG:no netplan generated networkd configuration exists DEBUG:netplan generated NM configuration changed, restarting NM ** (process:2972): DEBUG: 12:03:02.158: starting new processing pass ** (process:2972): DEBUG: 12:03:02.158: wlx00029e4bbb7f: adding wifi AP 'myaccesspoint' ** (process:2972): WARNING **: 12:03:02.158: `gateway4` has been deprecated, use default routes instead. See the 'Default routes' section of the documentation for more details. ** (process:2972): DEBUG: 12:03:02.158: wlx0089ccfa0b89: adding wifi AP 'myaccesspoint' ** (process:2972): WARNING **: 12:03:02.159: `gateway4` has been deprecated, use default routes instead. See the 'Default routes' section of the documentation for more details. ** (process:2972): DEBUG: 12:03:02.159: starting new processing pass ** (process:2972): WARNING **: 12:03:02.159: `gateway4` has been deprecated, use default routes instead. See the 'Default routes' section of the documentation for more details. ** (process:2972): DEBUG: 12:03:02.159: starting new processing pass ** (process:2972): WARNING **: 12:03:02.159: `gateway4` has been deprecated, use default routes instead. See the 'Default routes' section of the documentation for more details. ** (process:2972): DEBUG: 12:03:02.160: We have some netdefs, pass them through a final round of validation ** (process:2972): WARNING **: 12:03:02.160: Problem encountered while validating default route consistency.Please set up multiple routing tables and use `routing-policy` instead. Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in wlx00029e4bbb7f but also in wlx0089ccfa0b89 ** (process:2972): DEBUG: 12:03:02.160: wlx00029e4bbb7f: setting default backend to 2 ** (process:2972): DEBUG: 12:03:02.160: Configuration is valid ** (process:2972): DEBUG: 12:03:02.160: wlx0089ccfa0b89: setting default backend to 2 ** (process:2972): DEBUG: 12:03:02.160: Configuration is valid ** (process:2972): DEBUG: 12:03:02.160: enp4s0: setting default backend to 2 ** (process:2972): DEBUG: 12:03:02.160: Configuration is valid DEBUG:Merged config: b'' DEBUG:Link changes: {} DEBUG:netplan triggering .link rules for lo DEBUG:netplan triggering .link rules for enp4s0 DEBUG:netplan triggering .link rules for wlx00029e4bbb7f DEBUG:netplan triggering .link rules for br0 DEBUG:netplan triggering .link rules for virbr0 DEBUG:netplan triggering .link rules for wlx0089ccfa0b89 DEBUG:netplan triggering .link rules for vnet0 DEBUG:netplan triggering .link rules for vnet1 DEBUG:netplan triggering .link rules for vnet2 ** (process:2972): DEBUG: 12:03:03.923: starting new processing pass ** (process:2972): DEBUG: 12:03:03.923: wlx00029e4bbb7f: adding wifi AP 'myaccesspoint' ** (process:2972): WARNING **: 12:03:03.923: `gateway4` has been deprecated, use default routes instead. See the 'Default routes' section of the documentation for more details. ** (process:2972): DEBUG: 12:03:03.923: wlx0089ccfa0b89: adding wifi AP 'myaccesspoint' ** (process:2972): WARNING **: 12:03:03.923: `gateway4` has been deprecated, use default routes instead. See the 'Default routes' section of the documentation for more details. ** (process:2972): DEBUG: 12:03:03.923: starting new processing pass ** (process:2972): WARNING **: 12:03:03.923: `gateway4` has been deprecated, use default routes instead. See the 'Default routes' section of the documentation for more details. ** (process:2972): DEBUG: 12:03:03.923: starting new processing pass ** (process:2972): WARNING **: 12:03:03.923: `gateway4` has been deprecated, use default routes instead. See the 'Default routes' section of the documentation for more details. ** (process:2972): DEBUG: 12:03:03.923: We have some netdefs, pass them through a final round of validation ** (process:2972): WARNING **: 12:03:03.923: Problem encountered while validating default route consistency.Please set up multiple routing tables and use `routing-policy` instead. Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in wlx00029e4bbb7f but also in wlx0089ccfa0b89 ** (process:2972): DEBUG: 12:03:03.923: wlx00029e4bbb7f: setting default backend to 2 ** (process:2972): DEBUG: 12:03:03.923: Configuration is valid ** (process:2972): DEBUG: 12:03:03.923: wlx0089ccfa0b89: setting default backend to 2 ** (process:2972): DEBUG: 12:03:03.923: Configuration is valid ** (process:2972): DEBUG: 12:03:03.923: enp4s0: setting default backend to 2 ** (process:2972): DEBUG: 12:03:03.923: Configuration is valid ** (process:2972): DEBUG: 12:03:03.923: starting new processing pass ** (process:2972): DEBUG: 12:03:03.923: wlx00029e4bbb7f: adding wifi AP 'myaccesspoint' ** (process:2972): WARNING **: 12:03:03.923: `gateway4` has been deprecated, use default routes instead. See the 'Default routes' section of the documentation for more details. ** (process:2972): DEBUG: 12:03:03.923: wlx0089ccfa0b89: adding wifi AP 'myaccesspoint' ** (process:2972): WARNING **: 12:03:03.924: `gateway4` has been deprecated, use default routes instead. See the 'Default routes' section of the documentation for more details. ** (process:2972): DEBUG: 12:03:03.924: starting new processing pass ** (process:2972): WARNING **: 12:03:03.924: `gateway4` has been deprecated, use default routes instead. See the 'Default routes' section of the documentation for more details. ** (process:2972): DEBUG: 12:03:03.924: starting new processing pass ** (process:2972): WARNING **: 12:03:03.924: `gateway4` has been deprecated, use default routes instead. See the 'Default routes' section of the documentation for more details. ** (process:2972): DEBUG: 12:03:03.924: We have some netdefs, pass them through a final round of validation ** (process:2972): WARNING **: 12:03:03.924: Problem encountered while validating default route consistency.Please set up multiple routing tables and use `routing-policy` instead. Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in wlx00029e4bbb7f but also in wlx0089ccfa0b89 ** (process:2972): DEBUG: 12:03:03.924: wlx00029e4bbb7f: setting default backend to 2 ** (process:2972): DEBUG: 12:03:03.924: Configuration is valid ** (process:2972): DEBUG: 12:03:03.924: wlx0089ccfa0b89: setting default backend to 2 ** (process:2972): DEBUG: 12:03:03.924: Configuration is valid ** (process:2972): DEBUG: 12:03:03.924: enp4s0: setting default backend to 2 ** (process:2972): DEBUG: 12:03:03.924: Configuration is valid DEBUG:Merged config: b''
ネットワーク設定の確認。
ubuntu@kvm2ubuntu:/etc/netplan$ ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP group default qlen 1000 link/ether 00:36:22:9e:d0:c6 brd ff:ff:ff:ff:ff:ff 3: wlx00029e4bbb7f: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:12:8e:4b:bb:8f brd ff:ff:ff:ff:ff:ff inet 192.168.100.12/24 brd 192.168.1.255 scope global noprefixroute wlx00029e4bbb7f valid_lft forever preferred_lft forever inet6 fe80::201:8eff:fe4b:cc7f/64 scope link valid_lft forever preferred_lft forever 4: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 62:f8:3f:f0:52:60 brd ff:ff:ff:ff:ff:ff inet 192.168.13.11/24 brd 192.168.13.255 scope global noprefixroute br0 valid_lft forever preferred_lft forever inet6 350f:32:57b9:2:25a2:c2c:2c89:8f67/64 scope global temporary dynamic valid_lft 271sec preferred_lft 271sec inet6 350f:32:57b9:2:569c:477e:b705:d1c5/64 scope global dynamic mngtmpaddr noprefixroute valid_lft 271sec preferred_lft 271sec inet6 fe80::9f1b:ec4f:6c34:f041/64 scope link noprefixroute valid_lft forever preferred_lft forever 5: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 52:54:00:c9:c4:45 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 8: wlx0089ccfa0b89: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:90:cc:fa:0b:79 brd ff:ff:ff:ff:ff:ff inet 192.168.100.13/24 brd 192.168.1.255 scope global noprefixroute wlx0089ccfa0b89 valid_lft forever preferred_lft forever inet6 fe80::290:ccff:fefa:b79/64 scope link valid_lft forever preferred_lft forever 9: vnet0: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether fe:54:00:89:b0:ae brd ff:ff:ff:ff:ff:ff 10: vnet1: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether fe:54:00:f0:19:5a brd ff:ff:ff:ff:ff:ff 11: vnet2: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether fe:54:00:f4:c2:17 brd ff:ff:ff:ff:ff:ff
その他、ルーティングはip route showなどネットワーク関連の状態を確認するといいですね♪
おまけ
netplan applyの出力を見ると、以下のようなものがあります。
** (process:2972): WARNING **: 12:03:03.924: `gateway4` has been deprecated, use default routes instead.
これは、gateway4という記載方法が非推奨になっているので、
routesのdefaultを使って書いてねってことをいっています。
こちらに詳細あり。
今回使った設定を修正すると、以下のようになりますね!
ubuntu@kvm2ubuntu:/etc/netplan$ cat 00-installer-config-wifi.yaml # This is the network config written by 'subiquity' network: wifis: wlx00029e4bbb7f: access-points: myaccesspoint: password: "myappassword" addresses: - 192.168.100.12/24 routes: - to: default via: 192.168.100.1 nameservers: addresses: - 8.8.8.8 - 8.8.4.4 - 192.168.100.1 search: [] wlx0089ccfa0b89: access-points: myaccesspoint: password: "myappassword" addresses: - 192.168.100.13/24 routes: - to: default via: 192.168.100.1 nameservers: addresses: - 8.8.8.8 - 8.8.4.4 - 192.168.100.1 search: [] version: 2