Ubuntu 使用 netplan 配置 WIFI
在折腾 Ubuntu 的时候,我突然发现 Ubuntu 有好几套网络管理方案,但是在安装了图形化界面以后,只有Network Manager & Systemd-networkd 之一生效,
那像我这种爱折腾的人,肯定是不满足被束缚啊,为什么不能用命令行来连接 ? WiFi 呢?
查看网卡名字
1
2
3
4
5
6
7
8
9
|
$ ~ iw dev
phy#0
Interface wlx200db035fad3
ifindex 3
wdev 0x1
addr 20:0d:b0:35:fa:d3
ssid Tenda_277D40
type managed
txpower 12.00 dBm
|
打开无线网卡
1
|
$ ~ sudo ip lin set wlx200db035fad3 up
|
搜索 WiFi 信号
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
$ ~ sudo iw dev wlx200db035fad3 scan
BSS **:**:**:**:**:**(on wlx200db035fad3) -- associated
TSF: 1588670071330336 usec (18387d, 09:14:31)
freq: 2437
beacon interval: 100 TUs
capability: ESS Privacy ShortSlotTime (0x0411)
signal: -80.00 dBm
last seen: 0 ms ago
SSID: Tenda_277D40
Supported rates: 1.0* 2.0* 5.5 11.0 18.0 24.0 36.0 54.0
DS Parameter set: channel 6
ERP: <no flags>
ERP D4.0: <no flags>
Extended supported rates: 6.0 9.0 12.0 48.0
HT capabilities:
Capabilities: 0x18fc
HT20
SM Power Save disabled
RX Greenfield
RX HT20 SGI
RX HT40 SGI
TX STBC
No RX STBC
Max AMSDU length: 7935 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT RX MCS rate indexes supported: 0-15, 32
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 6
* secondary channel offset: no secondary
* STA channel width: 20 MHz
* RIFS: 1
* HT protection: no
* non-GF present: 0
* OBSS non-GF present: 0
* dual beacon: 0
* dual CTS protection: 0
* STBC beacon: 0
* L-SIG TXOP Prot: 0
* PCO active: 0
* PCO phase: 0
WPA: * Version: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Authentication suites: PSK
* Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
WMM: * Parameter version 1
* BE: CW 15-1023, AIFSN 3
* BK: CW 15-1023, AIFSN 7
* VI: CW 7-15, AIFSN 2, TXOP 3008 usec
* VO: CW 3-7, AIFSN 2, TXOP 1504 usec
|
我个人认为这一步纯属装 13! 我连接 ? WiFi,我肯定知道这个 WiFi の名字啊,那密码我肯定也知道啊,那还扫描个锤锤 ?啊?
配置 WiFi
1
|
$ ~ sudo nano /etc/netplan/01-network-manager-all.yaml
|
这个文件名大家理论上都是不一样的,但是配置文件都在这个 /etc/netplan/ 里面
1
2
3
4
5
6
7
8
9
10
|
network:
version: 2
renderer: networkd
wifis:
wlx200db035fad3:
dhcp4: yes
dhcp6: no
access-points:
Tenda_277D40:
password: "password"
|
这个配置文件是 YAML 使用的时候需要注意缩进,这样一番操作以后就可以
1
2
|
$ ~ sudo netplan generate //检查语法错误的
$ ~ sudo netplan apply
|
可以参考下面的文章,写的很规范 : connect-wifi-terminal-ubuntu