Skip to content

Instantly share code, notes, and snippets.

@Akagi201
Created July 21, 2014 15:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Akagi201/d538705917e9d27b3e82 to your computer and use it in GitHub Desktop.
Save Akagi201/d538705917e9d27b3e82 to your computer and use it in GitHub Desktop.

安装

  • opkg update
  • opkg install nodogsplash

repo

官网

配置

社区

FirewallRuleSet

  • authenticated-users
  • preauthenticated-users
  • users-to-router

EmptyRuleSetPolicy

  • authenticated-users
  • preauthenticated-users
  • users-to-router
  • trusted-users
  • trusted-users-to-router

每个进入路由器的包有4种类型

  • Blocked - MACMechanism block: 在BlockedMACList / MACMechanism allow: 不在AllowedMACList或者TrustedMACList.
  • Trusted - 在TrustedMACList, 放行, 定制行为: FirewallRuleSet trusted-users和trusted-users-to-router, 或者EmptyRuleSetPolicy trusted-users 和 trusted-users-to-router.
  • Authenticated - 通过认证, 没有超期. 定制行为在: FirewallRuleSet authenticated-users 和 users- to-router
  • Preauthenticated - 任何其他的包, 定制行为在: FirewallRuleSet preauthenticated-users 和 users-to-router, 所有其他的包都被dropped, 除了目的端口是80的包, 被重定向到2050(nodogsplash内建的http服务器在监听的), 这个会启动authentication过程, 服务器将会serve一个splash网页返回给源IP, 用户点击splash page上的一个合适的链接就会完成认证过程. 使得后面这个IP/MAC的包被标记为Authenticated, 直到inactive或者forced timeout达到, 然后他的包重新变为Preauthenticated.
  • Nodogsplash实现这些动作通过在路由器的iptables mangle PREROUTING chain中插入规则来标记这些包.并且在匹配这些标记的nat PREROUTING, filter INPUT和filter FORWARD chains上插入规则. 因为他插入这些规则在现有的chains的开始处, 所以nodogsplash对于大多的现有的防火墙配置不受影响.

流量控制Traffic Control

  • nodogsplash在他管理的接口上也实现了基本的流量控制, 这个特性可以指定clients的最大上传和下载流量. 通过使能2个Intermediate Queue Devices (IMQ's), 一个用于upload一个用于download, 并且给他们附加简单的rate-limited HTB qdiscs. 规则被插入到路由器的iptables mangle PREROUTING 和 POSTROUTING tables来跳到这些IMQ's. 结果是简单但是有效的尾部丢弃限制速率.(没有packet classification或者fairness queueing)

FirewallRule 格式

  • FirewallRule permission [protocol [port portrange] [to ip]
  • permission:必选, 必须是: allow, block, drop, log 或者 ulog
  • protocol: 可选, 必须是: tcp, udp, icmp或者all, 默认是all
  • port portrange: 可选, protocol必须是: tcp 或 udp, portrange可以是一个单一数字端口或者冒号分割范围,如 1024:2048, 默认是所有端口.
  • to ip: 可选, ip必须是点十进制带有可选的子网掩码, 默认是: 0.0.0.0/0, 所有地址.

splash.html 定制

  • $gatewayname: nodogsplash.conf中的GatewayName.
  • $authtarget: 一个URL编码了一个唯一的token和用户原始web请求的URL. 如果nodogsplash在这个URL上接收到了请求, 他会完成authentication过程, 并且返回"302 Found"到编码的原始的web请求URL(或者你可以使用一个GET方法来发送这个信息给nodogsplash)
  • $imagesdir: nodogsplash的 web hierarchy的图片目录
  • $tok, $redir,$authaction, and $denyaction 也是可用的, 如果你想要使用GET方法而不是使用$authtarget来和nodogsplash server通信, 例子:
<form method='GET' action='$authaction'>
<input type='hidden' name='tok' value='$tok'>
<input type='hidden' name='redir' value='$redir'>
<input type='submit' value='Click Here to Enter'>
</form>

infoskel.html - 错误页面

  • $gatewayname, $version, $title 和 $content这些变量可以使用.
  • $title 是错误描述的总结或者错误类型.
  • $content 是错误的内容.

认证方式

  1. Site-wide username and password Nodogsplash可以被配置成需要一个用户名和/或密码输入到splash page作为认证过程的一部分. 由于用户名和密码是site-wide(not per user), 他们使用HTTP GET明文进行发送, 不安全.使能他需要设置PasswordAuthentication, UsernameAuthentication, Password, Username, and PasswordAttempts, 然后splash page必须使用一个GET方法来发送用户输入的用户名和/或密码. 例子:
<form method='GET' action='$authaction'>
<input type='hidden' name='tok' value='$tok'>
<input type='hidden' name='redir' value='$redir'>
username: <input type='text' name='nodoguser' value='' size='12' maxlength='12'>
<br>
password: <input type='password' name='nodogpass' value='' size='12' maxlength='10'>
<br>
<input type='submit' value='Enter'>
</form>
  1. Forwarding authentication 转发认证 Nodogsplash允许调用一个外部程序来认证, 使用nodogsplash.conf里面的参数: BinVoucher/EnablePreAuth/ForceVoucher. 对于BinVoucher的给定的程序将会被调用使用客户端的mac地址作为参数.输出是作为客户端被认证的时间的秒数,他也可能包含客户端上传和下载的速度KBits/s.

ndsctl

一个独立程序, 使用unix socket与nodogsplash通信. ndsctl -h

调试nodogsplash

  • 最大化输出调试信息: -s -f -d 7.
  • 当停止运行, nodogsplash删除他的规则, 如果没有(crash情况), 那么可以手动start然后stop nodogsplash来清除规则.
  • nodogsplash的运行是通过mark packets(如果使能了traffic control, 那么passing packets through intermediate queueing devices), 大多数的QOS包也会mark packets 和使用 IMQ's. 一起用可能会失效, 为了检查所有的规则, 如 the mangle table chains, iptables -t mangle -v -n -L

问题

char *bin_voucher;    /**< @brief enable voucher support */
	char force_voucher;    /**< @brief force voucher */
	int authenticate_immediately;	/**< @brief boolean, whether to auth noninteractively */
	int set_mss;			/**< @brief boolean, whether to set mss */
	int mss_value;		/**< @brief int, mss value; <= 0 clamp to pmtu */
	int macmechanism; 		/**< @brief mechanism wrt MAC addrs */
	```
	`invalid request path wifidog`
@aaronchn
Copy link

aaronchn commented Jul 9, 2015

能否帮忙看看这个问题,nodogsplash/nodogsplash#72

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment