使用nmcli来创建一个无线热点

文章来源: https://unix.stackexchange.com/a/310699

1
2
3
4
5
6
7
# wlan0 换成自己的无线网卡名称, APname换成自己的热点名称
nmcli con add type wifi ifname wlan0 con-name APname autoconnect yes ssid APname
nmcli con modify APname 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared
nmcli con modify APname wifi-sec.key-mgmt wpa-psk
# wifipassword改成自己想要的密码
nmcli con modify APname wifi-sec.psk "wifipassword"
nmcli con up APname

如果重启后nmcli con up APname不起作用

请改用此命令来启动 APname

1
2
3
# 注意将APname换成自己的热点名称
UUID=$(grep uuid /etc/NetworkManager/system-connections/APname cut -d= -f2)
nmcli con up uuid $UUID