设为首页 收藏本站
查看: 1298|回复: 0

[经验分享] OpenWRT使用wifidog实现强制认证的WIFI热点

[复制链接]

尚未签到

发表于 2015-10-1 05:40:16 | 显示全部楼层 |阅读模式
  首先安装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里面也看不到。
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&prime;
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&prime;
        option _orig_bridge ‘false’
config interface ‘WAN’
        option proto ‘dhcp’
        option _orig_ifname ‘gretap0&prime;
        option _orig_bridge ‘false’
        option ifname ‘eth0&prime;
  
  之前我用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://wiki.openwrt.org/doc/howto/wireless.hotspot.wifidog>

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-121054-1-1.html 上篇帖子: mt7620 wifi driver 下篇帖子: win8怎么设置wifi热点共享
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表