比如禁止访问166.436.676.464

解决方案 »

  1.   

    把192.168.1.12换成你要封锁的IP就行,tun0换成你想的网卡名即可//在网卡tun0封禁源为192.168.1.12的包
    iptables -I INPUT -s 192.168.1.12 -i tun0 -j DROP查看设置的策略
    [root]# iptables -nvL --line-number
    [root@H3C ~]# iptables -nvL --line-number
    Chain INPUT (policy DROP 2 packets, 104 bytes)
    num   pkts bytes target     prot opt in     out     source               destination         
    1        0     0 DROP      all  --  tun0*       192.168.1.12         0.0.0.0/0           id:0 
    2     400K   38M ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           id:0  state RELATED,ESTABLISHED删除规则
    iptables -D INPUT 1(这个数字是num列对应的规则)
      

  2.   

    理解错了, 那用下面的命令 -d 指定目的地址 -o 指定网卡iptables -I OUTPUT -d 192.168.1.2 -o tun0 -j DROP
      

  3.   

    hostdeny
      

  4.   

    如何去禁止tun0访问182.254.116.117呢