tplink-703n-openwrt 使用iptables控制连接wlan的客户端 不生效 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
scola
V2EX    Linux

tplink-703n-openwrt 使用iptables控制连接wlan的客户端 不生效

  •  
  •   scola Oct 27, 2013 7480 views
    This topic created in 4572 days ago, the information mentioned may be changed or developed.
    我家里用了两台路由器,一台普通路由器A的连接宽带,ip:192.168.1.1
    另一台刷了openwrt的路由器B连接A的lan口,通过bridge上网,设置了 静态IP:192.168.1.111

    现在有一个android手机无线连接到 openwrt的路由器B,可以正常上网。手机的ip:192.168.1.100

    现在我想block掉手机的IP,让手机上不了网(其实我想干点别的,先从最简单的开始)

    我参考了这里 http://bredsaal.dk/some-small-iptables-on-openwrt-tips

    iptables -A input_wan -s 192.168.1.100 --jump REJECT
    iptables -A forwarding_rule -d 192.168.1.100 --jump REJECT

    运行完这两命令之后手机还是照样能上网。通过iptables -L,能在list里找到上面的命令
    在http://192.168.1.111/cgi-bin/luci/ 的防火墙里也能找到 相关的信息。

    链表 forwarding_rule (引用: 1)
    规则# 数据包 流量 对象 协议 标志 入口 出口 源地址 目的地址 选项
    1 0 0.00 B REJECT all -- * * 0.0.0.0/0 192.168.1.100 reject-with icmp-port-unreachable
    2 0 0.00 B DROP all -- * * 0.0.0.0/0 192.168.1.100 -

    链表 input_wan (引用: 1)
    规则# 数据包 流量 对象 协议 标志 入口 出口 源地址 目的地址 选项
    1 0 0.00 B REJECT all -- * * 192.168.1.100 0.0.0.0/0 reject-with icmp-port-unreachable
    2 0 0.00 B DROP all -- * * 192.168.1.100 0.0.0.0/0 -

    我又尝试了别的chain(INPUT,OUTPUT,FORWARD。。。)。REJECT换成DROP也不行
    手机始终能上网。到底要怎样才能让手机上不了网呢,或者问题出在哪里
    iptables的命令应该是没有问题的。能控制openwrt的lan端口转发。

    各位大大能不能给点建议。谢谢^_^
    Supplement 1    Oct 29, 2013
    我把自带的防火墙卸载了 opkg remove firewall
    还是不能用iptables 控制 wan

    我使用 iptables -I OUTPUT -o br-lan -j DROP 之后
    不能 ssh 到路由器了。http://192.168.1.111/cgi-bin/luci/ 也无法打开。
    说明iptables是没有问题的。但是此时手机连接路由器的wifi仍然可以上网。
    总之就是wifi不受iptables的控制
    Supplement 2    Nov 26, 2013
    多谢大侠shell909090的在博客中的回复
    http://shell909090.com/blog/2011/09/%E5%90%88%E7%94%A8%E4%B8%A4%E4%B8%AA%E8%B7%AF%E7%94%B1%E5%99%A8%E7%9A%84%E5%87%A0%E7%A7%8D%E6%96%B9%E6%A1%88/
    我这个路由器内核不支持bridg-nf,在支持bridge-nf之前,网桥的包都是二层的,不过iptables。
    我现在不使用bridge模式连网了,直接拨号连接,iptables生效了
    9 replies    1970-01-01 08:00:00 +08:00
    lenzhang
        1
    lenzhang  
       Oct 27, 2013   1
    楼主把openwrt自带的防火墙包卸载掉就好了
    LazyZhu
        2
    LazyZhu  
       Oct 27, 2013
    好乱啊,openwrt的路由器B设置为 192.168.2.x 不行吗?
    scola
        3
    scola  
    OP
       Oct 28, 2013
    @lenzhang 谢谢了,我晚上回家试试。现在还不清楚自带的防火墙包是那个
    @LazyZhu 这个IP当时没有太考虑,只是想着不和路由器A冲突就行。
    tywtyw2002
        4
    tywtyw2002  
       Oct 29, 2013   1
    -A是在最后面

    直接把防火墙block掉就好了

    或者自己在FORWARD表的最前面。。。。。。。


    我记得转发的数据包不走INPUT。
    如果DST_IP 不是路由器ip那么该包直走 forward
    http://www.opsers.org/wp-content/uploads/2010/03/123_thumb.png
    scola
        5
    scola  
    OP
       Oct 29, 2013
    @lenzhang
    @tywtyw2002

    我把自带的防火墙卸载了 opkg remove firewall
    还是不能用iptables 控制 wan

    我使用 iptables -I OUTPUT -o br-lan -j DROP 之后
    不能 ssh 到路由器了。http://192.168.1.111/cgi-bin/luci/ 也无法打开。
    说明iptables是没有问题的。但是此时手机连接路由器的wifi仍然可以上网。
    总之就是wifi不受iptables的控制
    tywtyw2002
        6
    tywtyw2002  
       Oct 29, 2013 via iPhone
    在forward 表里面加。。 用I 别用A
    -s 原地址 -j drop
    scola
        7
    scola  
    OP
       Oct 30, 2013
    @tywtyw2002 谢谢给建议,这个问题困扰我有几天了。
    iptables -I FORWARD -s 192.168.1.100 -j DROP
    这个我肯定也试过。
    晚上回家再试一遍
    zjgsamuel
        8
    zjgsamuel  
       Nov 26, 2013
    当你试的一点办法都没有的时候 可以试一下 DDWRT 说不定有惊喜
    我上次试一个无线桥接 openwrt死活不行 , DDWRT 一试就可以..
    xseven007
        9
    xseven007  
       Nov 26, 2013 via Android
    你用dhcp client模式不行么
    About     Help     Advertise     Blog     API     FAQ     Solana     2188 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 37ms UTC 00:24 PVG 08:24 LAX 17:24 JFK 20:24
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86