Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # ---------------------------------------------------------------------
- # Linux-iptables-Firewallskript, Copyright (c) 2010 under the GPL
- # Autogenerated by iptables Generator v1.22 (c) 2002-2010 by Harald Bertram
- # Please visit http://harry.homelinux.org for new versions of
- # the iptables Generator (c).
- #
- # If you have questions about the iptables Generator or about
- # your Firewall-Skript feel free to take a look at out website or
- # send me an E-Mail to [email protected].
- #
- # My special thanks are going to Lutz Heinrich (trinitywork at hotmail dot com)
- # who made lots of Beta-Testing and gave me lots of well qualified
- # Feedback that made me able to improve the iptables Generator.
- # --------------------------------------------------------------------
- # Besondere Hinweise fuer Nutzer einer Debian-Distribution oder eines Debian-Derivates (Ubuntu, Knoppix, Kanotix, ...)!
- # Fuehren Sie die folgenden Kommandos aus, nachdem das Skript "firewall" nach /etc/init.d kopiert wurde:
- # chmod 755 /etc/init.d/firewall
- # update-rc.d firewall defaults
- # /etc/init.d/firewall start
- # --------------------------------------------------------------------
- case "$1" in
- start)
- echo "Starte IP-Paketfilter"
- # iptables-Modul
- modprobe ip_tables
- # Connection-Tracking-Module
- modprobe ip_conntrack
- # Das Modul ip_conntrack_irc ist erst bei Kerneln >= 2.4.19 verfuegbar
- modprobe ip_conntrack_irc
- modprobe ip_conntrack_ftp
- # Tabelle flushen
- iptables -F
- iptables -t nat -F
- iptables -t mangle -F
- iptables -X
- iptables -t nat -X
- iptables -t mangle -X
- # Default-Policies setzen
- iptables -P INPUT DROP
- iptables -P OUTPUT DROP
- iptables -P FORWARD DROP
- # MY_REJECT-Chain
- iptables -N MY_REJECT
- # MY_REJECT fuellen
- iptables -A MY_REJECT -p tcp -j REJECT --reject-with tcp-reset
- iptables -A MY_REJECT -p udp -j REJECT --reject-with icmp-port-unreachable
- iptables -A MY_REJECT -p icmp -j DROP
- iptables -A MY_REJECT -j REJECT --reject-with icmp-proto-unreachable
- # MY_DROP-Chain
- iptables -N MY_DROP
- iptables -A MY_DROP -j DROP
- # Reject packets from RFC1918 class networks (i.e., spoofed)
- iptables -A INPUT -s 10.0.0.0/8 -j DROP
- iptables -A INPUT -s 169.254.0.0/16 -j DROP
- iptables -A INPUT -s 172.16.0.0/12 -j DROP
- iptables -A INPUT -s 127.0.0.0/8 -j DROP
- iptables -A INPUT -s 224.0.0.0/4 -j DROP
- iptables -A INPUT -d 224.0.0.0/4 -j DROP
- iptables -A INPUT -s 240.0.0.0/5 -j DROP
- iptables -A INPUT -d 240.0.0.0/5 -j DROP
- iptables -A INPUT -s 0.0.0.0/8 -j DROP
- iptables -A INPUT -d 0.0.0.0/8 -j DROP
- iptables -A INPUT -d 239.255.255.0/24 -j DROP
- iptables -A INPUT -d 255.255.255.255 -j DROP
- # Korrupte Pakete zurueckweisen
- iptables -A INPUT -m state --state INVALID -j DROP
- iptables -A OUTPUT -m state --state INVALID -j DROP
- # Stealth Scans etc. DROPpen
- # Keine Flags gesetzt
- iptables -A INPUT -p tcp --tcp-flags ALL NONE -j MY_DROP
- # SYN und FIN gesetzt
- iptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j MY_DROP
- # SYN und RST gleichzeitig gesetzt
- iptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j MY_DROP
- # FIN und RST gleichzeitig gesetzt
- iptables -A INPUT -p tcp --tcp-flags FIN,RST FIN,RST -j MY_DROP
- # FIN ohne ACK
- iptables -A INPUT -p tcp --tcp-flags ACK,FIN FIN -j MY_DROP
- # PSH ohne ACK
- iptables -A INPUT -p tcp --tcp-flags ACK,PSH PSH -j MY_DROP
- # URG ohne ACK
- iptables -A INPUT -p tcp --tcp-flags ACK,URG URG -j MY_DROP
- # Loopback-Netzwerk-Kommunikation zulassen
- iptables -A INPUT -i lo -j ACCEPT
- iptables -A OUTPUT -o lo -j ACCEPT
- # Connection-Tracking aktivieren
- iptables -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
- iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
- # DNS
- iptables -A INPUT -i eth0 -m state --state NEW -p tcp --dport 53 -j ACCEPT
- iptables -A INPUT -i eth0 -m state --state NEW -p udp --dport 53 -j ACCEPT
- # FTP
- iptables -A INPUT -i eth0 -m state --state NEW -p tcp --dport 21 -j ACCEPT
- # SSH
- iptables -A INPUT -i eth0 -m state --state NEW -p tcp --dport 22 -j ACCEPT
- # SMTP
- iptables -A OUTPUT -o eth0 -m state --state NEW -p tcp --dport 25 -j ACCEPT
- # Webmin
- iptables -A INPUT -i eth0 -m tcp -p tcp --dport 10000 -j ACCEPT
- # Call of Duty Reihe
- iptables -A INPUT -i eth0 -p udp --dport 28984 -j ACCEPT
- iptables -A INPUT -i eth0 -p udp --dport 28983 -j ACCEPT
- iptables -A INPUT -i eth0 -p udp --dport 28982 -j ACCEPT
- iptables -A INPUT -i eth0 -p udp --dport 28981 -j ACCEPT
- iptables -A INPUT -i eth0 -p udp --dport 28980 -j ACCEPT
- iptables -A INPUT -i eth0 -p udp --dport 28967 -j ACCEPT
- iptables -A INPUT -i eth0 -p udp --dport 28966 -j ACCEPT
- iptables -A INPUT -i eth0 -p udp --dport 28964 -j ACCEPT
- iptables -A INPUT -i eth0 -p udp --dport 28963 -j ACCEPT
- iptables -A INPUT -i eth0 -p udp --dport 28962 -j ACCEPT
- iptables -A INPUT -i eth0 -p udp --dport 28961 -j ACCEPT
- iptables -A INPUT -i eth0 -p udp --dport 28960 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --sport 28984 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --sport 28983 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --sport 28982 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --sport 28981 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --sport 28980 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --sport 28967 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --sport 28966 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --sport 28964 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --sport 28963 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --sport 28962 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --sport 28961 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --sport 28960 -j ACCEPT
- # CS:S
- iptables -A INPUT -i eth0 -p tcp --dport 27015 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p tcp --sport 27015 -j ACCEPT
- iptables -A INPUT -i eth0 -p udp --dport 27015 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --sport 27015 -j ACCEPT
- # Enemy Teritorry
- iptables -A INPUT -i eth0 -p udp --dport 27961 -j ACCEPT
- iptables -A INPUT -i eth0 -p udp --dport 27960 -j ACCEPT
- iptables -A INPUT -i eth0 -p udp --dport 27900 -j ACCEPT
- iptables -A INPUT -i eth0 -p udp --dport 30001 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --sport 27961 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --sport 27960 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --sport 27900 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --sport 30001 -j ACCEPT
- # Teamspeak3
- iptables -A INPUT -i eth0 -p udp --dport 1337 -j ACCEPT
- iptables -A INPUT -i eth0 -p udp --dport 1338 -j ACCEPT
- iptables -A INPUT -i eth0 -p udp --dport 9987 -j ACCEPT
- iptables -A INPUT -i eth0 -p udp --dport 9988 -j ACCEPT
- iptables -A INPUT -i eth0 -p udp --dport 9999 -j ACCEPT
- iptables -A INPUT -i eth0 -p udp --dport 9986 -j ACCEPT
- iptables -A INPUT -i eth0 -p tcp --dport 30033 -j ACCEPT
- iptables -A INPUT -i eth0 -p tcp --dport 10011 -j ACCEPT
- iptables -A INPUT -i eth0 -p tcp --dport 2008 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --dport 1337 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --dport 1338 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --dport 9987 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --dport 9988 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --dport 9999 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p udp --dport 9986 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p tcp --dport 30033 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p tcp --dport 10011 -j ACCEPT
- iptables -A OUTPUT -o eth0 -p tcp --dport 2008 -j ACCEPT
- #COD4 & ET getstatus DDoS fix
- #New Chain for each Server so Rcon tools like HLSW work
- #for ET pub server
- iptables -N Q3_27960
- iptables -A Q3_27960 -m string ! --hex-string "|FF FF FF FF|" --algo bm --from 27 --to 30 -j RETURN
- iptables -A Q3_27960 -m string --algo bm --string "getstatus" -m recent --set --name getstatus_27960
- iptables -A Q3_27960 -m recent --update --seconds 2 --hitcount 4 --name getstatus_27960 -j DROP
- iptables -A Q3_27960 -j RETURN
- iptables -I INPUT 2 -p udp --dport 27960 -j Q3_27960
- #for COD2 pub server
- iptables -N Q3_28967
- iptables -A Q3_28967 -m string ! --hex-string "|FF FF FF FF|" --algo bm --from 27 --to 30 -j RETURN
- iptables -A Q3_28967 -m string --algo bm --string "getstatus" -m recent --set --name getstatus_28967
- iptables -A Q3_28967 -m recent --update --seconds 2 --hitcount 4 --name getstatus_28967 -j DROP
- iptables -A Q3_28967 -j RETURN
- iptables -I INPUT 2 -p udp --dport 28967 -j Q3_28967
- #for ET facade
- iptables -N Q3_27900
- iptables -A Q3_27900 -m string ! --hex-string "|FF FF FF FF|" --algo bm --from 27 --to 30 -j RETURN
- iptables -A Q3_27900 -m string --algo bm --string "getstatus" -m recent --set --name getstatus_27900
- iptables -A Q3_27900 -m recent --update --seconds 2 --hitcount 4 --name getstatus_27900 -j DROP
- iptables -A Q3_27900 -j RETURN
- iptables -I INPUT 2 -p udp --dport 27900 -j Q3_27900
- #for ET facade 2
- iptables -N Q3_30001
- iptables -A Q3_30001 -m string ! --hex-string "|FF FF FF FF|" --algo bm --from 27 --to 30 -j RETURN
- iptables -A Q3_30001 -m string --algo bm --string "getstatus" -m recent --set --name getstatus_30001
- iptables -A Q3_30001 -m recent --update --seconds 2 --hitcount 4 --name getstatus_30001 -j DROP
- iptables -A Q3_30001 -j RETURN
- iptables -I INPUT 2 -p udp --dport 30001 -j Q3_30001
- #for sniper server
- iptables -N Q3_28960
- iptables -A Q3_28960 -m string ! --hex-string "|FF FF FF FF|" --algo bm --from 27 --to 30 -j RETURN
- iptables -A Q3_28960 -m string --algo bm --string "getstatus" -m recent --set --name getstatus_28960
- iptables -A Q3_28960 -m recent --update --seconds 2 --hitcount 4 --name getstatus_28960 -j DROP
- iptables -A Q3_28960 -j RETURN
- iptables -I INPUT 2 -p udp --dport 28960 -j Q3_28960
- #for tdm server
- iptables -N Q3_28963
- iptables -A Q3_28963 -m string ! --hex-string "|FF FF FF FF|" --algo bm --from 27 --to 30 -j RETURN
- iptables -A Q3_28963 -m string --algo bm --string "getstatus" -m recent --set --name getstatus_28963
- iptables -A Q3_28963 -m recent --update --seconds 2 --hitcount 4 --name getstatus_28963 -j DROP
- iptables -A Q3_28963 -j RETURN
- iptables -I INPUT 2 -p udp --dport 28963 -j Q3_28963
- #for sd server
- iptables -N Q3_28964
- iptables -A Q3_28964 -m string ! --hex-string "|FF FF FF FF|" --algo bm --from 27 --to 30 -j RETURN
- iptables -A Q3_28964 -m string --algo bm --string "getstatus" -m recent --set --name getstatus_28964
- iptables -A Q3_28964 -m recent --update --seconds 2 --hitcount 4 --name getstatus_28964 -j DROP
- iptables -A Q3_28964 -j RETURN
- iptables -I INPUT 2 -p udp --dport 28964 -j Q3_28964
- #for ET warserver
- iptables -N Q3_27961
- iptables -A Q3_27961 -m string ! --hex-string "|FF FF FF FF|" --algo bm --from 27 --to 30 -j RETURN
- iptables -A Q3_27961 -m string --algo bm --string "getstatus" -m recent --set --name getstatus_27961
- iptables -A Q3_27961 -m recent --update --seconds 2 --hitcount 4 --name getstatus_27961 -j DROP
- iptables -A Q3_27961 -j RETURN
- iptables -I INPUT 2 -p udp --dport 27961 -j Q3_27961
- #for cb server
- iptables -N Q3_28962
- iptables -A Q3_28962 -m string ! --hex-string "|FF FF FF FF|" --algo bm --from 27 --to 30 -j RETURN
- iptables -A Q3_28962 -m string --algo bm --string "getstatus" -m recent --set --name getstatus_28962
- iptables -A Q3_28962 -m recent --update --seconds 2 --hitcount 4 --name getstatus_28962 -j DROP
- iptables -A Q3_28962 -j RETURN
- iptables -I INPUT 2 -p udp --dport 28962 -j Q3_28962
- #for cg server
- iptables -N Q3_28961
- iptables -A Q3_28961 -m string ! --hex-string "|FF FF FF FF|" --algo bm --from 27 --to 30 -j RETURN
- iptables -A Q3_28961 -m string --algo bm --string "getstatus" -m recent --set --name getstatus_28961
- iptables -A Q3_28961 -m recent --update --seconds 2 --hitcount 4 --name getstatus_28961 -j DROP
- iptables -A Q3_28961 -j RETURN
- iptables -I INPUT 2 -p udp --dport 28961 -j Q3_28961
- #for war1 server
- iptables -N Q3_28980
- iptables -A Q3_28980 -m string ! --hex-string "|FF FF FF FF|" --algo bm --from 27 --to 30 -j RETURN
- iptables -A Q3_28980 -m string --algo bm --string "getstatus" -m recent --set --name getstatus_28980
- iptables -A Q3_28980 -m recent --update --seconds 2 --hitcount 4 --name getstatus_28980 -j DROP
- iptables -A Q3_28980 -j RETURN
- iptables -I INPUT 2 -p udp --dport 28980 -j Q3_28980
- #for war2 server
- iptables -N Q3_28981
- iptables -A Q3_28981 -m string ! --hex-string "|FF FF FF FF|" --algo bm --from 27 --to 30 -j RETURN
- iptables -A Q3_28981 -m string --algo bm --string "getstatus" -m recent --set --name getstatus_28981
- iptables -A Q3_28981 -m recent --update --seconds 2 --hitcount 4 --name getstatus_28981 -j DROP
- iptables -A Q3_28981 -j RETURN
- iptables -I INPUT 2 -p udp --dport 28981 -j Q3_28981
- #for gungame server
- iptables -N Q3_28982
- iptables -A Q3_28982 -m string ! --hex-string "|FF FF FF FF|" --algo bm --from 27 --to 30 -j RETURN
- iptables -A Q3_28982 -m string --algo bm --string "getstatus" -m recent --set --name getstatus_28982
- iptables -A Q3_28982 -m recent --update --seconds 2 --hitcount 4 --name getstatus_28982 -j DROP
- iptables -A Q3_28982 -j RETURN
- iptables -I INPUT 2 -p udp --dport 28982 -j Q3_28982
- #for cupprize server
- iptables -N Q3_28983
- iptables -A Q3_28983 -m string ! --hex-string "|FF FF FF FF|" --algo bm --from 27 --to 30 -j RETURN
- iptables -A Q3_28983 -m string --algo bm --string "getstatus" -m recent --set --name getstatus_28983
- iptables -A Q3_28983 -m recent --update --seconds 2 --hitcount 4 --name getstatus_28983 -j DROP
- iptables -A Q3_28983 -j RETURN
- iptables -I INPUT 2 -p udp --dport 28983 -j Q3_28983
- #for reddit server
- iptables -N Q3_28984
- iptables -A Q3_28984 -m string ! --hex-string "|FF FF FF FF|" --algo bm --from 27 --to 30 -j RETURN
- iptables -A Q3_28984 -m string --algo bm --string "getstatus" -m recent --set --name getstatus_28984
- iptables -A Q3_28984 -m recent --update --seconds 2 --hitcount 4 --name getstatus_28983 -j DROP
- iptables -A Q3_28984 -j RETURN
- iptables -I INPUT 2 -p udp --dport 28984 -j Q3_28984
- # Webserver
- iptables -A INPUT -p tcp --dport 80 -j ACCEPT
- # Default-Policies mit REJECT
- iptables -A INPUT -j MY_REJECT
- iptables -A OUTPUT -j MY_REJECT
- # Max. 500/Sekunde (5/Jiffie) senden
- echo 5 > /proc/sys/net/ipv4/icmp_ratelimit
- # Speicherallozierung und -timing for-De/-Fragmentierung
- echo 262144 > /proc/sys/net/ipv4/ipfrag_high_thresh
- echo 196608 > /proc/sys/net/ipv4/ipfrag_low_thresh
- echo 30 > /proc/sys/net/ipv4/ipfrag_time
- # TCP-FIN-Timeout zum Schutz vor DoS-Attacken setzen
- echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout
- # Maximal 3 Antworten auf ein TCP-SYN
- echo 3 > /proc/sys/net/ipv4/tcp_retries1
- # TCP-Pakete maximal 15x wiederholen
- echo 15 > /proc/sys/net/ipv4/tcp_retries2
- ;;
- stop)
- echo "Stoppe IP-Paketfilter"
- # Tabelle flushen
- iptables -F
- iptables -t nat -F
- iptables -t mangle -F
- iptables -X
- iptables -t nat -X
- iptables -t mangle -X
- # Default-Policies setzen
- iptables -P INPUT ACCEPT
- iptables -P OUTPUT ACCEPT
- iptables -P FORWARD ACCEPT
- ;;
- status)
- echo "Tabelle filter"
- iptables -L -vn
- echo "Tabelle nat"
- iptables -t nat -L -vn
- echo "Tabelle mangle"
- iptables -t mangle -L -vn
- ;;
- *)
- echo "Fehlerhafter Aufruf"
- echo "Syntax: $0 {start|stop|status}"
- exit 1
- ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment