🙆

How to set networkd+wpa_supplicant in environment

2022/10/10に公開約1,800字

If you using linux in cui, you'll be confused by the network wifi settings.

This article is how to set up a network.

Don't required dhcp settings and ip command.

networkctl contains manipulating dhcp.

preparation

enable systemd-networkd

debian 11 and rhel, are disable in default install condition.

sudo systemctl enable systemd-networkd
sudo systemctl start systemd-networkd

check nic condition


# show list nic
networkctl list 

# check nic detail
networkctl status nic_name

if you haven't set configuration, "SETUP" is "unmaged".

set up nic configuration for networkctl

/etc/systemd/network/youwantoname.network
[Match]
Name=nicname

[Network]
DHCP=ipv4

In this way, DHCP is automatically used for networkd.

Restart and check systemd-networkd.

sudo systemctl restart systemd-networkd

# check nic 
networkctl list

Probablly, you show "SETUP"is configured, but "OPERATIONAL" is "no-carryier".
Let's set for wpa_supplicant.

wpa_supplicant configuration

"psk" is SSID password.
country is your country Name, ex) US, JP and etc... .

/etc/wpa_supplicant/wpa_supplicant-(nicname).conf
ctrl_interface=DIR=/var/run/wpa_supplicant
update_config=1
country=JP
ap_scan=1

network={
    ssid="yourssid"
    psk="yourpsk"
    key_mgmt=WPA-PSK
}

network={
    ssid="yourssid2"
    psk="yourpsk2"
    key_mgmt=WPA-PSK
}

"nicname" is your using nic name.

If you don't know SSID, you scan wifi access point.

iw dev nicname scan | grep SSID

enable wpa_supplicant

sudo systemctl enable wpa_supplicant@nicname
sudo systemctl start wpa_supplicant@nicname

"nicname" is wpa_supplicant configuration nicname.

Check nic status.

networkctl list

Probablly, you show "OPERATIONAL" is "routable".

If it didn't, reastart systemd-networkd.

Discussion

ログインするとコメントできます