[关闭]
@orangleliu 2016-09-23T10:17:26.000000Z 字数 1709 阅读 3515

OpenWrt iptables 应用

物联网 openwrt


流量监控

  1. openwrt监控某个ip
  2. 添加一个新的iptables chain
  3. iptables -N P45
  4. 往刚才建的P45delegate_forward添加rulesip换成你想监控的
  5. iptables -I P45 -s 192.168.111.115 -j ACCEPT
  6. iptables -I P45 -d 192.168.111.115 -j ACCEPT
  7. iptables -I forwarding_rule -s 192.168.111.115 -j P45
  8. iptables -I forwarding_rule -d 192.168.111.115 -j P45
  9. -I 代表chain
  10. -s source
  11. -d destination
  12. -j 如果符合就
  13. # iptables -nvL forwarding_rule|grep 192.168.111.115
  14. 19657 20M P45 all -- * * 0.0.0.0/0 192.168.111.115
  15. 20214 2172K P45 all -- * * 192.168.111.115 0.0.0.0/0
  16. -n 显示端口号
  17. -L 规则
  18. -v 显示计数

监控本机某个IP和端口

  1. iptables -I INPUT -d 45.78.37.246 -p tcp --dport 9999
  2. iptables -I OUTPUT -s 45.78.37.246 -p tcp --sport 9999
  3. iptables -I INPUT -d 45.78.37.246
  4. iptables -I OUTPUT -s 45.78.37.246
  5. iptables -nvL
  6. 删除不需要的链
  7. iptables -n -L -v --line-numbers
  8. iptables -D INPUT 1

白名单

非转发

  1. 禁止某个MAC
  2. iptables -A INPUT -m mac --mac-source 00:0F:EA:91:04:08 -j DROP
  3. 只让某个mac访问某个端口
  4. iptables -A INPUT -p tcp --destination-port 22 -m mac --mac-source 00:0F:EA:91:04:07 -j ACCEPT

openwrt 认证使用 Wifidog类似

  1. 还没认证
  2. iptables -F forwarding_rule
  3. iptables -t nat -F prerouting_rule
  4. iptables -I forwarding_rule -s 192.168.111.0/24 -j DROP
  5. iptables -t nat -I prerouting_rule -p tcp -s 192.168.111.0/24 --dport 80 -j DNAT --to 192.168.111.1:81
  6. while list
  7. iptables -I forwarding_rule -d 115.29.203.45 -j ACCEPT
  8. iptables -t nat -I prerouting_rule -p tcp -d 115.29.203.45 --dport 80 -j ACCEPT
  9. iptables -I forwarding_rule -d mapi.alipay.com -j ACCEPT
  10. iptables -t nat -I prerouting_rule -p tcp -d mapi.alipay.com --dport 80 -j ACCEPT
  11. 开启某个MAC上网
  12. iptables -I forwarding_rule -m mac --mac-source a4:5e:60:cd:b3:d9 -j ACCEPT
  13. iptables -t nat -I prerouting_rule -p tcp -m mac --mac-source a4:5e:60:cd:b3:d9 --dport 80 -j ACCEPT

参考文章

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注