bahamutxii
Goto Top

Secure Debian als ProxyFirewall (iptables)

Ich mache eine Ausbildung als Fachinformatiker. Dies soll mein Praktikumsprojekt werden. Komme aber irgendwie nicht weiter trotz diverser Howtos und Bücher.

Hallo,

da ich noch ein Anfänger bin habe ich noch Probleme beim debuggen. Wäre jemand so nett sich die Zeit zu nehmen mir dabei zu helfen?

Das Szenario sieht so aus das Hinter der Firewall/Proxy stehen zwei Windows Server 2008 R2 und mehrere Clients. Die Firewall funktioniert sozusagen als Gateway und soll in Verbindung mit Squid und Squidguard vor bösem Traffic schützen. Die Clients und Server sind noch nicht eingetragen (bringt auch erst was wenn das ganze grundsätzlich läuft).
Es sind zwei Netzwerkkarten die für den internen und den externen Traffic gedacht sind. Auf ipv6 bin ich nocht nicht eingegangen ist aber angedacht. Vielleicht hat auch hier jemand Tipps?

Manchmal habe ich Anmerkungen reingeschrieben die nicht auskommentiert sind. Das Habe ich hier getan im Originalen Script stehen sie garnicht drin oder sind selbstverständlich auskommmentiert.

Wenn das ganze fertig ist werde ich auch ein ausführlich Howto zur Verfügung stellen jedoch erst nachdem ich das Projekt abgegeben habe face-smile

Firewall:

Ich kann das ruleset zwar starten jedoch funktioniert dann der Internetzugriff überhaupt nicht mehr. Ausserdem sind noch Fehler drin.

Hier das ruleset für die iptables:

VARIABLEN

##Interfaces

Loopback="lo"
Internal="eth0"
External="eth1"
Internal_Net="192.168.1.0/24"

##Dienste/Server
DNS_Server=192.168.1.1:53

##Interne Ip Adresse
Int_IP='ifconfig $Internal | grep inet | grep -v inet6 | cut -d : -f 2 | cut -d ' ' -f 1

#Externe IP Adresse
Ext_IP='ifconfig $External | grep inet | grep -v inet6 | cut -d : -f 2 | cut -d ' ' -f 1

##Logging
Log_Level="notice" ##Standart Log Level kern.notice

##Lösche alle Regeln
iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD

##Lösche alle Regeln die bisher geladen wurden um eine saubere Regeldefinition
##zu ermöglichen / Flush
iptables -F

##Lösche alle Ketten die erstellt wurden falls vorhanden
iptables -F -t mangle
iptables -t mangle -X
iptables -X


##Setze Default Regeln / HIGHLY RECOMMEND
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP


Spezielle Ketten

##KEEP_STATE um eingehende, ausgehende und bestehende Verbindungen zu managen
iptables -N Keep_State
iptables -F Keep_State

##Verwerfe Pakete die eine "INVALID" Verbindung darstellen
iptables -A Keep_State -m state --state INVALID -j DROP

##Akzeptiere Pakete von einer bestehenden Verbindung
iptables -A Keep_State -m state --state RELATED,ESTABLISHED -j ACCEPT

iptables -N Check_Flags
iptables -F Check_Flags
#---------------------------------------------------------------------------
##Nmap/Portscanner mit den TCP-Flags URG,FIN,PSH
iptables -A Check_Flags -p tcp --tcp-flags ALL FIN,URG,PSH -m limit --limit 5/minute -j LOG --log-level $Log_Level --log-prefix "NMAP-XMAS:"
iptables -A Check_Flags -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
#---------------------------------------------------------------------------
##SYN/RST
iptables -A Check_Flags -p tcp --tcp-flags SYN,RST SYN,RST -m limit --limit 5/minute -j LOG --log-level $Log_Level --log-prefix "SYN,RST:"
iptables -A Check_Flags -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
#---------------------------------------------------------------------------
##SYN/FIN (gegen mögliche Portscanner)
iptables -A Check_Flags -p tcp --tcp-flags SYN,FIN SYN,FIN -m limit --limit 5/minute -j LOG --log-level $Log_Level --log-prefix "SYN,FIN:"
iptables -A Check_Flags -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
#---------------------------------------------------------------------------##gegen mögliche DoS Attacken. Diese Regelen verlangsamen Portscanner können
##aber zu unvorhergesehenen Problemen führen. Bei Problemen bitte Abschalten##!!!

iptables -A Check_Flags -m limit --limit 5/second -p tcp --tcp-flags ALL RST -j ACCEPT

iptables -A Check_Flags -m limit --limit 5/second -p tcp --tcp-flags ALL FIN -j ACCEPT

iptables -A Check_Flags -m limit --limit 5/second -p tcp --tcp-flags ALL SYN -j ACCEPT
#---------------------------------------------------------------------------

Spezielle Kette: Verbiete Ports Deny_ports
##Diese Kette unterbindet Drop/Log Pakete basierend auf Portnummern

iptables -N Deny_Ports
iptables -F Deny_Ports

#---------------------------------------------------------------------------
##Deklaration der Portnummern
Denied_Ports_TCP="0:65535"


Welche Service Ports von 0:1024 würdet ihr freigeben?


for PORT in $Denied_Ports_TCP;

do

iptables -A Deny_Ports -p tcp --dport $PORT -m limit --limit 5/minute -j LOG --log-level $Log_Level --log-prefix "Denied Port:"

iptables -A Deny_Ports -p tcp --sport $PORT -m limit --limit 5/minute -j LOG --log-level $Log_Level --log-prefix "Denied Port:"

iptables -A Deny_Ports -p tcp --dport $PORT -j DROP
iptables -A Deny_Ports -p tcp --sport $PORT -j DROP

done
#---------------------------------------------------------------------------
##Deklaration der Portnummern
Denied_Ports_UDP="1025:65535"


for PORT in $Denied_Ports_UDP;

do

iptables -A Deny_Ports -p udp --dport $PORT -m limit --limit 5/minute -j LOG --log-level $Log_Level --log-prefix "Denied Port:"

iptables -A Deny_Ports -p udp --sport $PORT -m limit --limit 5/minute -j LOG --log-level $Log_Level --log-prefix "Denied Port:"

iptables -A Deny_Ports -p udp --dport $PORT -j DROP
iptables -A Deny_Ports -p udp --sport $PORT -j DROP

done
#---------------------------------------------------------------------------
Spezielle Kette: erlaube Ports
##Regeln um Pakete portbasierend zu erlauben. Wird nur benötigt wenn Dienste
##laufen. Hier müssen also eventuelle Ports für z.b. einen Windows Server
##eingetragen werden. Da sonst nicht erreichbar.

iptables -N Allow_Ports
iptables -F Allow_Ports


TCP_Ports="22 53 80"

for PORT in $TCP_Ports;
do

iptables -A Allow_Ports -m state --state NEW -p tcp --dport $PORT -j ACCEPT

done
#---------------------------------------------------------------------------
## Erlaube ICMP (Ping)
##icmp: verbiete alle einkommenden pingversuche und erlaube alle ausgehenden

iptables -N Allow_ICMP
iptables -F Allow_ICMP

iptables -A Allow_ICMP -p icmp --icmp-type echo-reply -j ACCEPT
iptables -A Allow_ICMP -p icmp --icmp-type destination-unreachable -j ACCEPT
iptables -A Allow_ICMP -p icmp --icmp-type time-exceeded -j ACCEPT
iptables -A Allow_ICMP -p icmp --icmp-type echo-request -j ACCEPT

##Akzeptiere Pings mit einer Rate von 1 Ping/sekunde
iptables -A Allow_ICMP -p icmp --icmp-type echo-request -m limit --limit 1/second -j ACCEPT

##Logge alle Pings
iptables -A Allow_ICMP -p icmp --icmp-type echo-request -m limit --limit 5/minute -j LOG --log-level $Log_Level --log-prefix "Ping:"

