Created
April 12, 2015 22:34
-
-
Save lune-sta/4cd74c3b523d2f2eda3b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iptables -F | |
iptables -X | |
iptables -Z | |
iptables -P INPUT ACCEPT | |
iptables -P OUTPUT ACCEPT | |
iptables -P FORWARD ACCEPT | |
iptables -A INPUT -i lo -j ACCEPT | |
iptables -A INPUT -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT | |
### Stealth Scan | |
iptables -N STEALTH_SCAN | |
iptables -A STEALTH_SCAN -j LOG --log-prefix "stealth_scan_attack: " | |
iptables -A STEALTH_SCAN -j DROP | |
iptables -A INPUT -p tcp --tcp-flags SYN,ACK SYN,ACK -m state --state NEW -j STEALTH_SCAN | |
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j STEALTH_SCAN | |
iptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j STEALTH_SCAN | |
iptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j STEALTH_SCAN | |
iptables -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j STEALTH_SCAN | |
iptables -A INPUT -p tcp --tcp-flags FIN,RST FIN,RST -j STEALTH_SCAN | |
iptables -A INPUT -p tcp --tcp-flags ACK,FIN FIN -j STEALTH_SCAN | |
iptables -A INPUT -p tcp --tcp-flags ACK,PSH PSH -j STEALTH_SCAN | |
iptables -A INPUT -p tcp --tcp-flags ACK,URG URG -j STEALTH_SCAN | |
### Fragment Packet | |
iptables -A INPUT -f -j LOG --log-prefix 'fragment_packet:' | |
iptables -A INPUT -f -j DROP | |
### Ping of Death | |
iptables -N PING_OF_DEATH | |
iptables -A PING_OF_DEATH -p icmp --icmp-type echo-request \ | |
-m hashlimit \ | |
--hashlimit 1/s \ | |
--hashlimit-burst 10 \ | |
--hashlimit-htable-expire 300000 \ | |
--hashlimit-mode srcip \ | |
--hashlimit-name t_PING_OF_DEATH \ | |
-j RETURN | |
iptables -A PING_OF_DEATH -j LOG --log-prefix "ping_of_death_attack: " | |
iptables -A PING_OF_DEATH -j DROP | |
iptables -A INPUT -p icmp --icmp-type echo-request -j PING_OF_DEATH | |
### SYN Flood Attack | |
iptables -N SYN_FLOOD | |
iptables -A SYN_FLOOD -p tcp --syn \ | |
-m hashlimit \ | |
--hashlimit 200/s \ | |
--hashlimit-burst 3 \ | |
--hashlimit-htable-expire 300000 \ | |
--hashlimit-mode srcip \ | |
--hashlimit-name t_SYN_FLOOD \ | |
-j RETURN | |
iptables -A SYN_FLOOD -j LOG --log-prefix "syn_flood_attack: " | |
iptables -A SYN_FLOOD -j DROP | |
iptables -A INPUT -p tcp --syn -j SYN_FLOOD | |
### HTTP DoS/DDoS Attack | |
iptables -N HTTP_DOS | |
iptables -A HTTP_DOS -p tcp -m multiport --dports $HTTP \ | |
-m hashlimit \ | |
--hashlimit 10/s \ | |
--hashlimit-burst 100 \ | |
--hashlimit-htable-expire 300000 \ | |
--hashlimit-mode srcip \ | |
--hashlimit-name t_HTTP_DOS \ | |
-j RETURN | |
iptables -A HTTP_DOS -j LOG --log-prefix "http_dos_attack: " | |
iptables -A HTTP_DOS -j DROP | |
iptables -A INPUT -p tcp -m multiport --dports 80,443 -j HTTP_DOS | |
iptables -A INPUT -p icmp -j ACCEPT | |
iptables -A INPUT -p tcp -m multiport --dports 80,443 -j ACCEPT | |
iptables -A INPUT -p tcp -m multiport --dports 22 -j ACCEPT | |
iptables -A INPUT -j LOG --log-prefix "drop: " | |
iptables -A INPUT -j DROP | |
service iptables save | |
service iptables restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment