切换网络环境后,要注意的几个地方
1.检查网关地址
[email protected]:/etc $ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.32.1 0.0.0.0 UG 303 0 0 wlan0
192.168.32.0 0.0.0.0 255.255.255.0 U 303 0 0 wlan0
2. /etc/dhcpcd.conf -------->>>设置静态IP
interface wlan0 #------------>>>无线网卡的设置
inform 192.168.32.38
static routers=192.168.32.1 # ---------------->>>修改为当前网络环境的路由地址
static domain_name_servers=8.8.8.8
static domain_search=114.114.114.114
interface enxb827ebf887e2 #------------>>>有线网卡的设置
inform 192.168.32.74
static routers=192.168.32.1
static domain_name_servers=8.8.8.8
static domain_search=114.114.114.114
#两个不同的网络环境
SSID ABC
inform 192.168.10.38
static routers=192.168.10.1
static domain_name_servers=114.114.114.114
static domain_search=8.8.8.8
SSID XYZ
inform 192.168.32.38
static routers=192.168.32.1
static domain_name_servers=114.114.114.114
static domain_search=8.8.8.8
3. /etc/wpa_supplicant/wpa_supplicant.conf
.......
network={
ssid="ABC"
psk="YYYYYYYYYYYYYY" #----------->>>ABC的密码
key_mgmt=WPA-PSK
}
network={
ssid="XYZ"
psk="XXXXXXXXXXXX" #----------->>>XYZ的密码
key_mgmt=WPA-PSK
}
4. /etc/resolc.conf -------->>>设置DNS服务器地址,ping 本地路由OK,但不能上网时检查
# Generated by resolvconf
search 8.8.8.8
nameserver 114.114.114.114