##TTL Exceeded (traceroute)
iptables -A Allow_ICMP -p icmp --icmp-type time-exceeded -j ACCEPT

##Egress Filter


iptables -A PREROUTING -t nat -p tcp -i $Internal --dport 53 -j DNAT --to-destination $DNS_Server


iptables -A PREROUTING -t nat -p udp -i $Internal --dport 53 -j DNAT --to-destination $DNS_Server


iptables -A POSTROUTING -t nat -p tcp -o $External --dport 53 -j SNAT --to-source $DNS_Server


iptables -A POSTROUTING -t nat -p udp -o $External --dport 53 -j SNAT --to-source $DNS_Server

#---------------------------------------------------------------------------
Spezielle Kette Mangle_Output
##Mangle Werte von Paketen die lokal kreiert wurden.
##Nur TOS(Type of Service Bits) werden gemangelt
##(Mangle stellt die Manipulation der Pakete dar bevor sie durchs NAT laufen)


##TOS-Stuff: (type: iptables -m tos -h)
##Minimize-Delay 16(0x10)
##Maximize-Throughput 8(0x08)
##Maximizie-Reliability 4(0x04)
##Minimize-Cost 2(0x02)
##Normal-Service 0(0x00)

iptables -t mangle -N Mangle_Output
iptables -t mangle -F Mangle_Output


Anmerkung:
Hier fehlen wohl noch Werte für die offenen Ports......


iptables -t mangle -A Mangle_Output -p tcp --dport 20 -j TOS --set-tos 8
iptables -t mangle -A Mangle_Output -p tcp --dport 21 -j TOS --set-tos 16
iptables -t mangle -A Mangle_Output -p tcp --dport 22 -j TOS --set-tos 16
iptables -t mangle -A Mangle_Output -p tcp --dport 23 -j TOS --set-tos 16
iptables -t mangle -A Mangle_Output -p tcp --dport 25 -j TOS --set-tos 16
iptables -t mangle -A Mangle_Output -p tcp --dport 53 -j TOS --set-tos 16
iptables -t mangle -A Mangle_Output -p udp --dport 53 -j TOS --set-tos 16
iptables -t mangle -A Mangle_Output -p tcp --dport 80 -j TOS --set-tos 8
#---------------------------------------------------------------------------
##Spezielle Kette Mangle_Prerouting
##Mangle Werte von Paketen die lokal kreiert wurden.
##Nur TOS(Type of Service Bits) werden gemangelt


##TOS-Stuff: (type: iptables -m tos -h)
##Minimize-Delay 16(0x10)
##Maximize-Throughput 8(0x08)
##Maximizie-Reliability 4(0x04)
##Minimize-Cost 2(0x02)
##Normal-Service 0(0x00)

iptables -t mangle -N Mangle_Prerouting
iptables -t mangle -F Mangle_Prerouting

iptables -t mangle -A Mangle_Prerouting -p tcp --dport 20 -j TOS --set-tos 8
iptables -t mangle -A Mangle_Prerouting -p tcp --dport 21 -j TOS --set-tos 16
iptables -t mangle -A Mangle_Prerouting -p tcp --dport 22 -j TOS --set-tos 16
iptables -t mangle -A Mangle_Prerouting -p tcp --dport 23 -j TOS --set-tos 16
iptables -t mangle -A Mangle_Prerouting -p tcp --dport 25 -j TOS --set-tos 16
iptables -t mangle -A Mangle_Prerouting -p tcp --dport 53 -j TOS --set-tos 16
iptables -t mangle -A Mangle_Prerouting -p udp --dport 53 -j TOS --set-tos 16
iptables -t mangle -A Mangle_Prerouting -p tcp --dport 80 -j TOS --set-tos 8
#-################################################################################## Firewall Input Ketten

##Neue Input Ketten für externen Input

iptables -N External_Input
iptables -F External_Input

##Checke reinkommende Pakete auf verrückte TCP Flags
iptables -A External_Input -i $External -p tcp -j Check_Flags

