interfaces文件配置wireless连接

配置文件访问无线网络

在/etc/network/interfaces文件可以配置要默认访问的无线热点:

动态获取ip:

1
2
3
4
5
# wireless
auto wlan0
iface wlan0 inet dhcp
wpa-ssid ESSID/SSID
wpa-psk pre-shared-key

配置静态ip:

1
2
3
4
5
6
7
8
9
10
# wireless
auto wlan0
iface wlan0 inet static
address 192.168.1.110
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
wpa-ssid ESSID/SSID
wpa-psk pre-shared-key

重新启动网络服务即可连接到默认的热点。

命令行手动扫描并连接到热点

扫描热点:

1
2
# iwlist wlan0 scan
# iw dev wlan0 scan

连接到热点:

1
# wpa_supplicant -i wlan0 -c <(wpa_passphrase ESSID pre-shared-key) -B

动态获取ip:

1
# dhclient wlan0

设置静态ip:

1
2
# ip addr add 192.168.1.110/24 dev wlan0
# ip route add default via 192.168.1.1

===
[erq]