OpenWRT使用wifidog實現強制認證的WIFI熱點

來源:互聯網
上載者:User

標籤:

首先安裝wifidog到OpenWRT的路由器:

  opkg update

  opkg install wifidog

  

wifidog依賴下面這些模組:

iptables-mod-extra

iptables-mod-ipopt

kmod-ipt-nat

iptables-mod-nat-extra

libpthread

  

由於trunk的韌體更新會比較頻繁,會導致直接opkg install wifidog安裝不了,如果你湊巧又沒有備份與韌體對應的Packages的話,就需要到http://downloads.openwrt.org/snapshots/trunk升級韌體,然後再安裝wifidog。我備份了一個2013年7月份(kernel =3.10.3-1-9da5017d589c0594e545ab00a51eecea)的版本的Packages,需要的話拿去用:

http://openwrt.sinapp.net

  

如果你的路由器不是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裡面也看不到。

[email protected]:~# 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:

[email protected]:~# 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

 

來源文件 <http://unix.stackexchange.com/questions/57309/how-can-i-tell-whether-a-network-interface-is-physical-device-or-virtual-alia>

 

 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

 

來源文件 <http://wiki.openwrt.org/doc/howto/wireless.hotspot.wifidog> 

OpenWRT使用wifidog實現強制認證的WIFI熱點

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.