##Filtere reinkommende Pakete basierend auf der Portnummer
iptables -A INPUT -i $Internal -p icmp -j Allow_ICMP

iptables -A External_Input -i $External ! -p icmp -j Deny_Ports
#---------------------------------------------------------------------------
##Neue Input Kette für das interne Interface

iptables -N Internal_Input
iptables -F Internal_Input

##Verwerfe jegliche Pakete die nicht aus dem internen Netzwerk kommen
iptables -A Internal_Input -i $Internal ! -s $Internal_Net -j DROP

##Prüfe von Extern reinkommende TCP Pakete nochmal am Internen Interface
iptables -A Internal_Input -i $Internal -p tcp -j Check_Flags

##Verwerfe/Logge Pakete basierend auf der Portnummer
iptables -A Internal_Input -i $Internal ! -p icmp -j Deny_Ports
#---------------------------------------------------------------------------##Neue Kette für den Input im Loopback Device

iptables -N Lo_Input
iptables -F Lo_Input

##Akzeptiere Pakete für das Loopback Device
iptables -A Lo_Input -i $Loopback -j ACCEPT
#---------------------------------------------------------------------------
Firewall Output Ketten

##Neue Kette zum Output vom Externen Interface

iptables -N External_Output
iptables -F External_Output

##Prüfe TCP Pakete die von Extern kommen auf verrückte TCP Header
iptables -A External_Output -o $External -j Check_Flags

##Filtere rausgehende Pakete am Externen Interface anhand der Portnummer
iptables -A External_Output -o $External ! -p icmp -j Deny_Ports

##Neue Kette für den Output am Externen Interface

iptables -N Internal_Output
iptables -F Internal_Output

##Verwerfe Pakete die nicht für das interne Netzwerk bestimmt sind
iptables -A Internal_Output -o $External ! -d $Internal_Net -j DROP

##Checke Interne TCP Pakete anhand der Portnummer
iptables -A Internal_Output -o $Internal ! -p icmp -j Deny_Ports

##Checke Interne Pakete die rausgehen auf verrückte TCP Flags
iptables -A Internal_Output -o $Internal -p tcp -j Check_Flags

##Neue Kette für den Output Traffic am Loopback Device

iptables -N Lo_Output
iptables -F Lo_Output

##Für jeglichen Traffic
iptables -A Lo_Output -o $Loopback -j ACCEPT
#---------------------------------------------------------------------------
Main Stuff

##Hier kommen wir zum Sprung von den selbst definierten Ketten zu den
##built-in Ketten

##Sprung zu den mangle Tabellen


iptables -t mangle -A OUTPUT -o $External -j Mangle_Output
iptables -t mangle -A PREROUTING -i $Internal -j Mangle_Output
###Logge und Verwerfe alle TCP Pakete die einen leeren Header besitzen
##möglicher Null_Scan

iptables -t mangle -A PREROUTING -p tcp --tcp-flags ALL NONE -m limit --limit 5/minute -j LOG --log-level $Log_Level --log-prefix "NULL SCAN:" --log-tcp-option --log-ip-option

iptables -t mangle -A PREROUTING -p tcp --tcp-flags ALL NONE -j DROP
#---------------------------------------------------------------------------##Sprung zum loopback Device

##Input fürs loopback Device
#Sprung zu unsere Lo_Input Kette

iptables -A INPUT -i $Loopback -j Lo_Input
#---------------------------------------------------------------------------##Input zu unserem internen Interface

##Verwerfe Pakete die nicht für die interne IPAdresse der Firewall bestimmt sind
iptables -A INPUT -i $Internal ! -d $Int_IP -j DROP

##Sprung zu unserer Internal_Input Kette
iptables -A INPUT -i $Internal -j Internal_Input

##Verwerfe/Akzeptiere Pakete je nach Status der Verbindung
iptables -A INPUT -i $Internal -j Keep_State

##Akzeptiere Pakete basierend auf der Portnummer
iptables -A INPUT -i $Internal -s $Internal_Net -d $Int_IP ! -p icmp -j Allow_Ports

###Input zum Externen Interface

##Springe zur External_Interface Kette
iptables -A INPUT -i $External -j External_Input

##Verwerfe/Akzeptiere Pakete basierend auf der Portnummer
iptables -A INPUT -i $External -j Keep_State

##Erlaube Pakete an bestimmte Ports (22, 53, 80)
iptables -A INPUT -i $External -j Allow_Ports

##Erlaube generell ICMP
iptables -A INPUT -i $External -p icmp -j Allow_ICMP

End Input Chains###############################
Springe zu unseren Output Ketten

##Output fürs Loopback Interface
iptables -A OUTPUT -o $Loopback -j Lo_Output

#---------------------------------------------------------------------------
##Springe zu unserem Internal_Output


##Spring zu unserer Internal_Output Kette
iptables -A OUTPUT -o $Int_IP -j $Internal_Output

##Verwerfe alles was nicht von der Firewall kommt
iptables -A OUTPUT -o $Internal ! -s $Int_IP

##Springe zur Keep_State Kette für einen generic stateful Packet Filter
iptables -A OUTPUT -o $Internal -j Keep_State

##Erlaube Pakete ins Interne Netz die von der Firewall kommen
iptables -A OUTPUT -o $Internal -s $Int_IP -d $Internal_Net -m state --state NEW -j ACCEPT

##Springe zum Allow_ICMP
iptables -A OUTPUT -o $Internal -j Allow_ICMP
#---------------------------------------------------------------------------
##Output am Externen Interface

##Springe zur Externen Output Kette
iptables -A OUTPUT -o $External -j External_Output

##Springe zur Keep_State Kette für einen generischen Paketfilter
iptables -A OUTPUT -o $External -j Keep_State

##Akzeptiere Pakete die nach draussen eine Verbindung aufbauen
iptables -A OUTPUT -o $External -m state --state NEW -j ACCEPT

##Akzeptiere Pings nach draussen
iptables -A OUTPUT -o $External -p icmp -j Allow_ICMP
Spring zu unseren Forward Ketten

##Springe zu unserem Internen/Externen Interface

iptables -A FORWARD -i $External -j External_Input
iptables -A FORWARD -i $External -j External_Output
iptables -A FORWARD -i $Internal -j Internal_Input
iptables -A FORWARD -i $Internal -j Internal_Output
Mehr Regeln um Sachen zu Verwerfen / DROP

##Verwerfe jeglichen Traffic von draussen der versucht eine Verbindung ins
##interne Netzwerk aufzubauen
iptables -A FORWARD -i $External -d $Internal_Net -m state --state NEW -j DROP

##Verwerfe jeglichen Traffic der von innen versucht eine Verbindung ins interne ##Netz aufzubauen
iptables -A FORWARD -o $Internal -d $Internal_Net -m state --state NEW -j DROP

##Verwerfe Echo Requests Pakete ins interne Netzwerk
iptables -A FORWARD -o $Internal -p icmp --icmp-type echo-request -j DROP
Egress Stuff

##Verwerfe jegliche Pakete die nicht für das interne Netzwerk bestimmt sind
iptables -A FORWARD -i $Internal ! -d $Internal_Net -j DROP

Akzeptiere einiges
iptables -A FORWARD -j Keep_State

##Akzeptiere Pakete die nach draussen eine Verbindung aufbauen
iptables -A FORWARD -o $External -m state --state NEW -j ACCEPT

##Springe zu Allow_ICMP
iptables -A FORWARD -p icmp -j ACCEPT
NAT

##Destination NAT

##ssh

iptables -t nat -A PREROUTING -i $External -p tcp -d $Ext_IP --dport 22 -j DNAT --to-destination $External:22

iptables -t nat -A PREROUTING -i $External -p tcp -d $Ext_IP --dport 80 -j DNAT --to-destination $External:80
#-------------------------------------------------------------------------------##Source NAT

##Dynamic IP Adress
iptables -t nat -A POSTROUTING -o $External -s $Internal_Net -j MASQUERADE
##Setze die Anzahl der möglichen Verbindungen die zu Überwachen sind höher

