OpenWRT使用wifidog实现强制认证的WIFI热点

简介: 首先安装wifidog到OpenWRT的路由器:   opkg update   opkg install wifidog    wifidog依赖下面这些模块: iptables-mod-extra iptables-mod-ipopt kmod-ipt-nat iptables-...

首先安装wifidogOpenWRT的路由器:

  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我备份了一个20137月份(kernel =3.10.3-1-9da5017d589c0594e545ab00a51eecea)的版本的Packages,需要的话拿去用:

http://openwrt.sinapp.net

  

如果你的路由器不是openwrt官方支持的版本的话,那就需要自己编译固件。make menuconfig后,在Network–>Captive Portals中选择wifidog.

wifidog1

安装完成后,

/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/>

不过貌似这wifidogAuthpuppy都已经N久没更新了。。。 

 

AuthPutty是需要安装apache2, php5MySQL。详细介绍在这里:http://www.authpuppy.org/doc/Getting_Started (Windows版点这里)

 

安装成功后,访问AuthPuppy会要求设置一些数据库信息,全部设置完成后能看到首页:

wifidog2

 

当然了,我们还需要设置管理员的账号。

 

进入Manage pluginsInstall apAuthLocalUserPlugin,记得要enable这个插件。

wifidog3

 

然后,点击Manage Nodes,把默认节点的status改成deployed。这个GW(Gateway) ID default后面配置wifidog.conf的时候需要使用。

wifidog4

 

到这里,AuthPuppy就基本配置完毕了。

 

下面回到路由器,编辑wifidog.conf,一般情况下,我们之后配置ExternalInterfaceGatewayInterfaceAuthServer这三项就可以,其他默认。下面是我的配置:

GatewayIDdefault           #注意这个ID必须跟AuthPuppyGW 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。注意不是下面这个:

wifidog5

 

可以看到我的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′

 

之前我用gretap0eth0设置ExternalInterfaceGatewayInterface,不行。反着来也不行。网上搜了一圈,找到下面的方法来获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

 

源文档 <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

目录
相关文章
|
7月前
|
Android开发
Android获取已连接wifi的热点信息(上位机开发学习之多个界面切换编程)
Android获取已连接wifi的热点信息(上位机开发学习之多个界面切换编程)
190 0
|
7月前
|
物联网 Android开发
Android获取已连接wifi的热点信息
Android获取已连接wifi的热点信息
187 0
|
网络协议 数据安全/隐私保护 Windows
Windows Win7建立wifi热点,手机共享WIFI上网
Windows Win7建立wifi热点,手机共享WIFI上网
153 0
|
网络安全 Android开发 Windows
如何让手机共享电脑代理网络的WIFI热点
如何让手机共享电脑代理网络的WIFI热点
2900 0
如何让手机共享电脑代理网络的WIFI热点
|
Ubuntu 数据安全/隐私保护
Ubuntu使用linux-wifi-hotspot创建WIFI热点
Ubuntu使用linux-wifi-hotspot创建WIFI热点
1003 0
Ubuntu使用linux-wifi-hotspot创建WIFI热点
|
Linux 开发工具 数据安全/隐私保护
Linux操作系统下开启wifi热点的方法
在很多场合下,网络使用是非常重要的,如果有一个Linux可以发出wifi热点,那么很多时候可以对于开发者来说是非常方便的。
993 1
|
Ubuntu 数据安全/隐私保护
Ubuntu 下建立WiFi热点的方法
使用ap-hotspot来创建WIFI热点。终端里输入: $ sudo add-apt-repository ppa:nilarimogard/webupd8 $ sudo apt-get update $ sudo apt-get install ap-hotspot $ sudo ap-...
1232 0
|
网络协议 Perl 数据安全/隐私保护
通过 Hostapd 进行 WIFI 热点共享上网
操作系统:Debian Gnu/Linux Jessie 内核: linux-image-4.3.0-0.bpo.1-amd64 网卡:腾达(Tenda) W311M 150M Mini无线USB网卡 最近发现自己的Debian之前可以使用GNOME3下的networkmanager进行WIFI共享上网功能因为内核升级导致无法使用。
2823 0