GigsGigsCloud 教程 GigsGigsCloud 教程

  • GigsGigsCloud.com
  • GigsGigs.com
Home / 安全防御教程 / 通过配置iptables有效防止syn、ddos、ping等攻击

通过配置iptables有效防止syn、ddos、ping等攻击

6721 views 1 min , 11 sec read 0

安装

1.先编辑iptables

vi /etc/sysconfig/iptables

2.在iptables中加入下面几行

#anti syn,ddos
-A FORWARD -p tcp --syn -m limit --limit 1/s --limit-burst 5 -j ACCEPT
-A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT
-A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT

说明:

第一行:每秒中最多允许5个新连接

第二行:防止各种端口扫描

第三行:Ping洪水攻击(Ping of Death)

可以根据需要调整或关闭

 

3.重启防火墙

/etc/init.d/iptables restart

其他命令


可以随着自己喜好添加 附带本人自己的

屏蔽一个IP

# iptables -I INPUT -s 192.168.0.1 -j DROP

 

怎么防止别人ping我??

# iptables -A INPUT -p icmp -j DROP

 

防止同步包洪水(Sync Flood)

# iptables -A FORWARD -p tcp –syn -m limit –limit 1/s -j ACCEPT

 

防止各种端口扫描

# iptables -A FORWARD -p tcp –tcp-flags SYN,ACK,FIN,RST RST -m limit –limit 1/s -j ACCEPT

 

Ping洪水攻击(Ping of Death)

#iptables -A FORWARD -p icmp –icmp-type echo-request -m limit –limit 1/s -j ACCEPT

 

# NMAP FIN/URG/PSH

# iptables -A INPUT -i eth0 -p tcp –tcp-flags ALL FIN,URG,PSH -j DROP

 

# Xmas Tree

iptables -A INPUT -i eth0 -p tcp –tcp-flags ALL ALL -j DROP

 

# Another Xmas Tree

# iptables -A INPUT -i eth0 -p tcp –tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP

 

# Null Scan(possibly)

iptables -A INPUT -i eth0 -p tcp –tcp-flags ALL NONE -j DROP

 

# SYN/RST

# iptables -A INPUT -i eth0 -p tcp –tcp-flags SYN,RST SYN,RST -j DROP

 

# SYN/FIN — Scan(possibly)

# iptables -A INPUT -i eth0 -p tcp –tcp-flags SYN,FIN SYN,FIN -j DROP

 

##限制对内部封包的发送速度

#iptables -A INPUT -f -m limit –limit 100/s –limit-burst 100 -j ACCEPT

##限制建立联机的转

#iptables -A FORWARD -f -m limit –limit 100/s –limit-burst 100 -j ACCEPT

我的设置


# Generated by iptables-save v1.4.7 on Sun Oct 2 00:30:53 2016
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [1:156]
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK RST -m limit --limit 1/sec -j ACCEPT
-A FORWARD -p icmp -m icmp --icmp-type 8 -m limit --limit 1/sec -j ACCEPT
COMMIT
# Completed on Sun Oct 2 00:30:53 2016
iptables教程 安全防御教程

About MONSTER

View all posts by MONSTER →

Related Articles

  • iptables 封禁 BT/PT/SPAM(垃圾邮件)和自定义端口/关键词 一键脚本
  • iptables之禁ping和ddos向外发包
  • PHP各版本PHP.INI基本安全设置
  • 防止利用Wget等方式进行扒站
COPYRIGHT © GIGSGIGSCLOUD.COM GIGSGIGS.COM. 本站教程仅供参考,本站不提供任何技术支持, 也不负责任何有可能引起的问题,如遇问题请借助搜索引擎。