Ich hab mit diversen Anleitungen mir ein Iptables script gebastelt.
Es funktioniert auch doch wenn ich einige Zeit nichts mache krieg ich keine Verbindung mehr hin. Die Programme bringen dann die Fehlermeldung "Server nicht gefunden".
Wenn ich die Iptables selber lösche und per default alles erlaube gehts wieder.
Hier das Script:
echo "0" > /proc/sys/net/ipv4/ip_forward
echo "1" > /proc/sys/net/ipv4/ip_dynaddr
echo "1" > /proc/sys/net/ipv4/tcp_syncookies
echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
echo "1" > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
echo "1" > /proc/sys/net/ipv4/conf/ppp0/rp_filter
echo "0" > /proc/sys/net/ipv4/conf/ppp0/accept_redirects
echo "0" > /proc/sys/net/ipv4/conf/ppp0/accept_source_route
echo "0" > /proc/sys/net/ipv4/conf/ppp0/bootp_relay
# Default Policy: legt fest, das alles gedropt wird, was nicht expliziet zugelassen wird
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
#iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmt
#löschen aller bisherigen regeln
iptables -F
iptables -X
# alles, was über die Loopbackdevice geht, wird zugelassen.
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -N my_drop
iptables -A my_drop -p ICMP -j LOG --log-prefix " DROP-ICMP "
iptables -A my_drop -p UDP -j LOG --log-prefix " DROP-UDP "
iptables -A my_drop -p TCP -j LOG --log-prefix " DROP-TCP "
iptables -A my_drop -j DROP
#Alles, was zu einer bestehenden Verbindung gehört wird zugelassen
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#Alles was von aussen kommt und zu keiner bestehenden Verbindung gehört wird geblockt.
iptables -A INPUT -m state --state NEW,INVALID -j DROP
################## Regeln ##############################
iptables -A OUTPUT -p ICMP --icmp-type echo-request -j ACCEPT
iptables -A INPUT -p ICMP --icmp-type echo-reply -j ACCEPT
################## HTTP ################################
iptables -A OUTPUT -p TCP --sport 1024:65535 --dport 80 -m state --state NEW -j ACCEPT
################## HTTPS ###############################
iptables -A OUTPUT -p TCP --sport 1024:65535 --dport 443 -m state --state NEW -j ACCEPT
################## FTP #################################
iptables -A OUTPUT -p tcp --sport 1024:65535 --dport 21 -m state --state NEW -j ACCEPT
################## Rest verhindern #####################
iptables -A OUTPUT -p tcp --sport 1024:65535 --dport 110 -m state --state NEW -j ACCEPT
iptables -A INPUT -j my_drop
iptables -A FORWARD -j my_drop
iptables -A OUTPUT -j REJECT
Was stimmt mit dem nun nicht ?
Lesezeichen