All pastes #120573 Raw Edit

Mine

public text v1 · immutable
·published 2006-08-07 12:29 UTC
rendered paste body
#The Mangle portion of the ruleset. Here is where unwanted packet types get dropped. 
#This helps in making port scans against your server a bit more time consuming and difficult, but not impossible.
*mangle
:PREROUTING ACCEPT [444:43563]
:INPUT ACCEPT [444:43563]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [402:144198]
:POSTROUTING ACCEPT [402:144198]
-A PREROUTING -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,PSH,URG -j DROP
-A PREROUTING -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j DROP
-A PREROUTING -p tcp -m tcp --tcp-flags SYN,RST SYN,RST -j DROP
-A PREROUTING -p tcp -m tcp --tcp-flags FIN,SYN FIN,SYN -j DROP
COMMIT
#The FILTER section of the ruleset is where we initially drop all packets and then selectively open certain ports.
#We will also enable logging of all dropped requests.
*filter
:INPUT DROP [1:242]
:FORWARD DROP [0:0]
:OUTPUT DROP [0:0]
:LOG_DROP - [0:0]
:LOG_ACCEPT - [0:0]
:LOG_WEBMIN_ACCEPT - [0:0]
:icmp_packets - [0:0]
#First, we cover the INPUT rules, or the rules for incoming requests. 
#Note how at the end we log any incoming packets that are not accepted.
# test from spencer.apollosigns.com 
#-A INPUT -s 216.212.91.122 -j DROP
-A INPUT -s 12.108.203.0/24 -j DROP 
-A INPUT -s 12.21.94.0/24 -j DROP
-A INPUT -s 12.25.203.0/24 -j DROP 
-A INPUT -s 124.34.232.0/24 -j DROP
-A INPUT -s 125.240.110.0/24 -j DROP
-A INPUT -s 130.228.0.0/16 -j DROP
-A INPUT -s 130.244.30.0/24 -j DROP 
-A INPUT -s 130.94.134.0/24 -j DROP
-A INPUT -s 140.127.139.0/24 -j DROP 
-A INPUT -s 145.221.95.0/24 -j DROP
-A INPUT -s 146.214.100.0/24 -j DROP 
-A INPUT -s 148.233.178.0/24 -j DROP 
-A INPUT -s 163.178.64.0/24 -j DROP 
-A INPUT -s 163.20.52.0/24 -j DROP 
-A INPUT -s 163.20.85.0/24 -j DROP 
-A INPUT -s 193.151.65.0/24 -j DROP 
-A INPUT -s 193.188.73.0/24 -j DROP 
-A INPUT -s 193.188.77.0/24 -j DROP 
-A INPUT -s 193.194.64.0/24 -j DROP 
-A INPUT -s 193.226.202.0/24 -j DROP
-A INPUT -s 193.69.116.0/24 -j DROP 
-A INPUT -s 194.250.151.0/24 -j DROP 
-A INPUT -s 195.175.37.0/24 -j DROP
-A INPUT -s 196.1.96.0/24 -j DROP 
-A INPUT -s 196.36.12.0/24 -j DROP 
-A INPUT -s 196.40.43.0/24 -j DROP 
-A INPUT -s 196.40.76.0/24 -j DROP 
-A INPUT -s 196.45.37.0/24 -j DROP
-A INPUT -s 200.21.17.0/24 -j DROP
-A INPUT -s 200.225.194.0/24 -j DROP
-A INPUT -s 200.67.92.0/24 -j DROP
-A INPUT -s 200.65.127.0/24 -j DROP
-A INPUT -s 201.0.4.0/24 -j DROP
-A INPUT -s 201.12.178.0/24 -j DROP 
-A INPUT -s 201.124.17.0/24 -j DROP
-A INPUT -s 201.147.158.0/24 -j DROP
-A INPUT -s 201.34.39.0/24 -j DROP 
-A INPUT -s 201.42.96.0/24 -j DROP
-A INPUT -s 201.51.6.0/24 -j DROP
-A INPUT -s 202.159.212.0/24 -j DROP
-A INPUT -s 203.149.62.0/24 -j DROP
-A INPUT -s 203.154.224.0/24 -j DROP
-A INPUT -s 204.249.97.0/24 -j DROP 
-A INPUT -s 206.153.59.0/24 -j DROP 
-A INPUT -s 207.118.44.0/24 -j DROP
-A INPUT -s 207.44.132.0/24 -j DROP
-A INPUT -s 208.102.62.0/24 -j DROP 
-A INPUT -s 209.241.144.0/24 -j DROP
-A INPUT -s 210.0.200.0/24 -j DROP
-A INPUT -s 210.222.183.0/24 -j DROP
-A INPUT -s 212.122.76.0/24 -j DROP 
-A INPUT -s 212.138.113.0/24 -j DROP 
-A INPUT -s 212.138.47.0/24 -j DROP 
-A INPUT -s 212.138.47.0/24 -j DROP 
-A INPUT -s 212.165.130.0/24 -j DROP 
-A INPUT -s 212.248.245.0/24 -j DROP 
-A INPUT -s 212.49.85.0/24 -j DROP
-A INPUT -s 212.77.192.0/24 -j DROP
-A INPUT -s 213.140.15.0/24 -j DROP
-A INPUT -s 216.71.32.92 -j DROP
-A INPUT -s 217.109.194.0/24 -j DROP 
-A INPUT -s 217.174.16.0/24 -j DROP 
-A INPUT -s 217.219.128.0/24 -j DROP 
-A INPUT -s 217.219.192.0/24 -j DROP 
-A INPUT -s 217.28.147.0/24 -j DROP 
-A INPUT -s 217.76.144.0/24 -j DROP 
-A INPUT -s 217.91.66.0/24 -j DROP 
-A INPUT -s 217.98.20.0/24 -j DROP 
-A INPUT -s 218.1.65.0/24 -j DROP
-A INPUT -s 218.12.76.0/24 -j DROP 
-A INPUT -s 218.155.246.0/24 -j DROP 
-A INPUT -s 218.158.116.0/24 -j DROP 
-A INPUT -s 218.158.52.0/24 -j DROP 
-A INPUT -s 218.180.196.0/24 -j DROP 
-A INPUT -s 218.224.203.0/24 -j DROP 
-A INPUT -s 218.26.157.0/24 -j DROP 
-A INPUT -s 218.45.158.0/24 -j DROP 
-A INPUT -s 218.45.184.0/24 -j DROP 
-A INPUT -s 218.50.254.0/24 -j DROP 
-A INPUT -s 218.56.144.0/24 -j DROP 
-A INPUT -s 218.160.179.0/24 -j DROP
-A INPUT -s 219.51.112.0/24 -j DROP
-A INPUT -s 219.101.35.0/24 -j DROP 
-A INPUT -s 219.144.206.0/24 -j DROP 
-A INPUT -s 219.173.248.0/24 -j DROP 
-A INPUT -s 219.180.24.0/24 -j DROP 
-A INPUT -s 219.196.240.0/24 -j DROP 
-A INPUT -s 219.205.241.0/24 -j DROP 
-A INPUT -s 219.26.66.0/24 -j DROP 
-A INPUT -s 219.47.252.0/24 -j DROP 
-A INPUT -s 219.51.52.0/24 -j DROP 
-A INPUT -s 219.94.108.0/24 -j DROP 
-A INPUT -s 220.132.120.0/24 -j DROP
-A INPUT -s 221.149.214.0/24 -j DROP 
-A INPUT -s 221.160.41.0/24 -j DROP 
-A INPUT -s 221.169.51.0/24 -j DROP 
-A INPUT -s 221.20.132.0/24 -j DROP 
-A INPUT -s 221.35.27.0/24 -j DROP 
-A INPUT -s 221.45.48.0/24 -j DROP 
-A INPUT -s 222.104.237.0/24 -j DROP 
-A INPUT -s 222.110.155.0/24 -j DROP 
-A INPUT -s 222.113.143.0/24 -j DROP 
-A INPUT -s 222.117.220.0/24 -j DROP 
-A INPUT -s 222.118.201.0/24 -j DROP 
-A INPUT -s 24.62.161.0/24 -j DROP
-A INPUT -s 24.27.113.0/24 -j DROP
-A INPUT -s 24.8.34.0/24 -j DROP 
-A INPUT -s 24.8.72.0/24 -j DROP 
-A INPUT -s 43.244.129.0/24 -j DROP
-A INPUT -s 58.141.9.0/24 -j DROP
-A INPUT -s 63.243.161.128/25 -j DROP
-A INPUT -s 64.121.22.0/24 -j DROP 
-A INPUT -s 65.123.150.0/24 -j DROP 
-A INPUT -s 65.208.122.0/24 -j DROP 
-A INPUT -s 65.54.188.0/24 -j DROP
-A INPUT -s 65.98.72.0/24 -j DROP 
-A INPUT -s 66.144.76.0/24 -j DROP 
-A INPUT -s 66.207.120.0/24 -j DROP 
-A INPUT -s 66.211.236.0/24 -j DROP 
-A INPUT -s 66.213.76.0/24 -j DROP 
-A INPUT -s 66.248.133.0/24 -j DROP
-A INPUT -s 66.248.134.0/24 -j DROP
-A INPUT -s 66.30.76.0/24 -j DROP 
-A INPUT -s 66.8.50.0/24 -j DROP 
-A INPUT -s 66.98.180.0/24 -j DROP 
-A INPUT -s 67.183.16.0/24 -j DROP 
-A INPUT -s 67.86.189.0/24 -j DROP 
-A INPUT -s 68.105.103.0/24 -j DROP 
-A INPUT -s 68.106.29.0/24 -j DROP 
-A INPUT -s 68.20.101.0/24 -j DROP 
-A INPUT -s 68.38.213.0/24 -j DROP 
-A INPUT -s 69.118.11.0/24 -j DROP 
-A INPUT -s 69.118.131.0/24 -j DROP 
-A INPUT -s 69.142.43.0/24 -j DROP 
-A INPUT -s 69.150.187.0/24 -j DROP 
-A INPUT -s 69.154.247.0/24 -j DROP 
-A INPUT -s 69.86.201.0/24 -j DROP 
-A INPUT -s 70.108.241.0/24 -j DROP 
-A INPUT -s 70.117.21.0/24 -j DROP 
-A INPUT -s 70.151.42.0/24 -j DROP 
-A INPUT -s 70.85.85.0/24 -j DROP 
-A INPUT -s 70.88.188.0/24 -j DROP 
-A INPUT -s 71.160.165.0/24 -j DROP
-A INPUT -s 71.251.52.0/24 -j DROP
-A INPUT -s 72.192.22.0/24 -j DROP
-A INPUT -s 72.232.81.0/24 -j DROP
-A INPUT -s 80.142.149.0/24 -j DROP
-A INPUT -s 84.40.189.0/24 -j DROP 
-A INPUT -s 85.185.237.0/24 -j DROP 
-A INPUT -s 85.193.205.0/24 -j DROP 
-A INPUT -s 86.51.0.0/24 -j DROP
-A INPUT -s 86.51.0.0/24 -j DROP
-A INPUT -s 86.51.0.0/24 -j DROP
-A INPUT -s 88.153.199.0/24 -j DROP
-A INPUT -s 88.154.229.0/24 -j DROP
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A OUTPUT -o lo -j ACCEPT
-A INPUT -p tcp -m tcp --dport 20 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j LOG_ACCEPT
-A INPUT -p tcp -m tcp --dport 25 -j LOG_ACCEPT
-A INPUT -p tcp -m tcp --dport 43 -j ACCEPT
-A INPUT -p udp -m udp --dport 53 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 110 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 143 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
#uncomment the next line if you are running Spamassassin on your server
-A INPUT -p tcp -m tcp --dport 783 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 993 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
#-A INPUT -p tcp -m tcp --dport MYPORT --source MY_CLIENT_IP -j LOG_WEBMIN_ACCEPT
-A INPUT -s 127.0.0.1 -j ACCEPT
-A INPUT -p icmp -j icmp_packets
-A INPUT -j LOG_DROP
#Next, we cover the OUTPUT rules, or the rules for all outgoing traffic.
#Note how at the end we log any outbound packets that are not accepted.
-A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 20 -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 21 -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 23 -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 25 -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 43 -j ACCEPT
-A OUTPUT -p udp -m udp --dport 53 -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 110 -j ACCEPT 
-A OUTPUT -p tcp -m tcp --dport 113 -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 143 -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 443 -j ACCEPT
#uncomment the next line if you are running Spamassassin on your server
#-A OUTPUT -p tcp -m tcp --dport 783 -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 993 -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 3306 -j ACCEPT
-A OUTPUT -d 127.0.0.1 -j ACCEPT
-A OUTPUT -p icmp -j icmp_packets
-A OUTPUT -j LOG_DROP
#Here we have 2 sets of logging rules. One for dropped packets to log all dropped requests and one for accepted packets, should we wish to log any accepted requesets.
-A LOG_DROP -j LOG --log-prefix "[IPTABLES DROP] : " --log-tcp-options --log-ip-options
-A LOG_DROP -j DROP
-A LOG_ACCEPT -j LOG --log-prefix "[IPTABLES ACCEPT] : " --log-tcp-options --log-ip-options
-A LOG_ACCEPT -j ACCEPT
-A LOG_WEBMIN_ACCEPT -j LOG --log-prefix "[WEBMIN ACCEPT] : " --log-tcp-options --log-ip-options
-A LOG_WEBMIN_ACCEPT -j ACCEPT

#And finally, a rule to deal with ICMP requests. We drop all ping requests except from our own server.
# Make sure you replace 1.2.3.4 with the IP address of your server.
-A icmp_packets -p icmp -m icmp --icmp-type 0 -j ACCEPT
#-A icmp_packets -s 192.168.1.21 -p icmp -m icmp --icmp-type 8 -j ACCEPT
-A icmp_packets -p icmp -m icmp --icmp-type 8 -j DROP
-A icmp_packets -p icmp -m icmp --icmp-type 3 -j ACCEPT
-A icmp_packets -p icmp -m icmp --icmp-type 11 -j ACCEPT
COMMIT