if

[ -e /proc/sys/net/ipv4/ip_conntrack_max ]; then
echo "4096" > /proc/sys/net/ipv4/ip_conntrack_max

fi

#-------------------------------------------------------------------------------
##Lege die lokale Portrange fest TCP/UDP

if

[ -e /proc/sys/net/ipv4/ip_local_portrange ]; then
echo -e "32768\t61000" > /proc/sys/net/ipv4/ip_local_portrange

fi
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
##verhindere das sich ein Paket mit gefälscter Absenderadresse einschleicht auch
##IP-Spoofing genannt
##verhindere source-routing damit ein Paket nicht vorgeben kann aus dem internen#Netz zu sein
echo "Disabling source routed packets..."
for i in /proc/sys/net/ipv4/conf/*/accept_source_route; do
echo "0" > $i
done
#-------------------------------------------------------------------------------
echo "Setting up spoofing protection..."
for i in /proc/sys/net/ipv4/conf/*/rp_filter; do
echo "1" > $i
done
#-------------------------------------------------------------------------------##ignoriere alle icmp echo requests(ping)
if [ -e /proc/sys/net/ipv4/conf/icmp_echo_ignore_broadcasts ]; then
echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
fi
#-------------------------------------------------------------------------------##ignoriere sämtlichen icmp traffic

if [ -e /proc/sys/net/ipv4/conf/icmp_echo_ignore_all ]; then
echo "0" > /proc/sys/net/ipv4/icmp_echo_ignore_all
fi
#-------------------------------------------------------------------------------##logge Pakete mit unmöglichen Adressen die an den kernel selbst adressiert sind
if [ -e /proc/sys/net/ipv4/conf/all/log_martians ]; then
echo "1" > /proc/sys/net/ipv4/conf/all/log_martians
fi
#-------------------------------------------------------------------------------#verweigere icmp redirects (könnten die kernel routing einstellungen verändern)

##verhindere redirect vom externen interface
if [ -e /proc/sys/net/ipv4/conf/$External/accept_redirects ]; then
echo "0" > /proc/sys/net/ipv4/conf/$External/accept_redirects

fi
#-------------------------------------------------------------------------------##Sage dem kernel das du ein dynamisches netzwerkinterface hast / IP
if [ -e /proc/sys/net/ipv4/ip_dynaddr ]; then
echo "1" > /proc/sys/net/ipv4/ip_dynaddr
fi
#-------------------------------------------------------------------------------##Aktiviere IP Forwarding
if [ -e /proc/sys/net/ipv4/ip_forward ]; then
echo "1" > /proc/sys/net/ipv4/ip_forward
else
echo "oh oh /proc/sys/net/ipv4/ip_forward existiert nicht"
fi

##EOF##


Mfg
Benjamin

Content-Key: 156059

Url: https://administrator.de/contentid/156059

Printed on: April 18, 2024 at 13:04 o'clock

Member: knut4linux
knut4linux Nov 30, 2010 at 21:49:07 (UTC)
Goto Top
Hallo Benjamin,

wenn du dieses Script durchfeuerst, dann schau doch mal nach, ob deine Regeln wirklich so greifen, wie du das willst:

Zum Überprüfen:

- iptables -L mal eingeben (listet die Regeln aller Chains)

- netstat -tulpen listet dir alle Ports auf die gelauscht wird

- route -n (Klassiker) prüfe ob deine Routen auch stimmen

- cat /var/log/syslog um zu sehen, ob deine Script überhaupt ohne Fehler sauber durchläuft


Mfg Knut
Member: BahamutXII
BahamutXII Nov 30, 2010 at 23:01:28 (UTC)
Goto Top
Ja das tun sie schon. Es ist eher zu viel. Ich leite die Ausgabe in eine Datei um kann ich ja morgen mal posten. Weis aber trotzdem nicht woran das liegt. Die Befehle oben kenn ich selbst face-smile Ich poste morgen mal das Fehlerlog bin aber atm nicht @work....
Member: BahamutXII
BahamutXII Dec 01, 2010 at 16:33:09 (UTC)
Goto Top

back-to-topLoopback=lo

back-to-topInternal=eth0

back-to-topExternal=eth1

back-to-topInternal_Net=192.168.1.0/24

back-to-topDNS_Server=192.168.1.2:53

back-to-topInt_IP='ifconfig $Internal | grep inet | grep -v inet6 | cut -d : -f 2 | cut -d '

back-to-top' -f 1



##Externe IP Adresse

back-to-topInt_IP='ifconfig $Internal | grep inet | grep -v inet6 | cut -d : -f 2 | cut -d '

back-to-top' -f 1



##Externe IP Adresse
Ext_IP=ifconfig' eth1
./ruleset.sh: line 16: -f 1

Ext_IP=ifconfig: command not found

back-to-topgrep inet

back-to-topgrep -v inet6

back-to-topcut -d : -f 2

back-to-topcut -d ' ' -f 1


<<--wieso klappt der cut bei der internen aber nicht bei der externen adresse das ist unlogisch



back-to-topiptables -A POSTROUTING -t nat -p tcp -o eth1 -m multiport --dport 20,21,22,25,53,80,443,546,547,1701,110,143,993,995,3389 -j REDIRECT --to-ports 3128

iptables: Invalid argument. Run `dmesg' for more information.

back-to-topiptables -A POSTROUTING -t nat -p udp -o eth1 -m multiport --dport 20,21,22,25,53,80,443,546,547,1701,110,143,993,995,3389 -j REDIRECT --to-ports 3128

iptables: Invalid argument. Run `dmesg' for more information.

<<--Was ist hier falsch??


back-to-topiptables -A INPUT -i eth0 '!' -d -j DROP

Bad argument `DROP'
Try `iptables -h' or 'iptables --help' for more information.

<<--Hier hab ich die Variable $Int_IP eingetragen aber er schluckt sie nicht warum?
iptables -A INPUT -i eth0 '!' -d $Int_IP -j DROP

back-to-topiptables -A INPUT -i eth0 -s 192.168.1.0/24 -d ' ' '!' -p icmp -j Allow_Ports

iptables v1.4.9.1: host/network ` ' not found
Try `iptables -h' or 'iptables --help' for more information.

<<--das hängt sicher mit dem cut zusammen aber wieso??



back-to-topiptables -A OUTPUT -o eth0 '!' -s

iptables v1.4.9.1: option `-s' requires an argument
Try `iptables -h' or 'iptables --help' for more information.

<<--Er schluckt hier die variable nicht eigentlich sieht das so aus:
iptables -A OUTPUT -o $Internal ! -s $Int_IP


back-to-topiptables -A OUTPUT -o eth0 -s -d 192.168.1.0/24 -m state --state NEW -j ACCEPT

Bad argument `192.168.1.0/24'
Try `iptables -h' or 'iptables --help' for more information.

<<--als destination hab ich hier die variable $Internal_Net eingetragen was stimmt nicht?


back-to-topiptables -A PREROUTING -t nat -p tcp -i eth1 -d --dport 22 -j DNAT --to-destination eth1

Bad argument `22'
Try `iptables -h' or 'iptables --help' for more information.

back-to-topiptables -A PREROUTING -t nat -p tcp -i eth1 -d --dport 80 -j DNAT --to-destination eth1

Bad argument `80'
Try `iptables -h' or 'iptables --help' for more information.

<<--er schluckt die ports nicht aber warum??


Welche Service ports (0:1024) würdet ihr immer offen lassen?
Was müsste ich noch verändern um ipv6 mit einzubeziehen?


* Das ist ein Fehlerlog bitte die Pluszeichen und Striche die nicht auskommentiert sind missachten


Über jede Hilfe bin ich sehr dankbar. Die meisten Fehler habe ich selber bereinigt aber das da oben bekomme ich nich hin face-confused

Mfg
Benjamin