最近给家里吃灰的NUC5装了CentOS7(之前重装Windows给我玩坏了 而且配置实在不太跑得动) 记录一下配网的常用操作

步骤

找到网卡名称

1
ip address # 可简写为ip a

临时联网

1
2
wpa_supplicant -B -i <网卡名称> -c <(wpa_passphrase <WiFi名称> <WiFi密码>)
dhclient <网卡名称>

使用NetworkManager接管网络配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
yum -y install NetworkManager-wifi

systemctl start NetworkManager.service
systemctl enable NetworkManager.service
# 以上两行或chkconfig NetworkManager on

nmcli device set <网卡名称> managed yes

nmcli connection delete <WiFi名称>

nmcli device wifi connect <WiFi名称> password <WiFi密码>

nmcli connection modify <WiFi名称> ipv4.addresses 192.168.1.114/24
nmcli connection modify <WiFi名称> ipv4.gateway 192.168.1.1
nmcli connection modify <WiFi名称> ipv4.method manual
nmcli connection modify <WiFi名称> ipv4.dns "8.8.8.8"

nmcli connection up <WiFi名称>

cat /etc/sysconfig/network-scripts/ifcfg-<WiFi名称>
ip addr show <网卡名称>

systemctl restart NetworkManager