分类 wifidog安装 下的文章

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

首先安装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。

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

wifidog1.png

安装完成后,
/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版点http://www.authpuppy.org/doc/Getting_Started_-_Windows)。

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

当然了,我们还需要设置管理员的账号。
进入Manage plugins,Install apAuthLocalUserPlugin,记得要enable这个插件。

wifidog3.png

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

wifidog4.png

到这里,AuthPuppy就基本配置完毕了。
下面回到路由器,编辑wifidog.conf,一般情况下,我们之后配置ExternalInterface,GatewayInterface和AuthServer这三项就可以,其他默认。下面是我的配置:

GatewayID default           #注意这个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。注意不是下面这个:
wifidog5.png

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

源文档 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://www.wifidog.pro/2014/12/15/openwrt%E4%BD%BF%E7%94%A8wifidog%E5%AE%9E%E7%8E%B0%E8%AE%A4%E8%AF%81.html整理编辑,转载请注明出处

wifidog标准流程描述

一 认证流程描述
  i. Wifidog 运行之后建立一系列的防火墙规则,主要规则起到如下作用:

    1.阻断所有内网到外网的访问。

    2.开通内网到外网的 dns 访问。

    3.开通内网到认证服务器以及域名白名单的访问。

    4.对内网到外网 80 端口的访问转向到 wifidog 自己的 http 服务(2060 端口)。

  ii. 手机、pc 连接上来后,app 或者系统(安卓、ios 会自己连接到各自的服务器上来验证网络的连通性)会发起对外网的访问请求,dns 请求会被放过,然后对应的 80 端口的访问会被指向 2060 的 http 服务,其他的请求都会被拦截。
  iii. Wifidog 的 http 接到 web 请求后,基本上都会被指向 404 页面,404 页面会给客户端一个重定向返回(302),要求客户端重定向访问认证服务器的 login 页面,附加参数 gw_id、gw_address、gw_port、url。
  iv. 手机、pc 客户端加载、显示认证服务器的 login 页面,用户根据页面内容做相关的认证操作(qq 登录、微博登录、用户名密码登录、手机短信登录等多种登录方式) ,原则只有一个认证不成功就仍然让用户停留在认证服务器继续认证操作,认证成功给客户端一个 302 重定向返回,根据 login 接口提交上来的参数 gw_address、gw_port 跳转套 wifidog web 服务的/wifidog/auth 页面上,附带 token 和 url 参数。
  v. Wifidog 的 web 服务收到手机、pc 客户端的/wifidog/auth 请求后,会主动对认证服务器的 auth 接口发起一个验证请求, 附带参数 ip、 mac、 token、 stage=loginvi. 认证服务器的 auth 接口收到 wifidog 的请求, 要根据内部逻辑返回是否允许通过的应答 :

    Auth: 0 拒绝

    Auth: 1 允许

  vii. Wifidog 接收到验证结果后,如果拒绝访问,就会返回 302 给客户端,重定向到认证服务器的 gw_message 接口,附带 message=denied 参数,客户端的上网访问仍然会回到第二步骤;如果允许访问,则改动防火墙规则,开通改客户端的上网(至此客户端已经能够正常上网) ,然后返回 302 重点向给客户端,重定向到认证服务器的 portal 接口,附带参数 gw_id。

  viii. 认证服务器的的 portal 接口根据业务流成显示广告业或者做其他的跳转ix. 整个认证流程完成。

二 ping 心跳流程描述
  i. ping 接口 wifidog 检测认证服务器访问是否正常、并向认证服务器提交 wifidog的运行状态。
  ii. 定时 ping 认证服务器。
  iii. 提交的参数 gw_id、sys_uptime、sys_memfree、wifidog_uptime。

三 auth 心跳流程描述
  i. 和 ping 一样的频率定期请求认证服务器,并且有多少已认证客户端就发多少请求。
  ii. 用来向认证服务器提交客户端的状态以及执行认证服务的验证结果。
  iii. 提交的参数有:ip、mac、token、incoming、outgoing 、stage=counters。
  iv. 如果服务器返回拒绝,则 wifidog 改动防火墙规则,关闭该客户端的上网。

