iptables, udp und die ports

saiki

saiki

Bratwurstgriller
Ich habe ein kleines Problem. Und zwar würde ich gerne SC hinter meinem Router hosten. Soweit so gut, hab ich mir gedacht, machste in dem Script (s.u.) einfach ein Copy&Paster von der edonky zeile und änderst die ports und ips entsprechend. Leider funktioniert es nicht.
TCP scheint zu funktioneren (das Log sagt zumindest nichts :)), UDP leider nicht.
Wie kriege ich das Script (iptables) dazu, das es Port 6112 als TCP und UDP auf die x.x.x.10 leitet?

Code:
#!/bin/bash
# ---------------------------------------------------------------------
# Linux-iptables-Firewallskript, Copyright (c) 2004 under the GPL
# Autogenerated by iptables Generator v1.16 (c) 2002 by Harald Bertram*
# Please visit [url]http://www.harry.homelinux.org[/url] for new versions of
# the iptables Generator (c).
# 
# This Script was generated by request from:
# [email]saiki@gmx.info[/email] on: 2004-1-30 16:39.51 MET.
# 
# 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]webmaster@harry.homelinux.org[/email].
# 
# My special thanks are going to Lutz Heinrich (trinitywork@hotmail.com) who
# made lots of Beta-Testing and gave me lots of well qualified
# Feedback that made me able to improve the iptables Generator.
# --------------------------------------------------------------------

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 -m limit --limit 7200/h -j LOG --log-prefix "REJECT TCP "
    iptables -A MY_REJECT -p tcp -j REJECT --reject-with tcp-reset
    iptables -A MY_REJECT -p udp -m limit --limit 7200/h -j LOG --log-prefix "REJECT UDP "
    iptables -A MY_REJECT -p udp -j REJECT --reject-with icmp-port-unreachable
    iptables -A MY_REJECT -p icmp -m limit --limit 7200/h -j LOG --log-prefix "DROP ICMP "
    iptables -A MY_REJECT -p icmp -j DROP
    iptables -A MY_REJECT -m limit --limit 7200/h -j LOG --log-prefix "REJECT OTHER "
    iptables -A MY_REJECT -j REJECT --reject-with icmp-proto-unreachable

    # MY_DROP-Chain
    iptables -N MY_DROP
    iptables -A MY_DROP -m limit --limit 7200/h -j LOG --log-prefix "PORTSCAN DROP "
    iptables -A MY_DROP -j DROP

    # Alle verworfenen Pakete protokollieren
    iptables -A INPUT -m state --state INVALID -m limit --limit 7200/h -j LOG --log-prefix "INPUT INVALID "
    iptables -A OUTPUT -m state --state INVALID -m limit --limit 7200/h -j LOG --log-prefix "OUTPUT INVALID "
    iptables -A FORWARD -m state --state INVALID -m limit --limit 7200/h -j LOG --log-prefix "FORWARD INVALID "

    # Korrupte Pakete zurueckweisen
    iptables -A INPUT -m state --state INVALID -j DROP
    iptables -A OUTPUT -m state --state INVALID -j DROP
    iptables -A FORWARD -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
    iptables -A FORWARD -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
    iptables -A FORWARD -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
    iptables -A FORWARD -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
    iptables -A FORWARD -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
    iptables -A FORWARD -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
    iptables -A FORWARD -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
    iptables -A FORWARD -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

    # Maximum Segment Size (MSS) für das Forwarding an PMTU anpassen
    iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu

    # Connection-Tracking aktivieren
    iptables -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
    iptables -A FORWARD -i ! ippp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
    iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
    iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

    # SSH
    iptables -A INPUT -i eth0 -m state --state NEW -p tcp --dport 22 -j ACCEPT
    
    # IP-Adresse des LAN-Interfaces ermitteln
    LAN_IP=$(ifconfig eth0 | head -n 2 | tail -n 1 | cut -d: -f2 | cut -d" " -f 1)

    # NAT fuer EDONKEY
    iptables -t nat -A PREROUTING -i ippp0 -p tcp --dport 4661 -j DNAT --to-destination 192.168.6.2
    iptables -t nat -A POSTROUTING -o eth0 -p tcp --dport 4661 -j SNAT --to-source $LAN_IP
    iptables -A FORWARD -i ippp0 -m state --state NEW -p tcp -d 192.168.6.2 --dport 4661 -j ACCEPT
    iptables -t nat -A PREROUTING -i ippp0 -p tcp --dport 4662 -j DNAT --to-destination 192.168.6.2
    iptables -t nat -A POSTROUTING -o eth0 -p tcp --dport 4662 -j SNAT --to-source $LAN_IP
    iptables -A FORWARD -i ippp0 -m state --state NEW -p tcp -d 192.168.6.2 --dport 4662 -j ACCEPT
    iptables -t nat -A PREROUTING -i ippp0 -p tcp --dport 4663 -j DNAT --to-destination 192.168.6.2
    iptables -t nat -A POSTROUTING -o eth0 -p tcp --dport 4663 -j SNAT --to-source $LAN_IP
    iptables -A FORWARD -i ippp0 -m state --state NEW -p tcp -d 192.168.6.2 --dport 4663 -j ACCEPT
    iptables -t nat -A PREROUTING -i ippp0 -p udp --dport 4665 -j DNAT --to-destination 192.168.6.2
    iptables -t nat -A POSTROUTING -o eth0 -p udp --dport 4665 -j SNAT --to-source $LAN_IP
    iptables -A FORWARD -i ippp0 -m state --state NEW -p udp -d 192.168.6.2 --dport 4665 -j ACCEPT
    
    

