V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
gdtv
V2EX  ›  问与答

求助 iptables 屏蔽 IP 怎么写

  •  
  •   gdtv · 2015-05-21 15:13:39 +08:00 · 1841 次点击
    这是一个创建于 3478 天前的主题,其中的信息可能已经有所发展或是发生改变。

    这是现在的iptables规则
    我想屏蔽 123.123.123.1, 187.221.123.22等几百个IP,该怎么写?

    [root@cctv jet]# iptables -L
    Chain INPUT (policy ACCEPT)
    target prot opt source destination

    RH-Firewall-1-INPUT all -- anywhere anywhere

    Chain FORWARD (policy ACCEPT)
    target prot opt source destination

    RH-Firewall-1-INPUT all -- anywhere anywhere

    Chain OUTPUT (policy ACCEPT)
    target prot opt source destination

    Chain RH-Firewall-1-INPUT (2 references)
    target prot opt source destination

    ACCEPT all -- anywhere anywhere

    ACCEPT icmp -- anywhere anywhere icmp any
    ACCEPT esp -- anywhere anywhere

    ACCEPT ah -- anywhere anywhere

    ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
    ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:11
    ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http
    ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:https
    ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ftp
    ACCEPT tcp -- anywhere anywhere state NEW tcp dpts:30000:31999
    ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:smtp
    ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:EtherNet/IP-1
    ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:pop3
    ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:pop3s
    ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:imap
    ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:imaps
    ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:submission
    ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:domain
    REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

    1 条回复    2015-05-21 15:32:44 +08:00
    liwei
        1
    liwei  
       2015-05-21 15:32:44 +08:00
    1. 把IP列表加入ipset
    2. 在iptables中使用ipset模块进行匹配,然后target设为DROP
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5304 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 09:35 · PVG 17:35 · LAX 01:35 · JFK 04:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.