gdtv
V2EX  ›  问与答

求助 iptables 屏蔽 IP 怎么写

  •  
  •   gdtv · May 21, 2015 · 2187 views
    This topic created in 4018 days ago, the information mentioned may be changed or developed.

    这是现在的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 replies    2015-05-21 15:32:44 +08:00
    liwei
        1
    liwei  
       May 21, 2015
    1. 把IP列表加入ipset
    2. 在iptables中使用ipset模块进行匹配,然后target设为DROP
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   973 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 19:43 · PVG 03:43 · LAX 12:43 · JFK 15:43
    ♥ Do have faith in what you're doing.