#StarCraft TCP/UDP Ports
     iptables -t nat -A PREROUTING -i ippp0 -p tcp --dport 6112 -j DNAT --to-destination 192.168.6.10
     iptables -t nat -A POSTROUTING -o eth0 -p tcp --dport 6112 -j SNAT --to-source $LAN_IP
     iptables -A FORWARD -i ippp0 -m state --state NEW -p tcp -d 192.168.6.10 --dport 6112 -j ACCEPT
     
     iptables -t nat -A PREROUTING -i ippp0 -p udp --dport 6112 -j DNAT --to-destination 192.168.6.10
     iptables -t nat -A POSTROUTING -o eth0 -p udp --dport 6112 -j SNAT --to-source $LAN_IP
     iptables -A FORWARD -i ippp0 -m state --state NEW -p udp -d 192.168.6.10 --dport 6112 -j ACCEPT
	       
	     
	 
     



							    	    
    # NAT fuer RA3 1.7 tcp
    # iptables -t nat -A PREROUTING -i ippp0 -p tcp --dport 27960 -j DNAT --to-destination 192.168.6.2
    # iptables -t nat -A POSTROUTING -o eth0 -p tcp --dport 27960 -j SNAT --to-source $LAN_IP
    # iptables -A FORWARD -i ippp0 -m state --state NEW -p tcp -d 192.168.6.2 --dport 27960 -j ACCEPT
    # NAT fuer RA3 1.7 udp
    # iptables -t nat -A PREROUTING -i ippp0 -p udp --dport 27960 -j DNAT --to-destination 192.168.6.2
    # iptables -t nat -A POSTROUTING -o eth0 -p udp --dport 27960 -j SNAT --to-source $LAN_IP
    # iptables -A FORWARD -i ippp0 -m state --state NEW -p udp -d 192.168.6.2 --dport 27960 -j ACCEPT
	    
    
    # LAN-Zugriff auf eth0
    iptables -A INPUT -m state --state NEW -i eth0 -j ACCEPT

    # Default-Policies mit REJECT
    iptables -A INPUT -j MY_REJECT
    iptables -A OUTPUT -j MY_REJECT
    iptables -A FORWARD -j MY_REJECT

    # Routing
    echo 1 > /proc/sys/net/ipv4/ip_forward 2> /dev/null

    # Masquerading
    iptables -t nat -A POSTROUTING -o ippp0 -j MASQUERADE

    # SYN-Cookies
    echo 1 > /proc/sys/net/ipv4/tcp_syncookies 2> /dev/null

    # Stop Source-Routing
    for i in /proc/sys/net/ipv4/conf/*; do echo 0 > $i/accept_source_route 2> /dev/null; done

    # Stop Redirecting
    for i in /proc/sys/net/ipv4/conf/*; do echo 0 > $i/accept_redirects 2> /dev/null; done

    # Reverse-Path-Filter
    for i in /proc/sys/net/ipv4/conf/*; do echo 2 > $i/rp_filter 2> /dev/null; done

    # Log Martians
    for i in /proc/sys/net/ipv4/conf/*; do echo 1 > $i/log_martians 2> /dev/null; done

    # BOOTP-Relaying ausschalten
    for i in /proc/sys/net/ipv4/conf/*; do echo 0 > $i/bootp_relay 2> /dev/null; done

    # Proxy-ARP ausschalten
    for i in /proc/sys/net/ipv4/conf/*; do echo 0 > $i/proxy_arp 2> /dev/null; done

    # Ungültige ICMP-Antworten ignorieren
    echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses 2> /dev/null

    # ICMP Echo-Broadcasts ignorieren
    echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts 2> /dev/null

    # Max. 500/Sekunde (5/Jiffie) senden
    echo 5 > /proc/sys/net/ipv4/icmp_ratelimit

    # Speicherallozierung und -timing für IP-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
    echo "Deaktiviere IP-Routing"
    echo 0 > /proc/sys/net/ipv4/ip_forward

    # 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


So schauts im Log aus (und zwar ganz oft :D):
Apr 6 22:52:46 knecht kernel: REJECT UDP IN=ippp0 OUT= MAC= SRC=213.51.37.195 DST=217.3.35.228 LEN=36 TOS=0x00 PREC=0x00 TTL=120 ID=33228 PROTO=UDP SPT=6112 DPT=1024 LEN=16
 
hi saiki

saiki schrieb:
Code:
#StarCraft TCP/UDP Ports
     iptables -t nat -A PREROUTING -i ippp0 -p tcp --dport 6112 -j DNAT --to-destination 192.168.6.10
     iptables -t nat -A POSTROUTING -o eth0 -p tcp --dport 6112 -j SNAT --to-source $LAN_IP
     iptables -A FORWARD -i ippp0 -m state --state NEW -p tcp -d 192.168.6.10 --dport 6112 -j ACCEPT
     
     iptables -t nat -A PREROUTING -i ippp0 -p udp --dport 6112 -j DNAT --to-destination 192.168.6.10
     iptables -t nat -A POSTROUTING -o eth0 -p udp --[b]dport[/b] 6112 -j SNAT --to-source $LAN_IP
     iptables -A FORWARD -i ippp0 -m state --state NEW -p udp -d 192.168.6.10 --dport 6112 -j ACCEPT


So schauts im Log aus (und zwar ganz oft :D):
Apr 6 22:52:46 knecht kernel: REJECT UDP IN=ippp0 OUT= MAC= SRC=213.51.37.195 DST=217.3.35.228 LEN=36 TOS=0x00 PREC=0x00 TTL=120 ID=33228 PROTO=UDP SPT=6112 DPT=1024 LEN=16

ich kenne mich mit dem spiel jetzt nicht aus und weiß nicht welche ports dort benötigt werden.
aber du hast den destinationport 6112 *freigeben*. die pakete die bei dir gedropt werden, haben aber einen destination port 1024. sie kommen zwar vom source port 6112, das ist aber noch ein unterschied.


Gruß HL
 
ich kenne mich mit dem spiel jetzt nicht aus und weiß nicht welche ports dort benötigt werden.
aber du hast den destinationport 6112 *freigeben*. die pakete die bei dir gedropt werden, haben aber einen destination port 1024. sie kommen zwar vom source port 6112, das ist aber noch ein unterschied.
Eigentlich sollte das Spiel nur auf 6112-6119 kommunizieren und das rein und raus und nix mit 1024. Wo kann man das umstellen. Irgendwie sehe ich nun garnich mehr durch *G*
 
hi saiki

da muss ich leider passen, da ich, wie gesagt, nicht weiß welche ports von dem spiel verwendet werden.

bist du dir denn sicher, das die gedropten pakete vom *spiel* stammen?


Gruß HL
 
Ich weiß ja welche Ports verwendet werden, es sind 6112-6119. Das Problem ist nicht, dass die Ports nicht rausgelassen werden sondern genau anders herum.

Beispiel:
Wenn ich ein Spiel Hoste (hinter dem Router) sollte es so sein, dass der Router die UDP-Ports 6112-6119 auf die IP 192.168.6.10 leitet.

Wenn ich das Spiel hoste, sehe ich im Router-Log, dass Leute von draußen versuchen, darauch zu connecten. Die Firewall verwirft aber die UDP-Pakete.

Wie kriege ich es nun hin, das die UDP-Ports 6112-6119 (die von außen kommen) auf 192.168.6.10 geleitet werden?
 
hi

ich hab mal eben gegoogelt und demnach soll es so sein, wie du schon sagst, das die kommunikation über die von dir genannten ports läuft.
warum die pakete dann aber nen anderen destport haben, weiß ich nicht.

du könntest jetzt folgendes machen. du lässt den destport in der filterregel weg und filterst nur nach sourceport 6112.

#StarCraft TCP/UDP Ports
iptables -t nat -A PREROUTING -i ippp0 -p tcp --dport 6112 -j DNAT --to-destination 192.168.6.10
iptables -t nat -A POSTROUTING -o eth0 -p tcp --dport 6112 -j SNAT --to-source $LAN_IP
iptables -A FORWARD -i ippp0 -m state --state NEW -p tcp -d 192.168.6.10 --dport 6112 -j ACCEPT

iptables -t nat -A PREROUTING -i ippp0 -p udp --sport 6112 -j DNAT --to-destination 192.168.6.10
iptables -t nat -A POSTROUTING -o eth0 -p udp --sport 6112 -j SNAT --to-source $LAN_IP
iptables -A FORWARD -i ippp0 -m state --state NEW -p udp -d 192.168.6.10 --sport 6112


hab die änderungen mal fett gemacht ;)


Gruß HL
 
Jetzt sagt mir die FW sowas:

Apr 7 18:28:56 knecht kernel: REJECT UDP IN=ippp0 OUT= MAC= SRC=213.64.6.147 DST=217.3.35.202 LEN=36 TOS=0x00 PREC=0x00 TTL=113 ID=44508 PROTO=UDP SPT=52300 DPT=1024 LEN=16

Ich verstehe immernoch nicht, was der Port 1024 damit zu tun hat.

Vielleicht hilft das ja weiter:

Tabelle filter
Chain INPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 state INVALID limit: avg 2/sec burst 5 LOG flags 0 level 4 prefix `INPUT INVALID '
0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 state INVALID
0 0 MY_DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x3F/0x00
0 0 MY_DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x03/0x03
0 0 MY_DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x06/0x06
0 0 MY_DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x05/0x05
0 0 MY_DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x11/0x01
0 0 MY_DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x18/0x08
0 0 MY_DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x30/0x20
0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
526 31921 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
0 0 ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
16 1349 ACCEPT all -- eth0 * 0.0.0.0/0 0.0.0.0/0 state NEW
38 1440 MY_REJECT all -- * * 0.0.0.0/0 0.0.0.0/0

Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 state INVALID limit: avg 2/sec burst 5 LOG flags 0 level 4 prefix `FORWARD INVALID '
0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 state INVALID
0 0 MY_DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x3F/0x00
0 0 MY_DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x03/0x03
0 0 MY_DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x06/0x06
0 0 MY_DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x05/0x05
0 0 MY_DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x11/0x01
0 0 MY_DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x18/0x08
0 0 MY_DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x30/0x20
295 17676 TCPMSS tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x06/0x02 TCPMSS clamp to PMTU
1209 216K ACCEPT all -- !ippp0 * 0.0.0.0/0 0.0.0.0/0 state NEW,RELATED,ESTABLISHED
916 174K ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
0 0 ACCEPT tcp -- ippp0 * 0.0.0.0/0 192.168.6.2 state NEW tcp dpt:4661
0 0 ACCEPT tcp -- ippp0 * 0.0.0.0/0 192.168.6.2 state NEW tcp dpt:4662
0 0 ACCEPT tcp -- ippp0 * 0.0.0.0/0 192.168.6.2 state NEW tcp dpt:4663
0 0 ACCEPT udp -- ippp0 * 0.0.0.0/0 192.168.6.2 state NEW udp dpt:4665
0 0 ACCEPT tcp -- ippp0 * 0.0.0.0/0 192.168.6.10 state NEW tcp dpt:6112
0 0 ACCEPT udp -- ippp0 * 0.0.0.0/0 192.168.6.10 state NEW udp dpt:6112
0 0 ACCEPT tcp -- ippp0 * 0.0.0.0/0 192.168.6.10 state NEW tcp dpt:6113
0 0 ACCEPT udp -- ippp0 * 0.0.0.0/0 192.168.6.10 state NEW udp dpt:6113
0 0 ACCEPT tcp -- ippp0 * 0.0.0.0/0 192.168.6.10 state NEW tcp dpt:6114
0 0 ACCEPT udp -- ippp0 * 0.0.0.0/0 192.168.6.10 state NEW udp dpt:6114
0 0 MY_REJECT all -- * * 0.0.0.0/0 0.0.0.0/0

Chain OUTPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 state INVALID limit: avg 2/sec burst 5 LOG flags 0 level 4 prefix `OUTPUT INVALID '
0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 state INVALID
0 0 ACCEPT all -- * lo 0.0.0.0/0 0.0.0.0/0
523 111K ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state NEW,RELATED,ESTABLISHED
0 0 MY_REJECT all -- * * 0.0.0.0/0 0.0.0.0/0

Chain MY_DROP (14 references)
pkts bytes target prot opt in out source destination
0 0 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 limit: avg 2/sec burst 5 LOG flags 0 level 4 prefix `PORTSCAN DROP '
0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0

Chain MY_REJECT (3 references)
pkts bytes target prot opt in out source destination
6 288 LOG tcp -- * * 0.0.0.0/0 0.0.0.0/0 limit: avg 2/sec burst 5 LOG flags 0 level 4 prefix `REJECT TCP '
6 288 REJECT tcp -- * * 0.0.0.0/0 0.0.0.0/0 reject-with tcp-reset
20 720 LOG udp -- * * 0.0.0.0/0 0.0.0.0/0 limit: avg 2/sec burst 5 LOG flags 0 level 4 prefix `REJECT UDP '
32 1152 REJECT udp -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
0 0 LOG icmp -- * * 0.0.0.0/0 0.0.0.0/0 limit: avg 2/sec burst 5 LOG flags 0 level 4 prefix `DROP ICMP '
0 0 DROP icmp -- * * 0.0.0.0/0 0.0.0.0/0
0 0 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 limit: avg 2/sec burst 5 LOG flags 0 level 4 prefix `REJECT OTHER '
0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-proto-unreachable
Tabelle nat
Chain PREROUTING (policy ACCEPT 8075 packets, 439K bytes)
pkts bytes target prot opt in out source destination
0 0 DNAT tcp -- ippp0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:4661 to:192.168.6.2
0 0 DNAT tcp -- ippp0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:4662 to:192.168.6.2
0 0 DNAT tcp -- ippp0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:4663 to:192.168.6.2
0 0 DNAT udp -- ippp0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:4665 to:192.168.6.2
0 0 DNAT tcp -- ippp0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:6112 to:192.168.6.10
0 0 DNAT udp -- ippp0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:6112 to:192.168.6.10
0 0 DNAT tcp -- ippp0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:6113 to:192.168.6.10
0 0 DNAT udp -- ippp0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:6113 to:192.168.6.10
0 0 DNAT tcp -- ippp0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:6114 to:192.168.6.10
0 0 DNAT udp -- ippp0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:6114 to:192.168.6.10

Chain POSTROUTING (policy ACCEPT 187 packets, 11186 bytes)
pkts bytes target prot opt in out source destination
0 0 SNAT tcp -- * eth0 0.0.0.0/0 0.0.0.0/0 tcp dpt:4661 to:192.168.6.1
0 0 SNAT tcp -- * eth0 0.0.0.0/0 0.0.0.0/0 tcp dpt:4662 to:192.168.6.1
0 0 SNAT tcp -- * eth0 0.0.0.0/0 0.0.0.0/0 tcp dpt:4663 to:192.168.6.1
0 0 SNAT udp -- * eth0 0.0.0.0/0 0.0.0.0/0 udp dpt:4665 to:192.168.6.1
0 0 SNAT tcp -- * eth0 0.0.0.0/0 0.0.0.0/0 tcp dpt:6112 to:192.168.6.1
0 0 SNAT udp -- * eth0 0.0.0.0/0 0.0.0.0/0 udp dpt:6112 to:192.168.6.1
0 0 SNAT tcp -- * eth0 0.0.0.0/0 0.0.0.0/0 tcp dpt:6113 to:192.168.6.1
0 0 SNAT udp -- * eth0 0.0.0.0/0 0.0.0.0/0 udp dpt:6113 to:192.168.6.1
0 0 SNAT tcp -- * eth0 0.0.0.0/0 0.0.0.0/0 tcp dpt:6114 to:192.168.6.1
0 0 SNAT udp -- * eth0 0.0.0.0/0 0.0.0.0/0 udp dpt:6114 to:192.168.6.1
177 10126 MASQUERADE all -- * ippp0 0.0.0.0/0 0.0.0.0/0

Chain OUTPUT (policy ACCEPT 822 packets, 58954 bytes)
pkts bytes target prot opt in out source destination
Tabelle mangle
Chain PREROUTING (policy ACCEPT 122K packets, 31M bytes)
pkts bytes target prot opt in out source destination

Chain INPUT (policy ACCEPT 59333 packets, 8433K bytes)
pkts bytes target prot opt in out source destination

Chain FORWARD (policy ACCEPT 62617 packets, 22M bytes)
pkts bytes target prot opt in out source destination

Chain OUTPUT (policy ACCEPT 54999 packets, 16M bytes)
pkts bytes target prot opt in out source destination

Chain POSTROUTING (policy ACCEPT 117K packets, 38M bytes)
pkts bytes target prot opt in out source destination
 
Zuletzt bearbeitet:
also ich glaube nicht, das das gedropte paket, was du gepostet hast, etwas mit dem spiel zu tun hat.

ändere mal die regeln nochmal folgendermaßen

iptables -t nat -A PREROUTING -i ippp0 -p udp --sport 6112 -j DNAT --to-destination 192.168.6.10:6112
iptables -t nat -A POSTROUTING -o eth0 -p udp --sport 6112 -j SNAT --to-source $LAN_IP
iptables -A FORWARD -i ippp0 -m state --state NEW -p udp -d 192.168.6.10 --sport 6112

hast du die firewall auch neu gestartet? sieht fast nicht so aus, wenn ich mir dein iptables-save so ansehe.

Gruß HL
 
Also das -j ACCEPT ist doch bei mir dran oder?

iptables -t nat -A PREROUTING -i ippp0 -p tcp --dport 6112 -j DNAT --to-destination 192.168.6.10
iptables -t nat -A POSTROUTING -o eth0 -p tcp --dport 6112 -j SNAT --to-source $LAN_IP
iptables -A FORWARD -i ippp0 -m state --state NEW -p tcp -d 192.168.6.10 --dport 6112 -j ACCEPT


Das mit --sport hat nichts gebracht.
 
hi,

Also was ich nicht ganz verstehe ist diese Zeile:
iptables -t nat -A POSTROUTING -o eth0 -p udp --sport 6112 -j SNAT --to-source $LAN_IP
Ich nehme mal an das eth0 dein internes Iface ist. Warum willst du den alle udp-frames vom sourceport 6112 als von deiner lan-ip ausgehend machen. Es ist doch der entfernet PC deines Starcraft- Freundes, der die Verbindung (wenn man das bei udp überhaupt sagen darf...) aufbaut und nicht dein Router....

Es müssten im Prinzip folgende Zeilen reichen:
1) iptables -t nat -A PREROUTING -i ippp0 -p tcp --dport 6112 -j DNAT --to-destination 192.168.6.10
2) iptables -t nat -A PREROUTING -i ippp0 -p udp --dport 6112 -j DNAT --to-destination 192.168.6.10
3) iptables -A FORWARD -i ippp0 -m state --state NEW -p tcp -d 192.168.6.10 --dport 6112 -j ACCEPT
4) iptables -A FORWARD -i ippp0 -m state --state NEW -p udp -d 192.168.6.10 --dport 6112 -j ACCEPT
Kommentiere den anderen Kram mal aus und versuchs damit....

Wenn es dann nicht funzt, würde ich es mal mit stateless filtering versuchen, weil ich mir nicht sicher bin ob udp mit den statefull Sachen zurechtkommt (Hier hatte ich nämlich mal ein Problem mit ipfw unter FreeBSD) Das ist dann zwar etwas weniger sicher, aber wenns anders nicht geht....

HTH,
mimi
 
Folgendes funktioniert jetzt:


iptables -t nat -A PREROUTING -i ippp0 -p udp --dport 6112:6119 -j DNAT --to-dest 192.168.6.10
iptables -A FORWARD -p udp -i ippp0 --dport 6112:6119 -d 192.168.6.10 -j ACCEPT

iptables -t nat -A PREROUTING -i ippp0 -p tcp --dport 6112:6119 -j DNAT --to-dest 192.168.6.10
iptables -A FORWARD -p tcp -i ippp0 --dport 6112:6119 -d 192.168.6.10 -j ACCEPT

Danke für eure Hilfe :)
 

Ähnliche Themen

Port Forwarding mit iptables

ip6tables Problem

iptables verständniss frage, xrdp nicht erreichbar.

[SOLVED][CentOS 7] Samba server nicht erreichbar trotz firewall regeln.

Wired-Lan komisches Verhalten

Zurück
Oben