wi-fi подключение

Ответить
ya
^-^
Сообщения: 2336
Зарегистрирован: 16 дек 2021, 19:56

wi-fi подключение

Сообщение ya »

Step 1: Find The Name of Your Wireless Interface And Wireless Network

iwconfig

ip link set dev wlx00721100621c up

rfkill unblock wifi

iwlist wlx00721100621c scan | grep ESSID

apt install wpasupplicant

wpa_passphrase "Redmi 9C NFC" 168317295 | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf

wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlx00721100621c
ya
^-^
Сообщения: 2336
Зарегистрирован: 16 дек 2021, 19:56

Re: wi-fi подключение

Сообщение ya »

Step 3: Auto-Connect At System Boot Time
To automatically connect to wireless network at boot time, we need to edit the wpa_supplicant.service file. It’s a good idea to copy the file from /lib/systemd/system/ directory to /etc/systemd/system/ directory, then edit the file content, because we don’t want a newer version of wpa_supplicant to override our modifications.

sudo cp /lib/systemd/system/wpa_supplicant.service /etc/systemd/system/wpa_supplicant.service
Edit the file with a command-line text editor, such as Nano.

sudo nano /etc/systemd/system/wpa_supplicant.service
Find the following line.

ExecStart=/sbin/wpa_supplicant -u -s -O /run/wpa_supplicant
Change it to the following. Here we added the configuration file and the wireless interface name to the ExecStart command.

ExecStart=/sbin/wpa_supplicant -u -s -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlp4s0
It’s recommended to always try to restart wpa_supplicant when failure is detected. Add the following right below the ExecStart line.

Restart=always
Save and close the file. (To save a file in Nano text editor, press Ctrl+O, then press Enter to confirm. To exit, press Ctrl+X.) Then reload systemd.

sudo systemctl daemon-reload
Enable wpa_supplicant service to start at boot time.

sudo systemctl enable wpa_supplicant.service
We also need to start dhclient at boot time to obtain a private IP address from DHCP server. This can be achieved by creating a systemd service unit for dhclient.

sudo nano /etc/systemd/system/dhclient.service
Put the following text into the file.

[Unit]
Description= DHCP Client
Before=network.target
After=wpa_supplicant.service

[Service]
Type=forking
ExecStart=/sbin/dhclient wlp4s0 -v
ExecStop=/sbin/dhclient wlp4s0 -r
Restart=always

[Install]
WantedBy=multi-user.target
Save and close the file. Then enable this service.

sudo systemctl enable dhclient.service
How to Obtain a Static IP Address
If you want to obtain a static IP address, then you need to disable dhclient.service.

sudo systemctl disable dhclient.service
Create a network config file.

sudo nano /etc/systemd/network/static.network
Add the following lines.

[Match]
Name=wlp4s0

[Network]
Address=192.168.1.8/24
Gateway=192.168.1.1
Save and close the file. Then create a .link file for the wireless interface.

sudo nano /etc/systemd/network/10-wifi.link
Add the following lines in this file. You need to use your own MAC address and wireless interface name. This is to prevent the system from changing the wireless interface name.

[Match]
MACAddress=a8:4b:05:2b:e8:54

[Link]
NamePolicy=
Name=wlp4s0
Save and close the file. Then disable the networking.service and enable systemd-networkd.service, which will take care of networking.

sudo systemctl disable networking

sudo systemctl enable systemd-networkd
You can now restart systemd-networkd to see if your configuration works.

sudo systemctl restart systemd-networkd
Another way to obtain a static IP address is by logging into your router’s management interface and assigning a static IP to the MAC address of your wireless card, if your router supports this feature.

Recommended Reading:

How to Use Systemd on Linux – Manage Services, Run Levels and Logs
Multiple Wi-Fi Networks
The /etc/wpa_supplicant.conf configuration file can include multiple Wi-Fi networks. wpa_supplicant automatically selects the best network based on the order of network blocks in the configuration file, network security level, and signal strength.

To add a second Wi-Fi network, run:

wpa_passphrase your-ESSID your-wifi-passphrase | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf
Note that you need to use the -a option with the tee command, which will append, instead of deleting the original content, the new Wifi-network to the file.

Wi-Fi Security
Do not use WPA2 TKIP or WPA2 TKIP+AES as the encryption method in your Wi-Fi router. TKIP is not considered secure anymore. You can use WPA2-AES as the encryption method.

Wrapping Up
I hope this tutorial helped you connect Debian 11/10 to Wi-Fi network from the command line with WPA Supplicant. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks 🙂

Rate this tutorial
ya
^-^
Сообщения: 2336
Зарегистрирован: 16 дек 2021, 19:56

Re: wi-fi подключение

Сообщение ya »

firmware-realtek - Binary firmware for Realtek wired/wifi/BT adapters
ya
^-^
Сообщения: 2336
Зарегистрирован: 16 дек 2021, 19:56

Re: wi-fi подключение

Сообщение ya »

подключение

sudo systemctl restart wpa_supplicant
ya
^-^
Сообщения: 2336
Зарегистрирован: 16 дек 2021, 19:56

Re: wi-fi подключение

Сообщение ya »

Интерфейс подключения:
iwconfig

Список доступных сетей
iwlist wlp4s0 scan | grep -i ssid

генерация конфига для подключения:
wpa_passphrase "Redmi 9C NFC" 168317295 | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf

подключение в фоновом режиме (ключ B)
wpa_supplicant -B -i wlp4s0 -c /etc/wpa_supplicant/wpa_supplicant.conf

Активация wi-fi
sh /etc/wpa_supplicant/action_wpa.sh
ya
^-^
Сообщения: 2336
Зарегистрирован: 16 дек 2021, 19:56

Автоматическое wi-fi подключение

Сообщение ya »

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="MySSID"
psk="MyPasswd"
}
and my /etc/network/interfaces file looks like this:

auto wlp4s0
iface wlp4s0 inet dhcp
pre-up wpa_supplicant -B -i wlp4s0 -c /etc/wpa_supplicant/wpa_supplicant.conf
pre-down killall -q wpa_supplicant



#wpa-ssid "TP-Link_5E2E"
#wpa-ssid "Redmi 9C NFC"



sudo apt install --no-install-recommends network-manager
nmcli connection add ifname wlp4s0 type wifi ssid MySSID
nmcli connection edit wifi-wlp4s0
While editing the config file you have to set WPA-PSK and the plain text password:

nmcli> goto wifi
nmcli 802-11-wireless> set mode infrastructure
nmcli 802-11-wireless> back
nmcli> goto wifi-sec
nmcli 802-11-wireless-security> set key-mgmt wpa-psk
nmcli 802-11-wireless-security> set psk your-plain-text-password
nmcli 802-11-wireless-security> save
nmcli 802-11-wireless-security> quit
ya
^-^
Сообщения: 2336
Зарегистрирован: 16 дек 2021, 19:56

Re: wi-fi подключение

Сообщение ya »

iwlwifi-100-5.ucode
Ответить