一条命令把笔记本变成 Wi-Fi 热点

用 nmcli 把电脑的网络共享给手机等设备。

Linuxnmcli 网络管理Wi-Fi热点NetworkManager低风险
运行 nmcli dev wifi hotspot ifname wlan0 ssid MyHotspot password 'pass12345',手机搜索并连接 MyHotspot 即可上网。

01命令

命令
$ nmcli dev wifi hotspot ifname wlan0 ssid MyHotspot password 'pass12345'

02作用说明

NetworkManager 的热点模式会把无线网卡变成一个迷你接入点,连上来的设备通过你当前的网络上网——完全不用改 hostapd 配置文件。它会保存为名为 Hotspot 的配置,之后用 nmcli con up Hotspot 一键再开。密码至少 8 位,否则手机会拒绝连接。

03风险

风险低风险
使用条件NetworkManager and a Wi-Fi card that supports AP mode (most laptops do); replace wlan0 with your interface from ip link
!注意: 热点共享的是你当前所在的网络——酒店或需网页认证的网络往往共享不出去;如果网卡不支持 AP 模式,命令会直接报错而不是静默降级。

04撤销

撤销
$ nmcli connection delete Hotspot

05来源

  • Software access point — Arch Wiki
    Arch Linux · community · 2026-09-17
    依据: NetworkManager can create a Wi-Fi access point with nmcli device wifi hotspot, sharing an internet connection with other devices.
  • nmcli(1) — Ubuntu manual page
    Ubuntu · community · 2026-09-17
    依据: nmcli device wifi hotspot creates an access point connection with the given ssid and password and starts sharing the current internet connection.

最后验证: 2026-09-18 · 分类: 网络