买了一台wifipineapple, pineapple有两种版本, 第一种是3G版本,可以外接3G上网卡, 还有一种是wifi版本, 包含一个物理的网络插槽, 我买的是第二种
wifipineapple包含了一个USB接口, 所以可以通过外接USB网卡, 实现网络的桥接
通过ssh连接到wifipineapple的网络,, 登陆密码为 pineapplesareyummy:
1:网卡修改为可用
ifconfig wlan1 up
2:重新启动wifipineapple
3:通过VIM修改无线网络配置
vim /etc/config/network
添加以下代码:
config interface wwan
option proto dhcp
添加以后是这样的:
4:修改wireless配置文件
vim /etc/config/wireless
修改配置文件:
config wifi-device radio0
option type mac80211
option channel
option hwmode 11ng
option macaddr :cf::9d::6a
option htmode HT20
list ht_capab SHORT-GI-
list ht_capab SHORT-GI-
list ht_capab RX-STBC1
list ht_capab DSSS_CCK-
# REMOVE THIS LINE TO ENABLE WIFI:
# option disabled config wifi-iface
option device radio0
option network lan
option mode ap
option ssid "FreeWifi"
option encryption none config wifi-device radio1
option type mac80211
option channel //无线网络的信道
option hwmode 11ng
option macaddr ::f9:1a::d4
option htmode HT20
list ht_capab SHORT-GI-
list ht_capab SHORT-GI-
list ht_capab RX-STBC1
list ht_capab DSSS_CCK-
# REMOVE THIS LINE TO ENABLE WIFI:
# option disabled config wifi-iface
option device radio1
option network wwan //网卡端口
option mode sta
option ssid //无线网络名字
option encryption mixed-psk+ccmp // 加密方式
option key //加密密码
encrytion是指加密方式, 加密方式有可以参考下表 encryption:
psk2+tkip+ccmp psk2+tkip+aes | WPA2 Personal (PSK) | TKIP, CCMP |
psk2+tkip | WPA2 Personal (PSK) | TKIP |
psk2+ccmp psk2+aes psk2 | WPA2 Personal (PSK) | CCMP |
psk+tkip+ccmp psk+tkip+aes | WPA Personal (PSK) | TKIP, CCMP |
psk+tkip | WPA Personal (PSK) | TKIP |
psk+ccmp psk+aes psk | WPA Personal (PSK) | CCMP |
psk-mixed+tkip+ccmp psk-mixed+tkip+aes | WPA/WPA2 Personal (PSK) mixed mode | TKIP, CCMP |
psk-mixed+tkip | WPA/WPA2 Personal (PSK) mixed mode | TKIP |
psk-mixed+ccmp psk-mixed+aes psk-mixed | WPA/WPA2 Personal (PSK) mixed mode | CCMP |
wpa2+tkip+ccmp wpa2+tkip+aes | WPA2 Enterprise | TKIP, CCMP |
wpa2+ccmp wpa2+aes wpa2 | WPA2 Enterprise | CCMP |
wpa2+tkip | WPA2 Enterprise | TKIP |
wpa+tkip+ccmp wpa+tkip+aes | WPA Enterprise | TKIP, CCMP |
wpa+ccmp wpa+aes | WPA Enterprise | CCMP |
wpa+tkip wpa | WPA Enterprise | TKIP |
wpa-mixed+tkip+ccmp wpa-mixed+tkip+aes | WPA/WPA2 Enterprise mixed mode | TKIP, CCMP |
wpa-mixed+tkip | WPA/WPA2 Enterprise mixed mode | TKIP |
wpa-mixed+ccmp wpa-mixed+aes wpa-mixed | WPA/WPA2 Enterprise mixed mode | CCMP |
5:执行命令:
ifup wwan
网卡会连接热点 ,连上以后, ifconfig可以看到获取的IP地址
6:现在要做消息转发,执行命令:
iptables -t nat -A POSTROUTING -o wlan1 -j MASQUERADE
7:在/etc/rc.local的底部添加iptalbes自动转发, 以后每次启动, 都会自动运行
iptables -t nat -A POSTROUTING -o wlan1 -j MASQUERADE