本文章由 http://www.wifidog.pro/2014/12/12/wifidog%E6%B5%81%E7%A8%8B.html 整理编辑,转载请注明出处

WifiDog 认证原理和流程

WifiDOG是一个热点系统,包含了认证服务器和客户端两部分组成,认证原理大体说下:

General Flow Description:
一般流程描述:
①The client does his initial request, as if he was already connected, (e.g.: http://www.google.ca)
客户端发出初始化请求,比如访问 www.google.ca 这个站点

②The Gateway's firewall rules mangle the request to redirect it to a local port on the Gateway. When that's the done, the Gateway provides an HTTP Redirect reply that contains the Gateway ID, Gateway FQDN and other informations
网关的防火墙规则将这个请求重定向到本地网关的端口上。当做完这个工作,网关提供一个HTTP重定向回复,包含了Gateway的ID,Gateway的FQDN以及其他的信息。

③The Client does his request to the Auth Server as specified by the Gateway, see Login Protocol
用户向认证服务器发出认证请求

http://auth_server/login?
gw_id=[GatewayID, default: "default"]
gw_address=[GatewayAddress, internal IP of router]
gw_port=[GatewayPort, port that wifidog Gateway is listening on]
url=[user requested url]

④The Gateway replies with a (potentially custom) splash (login) page
网关返回一个(可以是自定义的)splash(也称作“登录”)页面

⑤The Client provides his identification informations (username and password)
用户提供他的凭据信息,比如用户名和密码

⑥Upon succesful authentication, the client gets an HTTP Redirect to the Gateway's own web server with his authentication proof (a one-time token), http://GatewayIP:GatewayPort/wifidog/auth?token=[auth token]
成功认证的话,客户端将会被重定向到网关的自己的web页面上,并且带有一个 认证凭据(一个一次性的token),内容比如
http://GatewayIP:GatewayPort/wifidog/auth?token=[auth token]

⑦The Client then connects to the Gateway and thus gives it his token
用户就是用获取到的凭据访问网关

⑧The Gateway requests validation of the token from the Auth Server, see Client Protocol【见登录心跳】
网关去认证服务器询问token的有效性

⑨The Auth Server confirms the token
认证服务器确认token的有效性

①①The Gateway then sends a redirect to the Client to obtain the Success Page from the Auth Server, redirects to http://auth_server/portal/
网关发送重定向给客户端,以从认证服务器上获取 成功提示页面,重定向到 http://auth_server/portal/ 这个位置

①②The Auth Server notifies the Client that his request was successful
认证服务器通知客户请求成功,可以上网了

1123.png

这个是原理图,大概需要11步才能完成认证,这种token认证方式有个好处,可以第三方认证后然后到wifidog的认证服务器取一个有效的token给用户,实现与第三方认证的整合。

本文章由 http://www.wifidog.pro/2014/12/12/39.html 整理编辑,转载请注明出处

wifidog和authpuppy配合使用,实现wifi认证

通过在路由器系统(比如dd-wrt,openwrt)安装wifi看门狗程序wifidog,在认证服务器安装authpuppy wifi认证程序,可以实现类似在商场、机场、银行经常看到的免费wifi使之前看到的认证页面或产品、企业广告、介绍页面的功能。(wifidog 和 authpuppy 都是开源项目)

wifidog
官网地址:http://dev.wifidog.org/

authpuppy
官网地址:http://www.authpuppy.org

openwrt安装wifidog方法
http://wiki.openwrt.org/doc/howto/wireless.hotspot.wifidog?s[]=wifidog

linux安装authpuppy方法
可以看下这篇文章:
http://blog.csdn.net/sdvch/article/details/16350763
也可以在官网查看http://www.authpuppy.org

如果自己没有服务器搭建authpuppy认证程序,但是路由器是dd-wrt,openwrt系统可以通过安装wificat实现无线认证功能,可参考如下两篇文章
dd-wrt 安装wificat方法:http://bbs.pcpop.com/forum.php?mod=viewthread&tid=10646786
openwrt安装wificat方法:http://www.right.com.cn/forum/thread-141807-1-1.html

本文章由 http://www.wifidog.pro/2014/12/12/wifidog%E5%92%8Cauthpuppy.html 整理编辑,转载请注明出处