Linux uses a command line script to connect to wifi wifi name is WIFINAME wifi password is WIFIPASSWORD Set static ip to 192.168.0.111 subnet mask to 255.255.255.0 dns to

The following is a command line script to connect to wifi and set a static IP:

 
 

bashCopy code

#!/bin/bash # 设置要连接的WiFi的名称和密码 WIFINAME="your_wifi_name" WIFIPASSWORD="your_wifi_password" # 连接WiFi nmcli device wifi connect "$WIFINAME" password "$WIFIPASSWORD" # 设置静态IP nmcli connection modify "$WIFINAME" ipv4.method manual ipv4.addresses 192.168.0.111/24 ipv4.gateway 192.168.0.1 ipv4.dns 192.168.0.1 # 重启网络服务 systemctl restart NetworkManager.service

After the script is executed, the wifi with the specified name will be automatically connected, and the IP address will be set to the specified static IP. Please replace WIFINAME and WIFIPASSWORD in the script with your wifi name and password.

Guess you like

Origin blog.csdn.net/ihateright/article/details/131151890