Changes between Version 3 and Version 4 of jazz/10-03-26


Ignore:
Timestamp:
Mar 26, 2010, 11:59:41 PM (14 years ago)
Author:
jazz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • jazz/10-03-26

    v3 v4  
    2929net.ipv4.tcp_tw_recycle = 1 表示開啟TCP連接中TIME-WAIT sockets的快速回收,預設為0,表示關閉
    3030}}}
     31 * 彙整以上的規則,寫一隻 script 來當做開機時啟用安全防護的機制。
     32{{{
     33#!sh
     34echo "clear rules"
     35iptables -F
     36iptables -X
     37iptables -Z
     38iptables -t nat -F
     39echo "drop ping and traceroute"
     40iptables -A INPUT -i eth0 -p icmp -s any/0 --icmp-type 8 -j DROP
     41iptables -A OUTPUT -o eth0 -p icmp --icmp-type 3 -d any/0 -j DROP
     42iptables -A OUTPUT -o eth0 -p icmp --icmp-type 11 -d any/0 -j DROP
     43echo "drop abuse IP connections"
     44iptables -A INPUT -s 124.254.15.50 -j DROP
     45iptables -A INPUT -s 222.191.249.106 -j DROP
     46iptables -A INPUT -s 121.235.30.92 -j DROP
     47echo "drop connect more than 10 times in 10 seconds ..."
     48iptables -A INPUT -p tcp -m tcp --dport 80 -m state --state NEW -m recent --set --name DEFAULT --rsource
     49iptables -A INPUT -p tcp -m tcp --dport 80 -m state --state NEW -m recent --update --seconds 10 --hitcount 10 --name DEFAULT --rsource -j DROP
     50echo "decrease TCP socket TIME_WAIT time"
     51echo 10 > /proc/sys/net/ipv4/tcp_fin_timeout
     52sysctl net.ipv4.tcp_tw_reuse=1
     53sysctl net.ipv4.tcp_tw_recycle=1
     54}}}