首先安裝wifidog到OpenWRT的路由器:php
opkg updateweb
opkg install wifidogsql
wifidog依賴下面這些模塊:數據庫
iptables-mod-extraapache
iptables-mod-ipoptapp
kmod-ipt-natless
iptables-mod-nat-extratcp
libpthreadoop
因爲trunk的固件更新會比較頻繁,會致使直接opkg install wifidog安裝不了,若是你湊巧又沒有備份與固件對應的Packages的話,就須要到http://downloads.openwrt.org/snapshots/trunk升級固件,而後再安裝wifidog。我備份了一個2013年7月份(kernel =3.10.3-1-9da5017d589c0594e545ab00a51eecea)的版本的Packages,須要的話拿去用:this
若是你的路由器不是openwrt官方支持的版本的話,那就須要本身編譯固件。make menuconfig後,在Network–>Captive Portals中選擇wifidog.
安裝完成後,
/etc/init.d/wifidog enable
/etc/init.d/wifidog start
這時會拋出一個錯誤,由於咱們尚未設置AuthServer的信息。關於安裝wifidog更多的信息能夠參考:http://wiki.openwrt.org/doc/howto/wireless.hotspot.wifidog
下面安裝Auth Server,按照官方的說法:
AuthPuppy is the next generation authentication server for Wifidog networks.
源文檔 <http://www.authpuppy.org/>
不過貌似這wifidog和Authpuppy都已經N久沒更新了。。。
AuthPutty是須要安裝apache2, php5和MySQL。詳細介紹在這裏:http://www.authpuppy.org/doc/Getting_Started (Windows版點這裏)。
安裝成功後,訪問AuthPuppy會要求設置一些數據庫信息,所有設置完成後能看到首頁:
固然了,咱們還須要設置管理員的帳號。
進入Manage plugins,Install apAuthLocalUserPlugin,記得要enable這個插件。
而後,點擊Manage Nodes,把默認節點的status改爲deployed。這個GW(Gateway) ID default後面配置wifidog.conf的時候須要使用。
到這裏,AuthPuppy就基本配置完畢了。
下面回到路由器,編輯wifidog.conf,通常狀況下,咱們以後配置ExternalInterface,GatewayInterface和AuthServer這三項就能夠,其餘默認。下面是個人配置:
GatewayIDdefault #注意這個ID必須跟AuthPuppy的GW ID一致
# Parameter: ExternalInterface
# Default: NONE
# Optional
#
# Set this to the external interface (the one going out to the Inernet or your larger LAN).
# Typically vlan1 for OpenWrt, and eth0 or ppp0 otherwise,
# Normally autodetected
ExternalInterface eth0 #路由器外網的物理接口
# Parameter: GatewayInterface
# Default: NONE
# Mandatory
#
# Set this to the internal interface (typically your wifi interface).
# Typically br-lan for OpenWrt, and eth1, wlan0, ath0, etc. otherwise
GatewayInterface wlan0 #路由器內網的物理接口
AuthServer {
Hostname 192.170.1.104
SSLAvailable no
Path /
CheckInterval 60
ClientTimeout 5
FirewallRuleSet global {
}
FirewallRuleSet validating-users {
FirewallRule allow to 0.0.0.0/0
}
FirewallRuleSet known-users {
FirewallRule allow to 0.0.0.0/0
}
FirewallRuleSet unknown-users {
FirewallRule allow udp port 53
FirewallRule allow tcp port 53
FirewallRule allow udp port 67
FirewallRule allow tcp port 67
}
FirewallRuleSet locked-users {
FirewallRule block to 0.0.0.0/0
}
注意這個Interface是物理接口,而不是下面OpenWRT web界面中看到的interface。注意不是下面這個:
能夠看到個人Interface裏面沒有wlan0之類的選項,/etc/config/network裏面也看不到。
root@OpenWrt:~# cat /etc/config/network
config interface ‘loopback’
option ifname ‘lo’
option proto ‘static’
option ipaddr ‘127.0.0.1’
option netmask ‘255.0.0.0’
config globals ‘globals’
option ula_prefix ‘fd09:fd03:490d::/48′
config interface ‘lan’
option proto ‘static’
option ipaddr ‘192.168.1.1’
option netmask ‘255.255.255.0’
option ip6assign ’60’
option _orig_ifname ‘eth0′
option _orig_bridge ‘false’
config interface ‘WAN’
option proto ‘dhcp’
option _orig_ifname ‘gretap0′
option _orig_bridge ‘false’
option ifname ‘eth0′
以前我用gretap0和eth0設置ExternalInterface和GatewayInterface,不行。反着來也不行。網上搜了一圈,找到下面的方法來獲取physical interface:
root@OpenWrt:~# ls -l /sys/class/net
lrwxrwxrwx 1 root root 0 Jan 1 1970 eth0 -> ../../devices/platform/ag71xx.0/net/eth0
lrwxrwxrwx 1 root root 0 Jan 1 1970 lo -> ../../devices/virtual/net/lo
lrwxrwxrwx 1 root root 0 Aug 2 15:58 wlan0 -> ../../devices/platform/ar933x_wmac/net/wlan0
OK,原來我這邊也是有wlan0這個interface的,找到以後添加在wifidog.conf上。重啓wifidog,成功。
另外:
You can also run wifidog in foreground/Debug mode:
wifidog -f -d 7
-f means to run in foreground (do not become a background daemon)
-d 7 increases Debug output level to the maximum