Ports an OpenVPN Client weiterleiten

Einrichten des lokalen Netzes, Verbindung zu anderen Computern und Diensten.
Antworten
GFXG4M3R
Beiträge: 7
Registriert: 10.04.2014 15:55:09

Ports an OpenVPN Client weiterleiten

Beitrag von GFXG4M3R » 10.04.2014 15:57:32

Hallo,
ich habe mir einen Server gemietet und einen OpenVPN Server erstellt.
Ich habe es auch schon hinbekommen, dass ich die öffentliche IPv4 Adresse des Servers auf meinen PC weitergeleitet habe.

Jetzt möchte ich noch Ports für meinen PC weiterleiten, so dass ich auf meinem PC einen Server laufen lassen kann und über die RootServer IP erreichbar bin.

Ich bedanke mich jetzt schon für Antworten und für jegliche Hilfe.



Mfg Andreas

hschroed
Beiträge: 30
Registriert: 14.03.2005 04:04:00

Re: Ports an OpenVPN Client weiterleiten

Beitrag von hschroed » 10.04.2014 16:36:47

Moin,

wenn ich das jetzt richtig verstanden haben, hasst du eine OpenVPN Verbindung eingerichtet über die du auch schon surfen kannst, bzw. die ausgehend funktioniert ?

Dann ist das was dir noch fehlt für die Portweiterleitung, das DNAT in IPtables auf dem Server

Code: Alles auswählen

iptables -t nat -A PREROUTING -p tcp -d 192.168.102.37 --dport 422 -j DNAT --to 192.168.102.37:22
-d = öffentliche IP des Servers
-p = Protokoll TCP/UDP
-dport = Port
--to = OpenVPN IP Adresse vom Client (mit : kann man den Port ändern an den Weitergeleitet wird am Client)

Gruß,

hschroed

GFXG4M3R
Beiträge: 7
Registriert: 10.04.2014 15:55:09

Re: Ports an OpenVPN Client weiterleiten

Beitrag von GFXG4M3R » 10.04.2014 16:50:40

Hallo,
danke für deine Antwort.

Ja, dass haben sie richtig verstanden.
Unter wieistmeineip.de steht die IP von meinem Server.

Den Befehl habe ich mal getestet aber er funktioniert bei mir nicht.
Also wenn ich einen Teamspeak3 Server auf meinem PC starte, dann kann ich nicht mit der ServerIP connecten.

Ich habe folgendes eingegeben:

Code: Alles auswählen

iptables -t nat -A PREROUTING -p udp -d 134.xxx.xxx.xxx --dport 9987 -j DNAT --to 10.8.0.50:9987
Den Port 9987, weil ich zum Testen einen Teamspeak 3 Server testen wollte.

Bei meinem OpenVPN Client steht das ich die IP 10.8.0.50 habe also müsste die schonmal stimmen.

Ich weis nicht woran es liegt und ich hoffe du kannst mir weiterhelfen.

Hier noch die Routingtabelle, falls diese dir weiterhilft:

Code: Alles auswählen

root@server:~# netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:10000           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:33461           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN
tcp        0      0 10.8.0.1:445            10.8.0.50:28406         ESTABLISHED
tcp        0    448 134.xxx.xxx.xxx:22      88.xxx.xxx.xxx:62975    ESTABLISHED
tcp        0      0 134.xxx.xxx.xxx:139     10.8.0.50:27544         ESTABLISHED
tcp6       0      0 :::111                  :::*                    LISTEN
tcp6       0      0 :::80                   :::*                    LISTEN
tcp6       0      0 :::21                   :::*                    LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 ::1:25                  :::*                    LISTEN
tcp6       0      0 :::445                  :::*                    LISTEN
tcp6       0      0 :::45568                :::*                    LISTEN
tcp6       0      0 :::139                  :::*                    LISTEN

root@server:~# netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         134.xxx.xxx.1   0.0.0.0         UG        0 0          0 eth0
10.8.0.0        10.8.0.2        255.255.255.0   UG        0 0          0 tun0
10.8.0.2        *               255.255.255.255 UH        0 0          0 tun0
134.xxx.xxx.0   *               255.255.255.128 U         0 0          0 eth0

root@server:~# iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination
DNAT       tcp  --  anywhere             kxxx.net  tcp dpt:9987 to:10.8.0.50:9987
DNAT       udp  --  anywhere             kxxx.net  udp dpt:9987 to:10.8.0.50:9987

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination
MASQUERADE  all  --  anywhere             anywhere

root@server:~# iptables -t nat -nvL
Chain PREROUTING (policy ACCEPT 549 packets, 37952 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 DNAT       tcp  --  *      *       0.0.0.0/0            134.xxx.xxx.xxx      tcp dpt:9987 to:10.8.0.50:9987
    0     0 DNAT       udp  --  *      *       0.0.0.0/0            134.xxx.xxx.xxx      udp dpt:9987 to:10.8.0.50:9987

Chain INPUT (policy ACCEPT 58 packets, 8391 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 8 packets, 911 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain POSTROUTING (policy ACCEPT 1 packets, 60 bytes)
 pkts bytes target     prot opt in     out     source               destination
14143  777K MASQUERADE  all  --  *      eth0    0.0.0.0/0            0.0.0.0/0



Gibt es eine Möglichkeit ganze Portbereiche weiterzuleiten. Oder besser wäre es alle Ports an den OpenVPN client weiterzuleiten.
Da ich nur einen Clienten habe, wäre es auch kein Problem alle Ports für das tun0 Device weiterzuleiten, falls dies geht.





Mfg Andreas

Benutzeravatar
DynaBlaster
Beiträge: 958
Registriert: 25.03.2004 18:18:57
Lizenz eigener Beiträge: MIT Lizenz
Wohnort: DF0://dynablaster.adf

Re: Ports an OpenVPN Client weiterleiten

Beitrag von DynaBlaster » 10.04.2014 21:29:42

Aber die Forward-Chain auf dem Rootserver blockt nicht oder. Bitte mal die Ausgabe von

Code: Alles auswählen

iptables -L -n
Und ip_forward aktivieren. Entweder über /etc/sysctl.conf oder eben

Code: Alles auswählen

echo 1 > /proc/sys/net/ipv4/ip_forward

GFXG4M3R
Beiträge: 7
Registriert: 10.04.2014 15:55:09

Re: Ports an OpenVPN Client weiterleiten

Beitrag von GFXG4M3R » 11.04.2014 06:21:20

Hallo,
danke für deine Antwort.

Das IPv4 Forwarding war schon aktiviert.

Hier die Ausgabe von iptables -L -n:

Code: Alles auswählen

root@server:~# iptables -L -n                                                                     Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  10.8.0.0/24          0.0.0.0/0            ctstate NEW
ACCEPT     all  --  10.8.0.0/24          0.0.0.0/0            ctstate NEW
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
So wie ich das sehe blockt die Forward-Chain nicht oder?

Woran kann es liegen?
Ist es vielleicht ein Fehler in der OpenVPN Konfiguration?



Mfg Andreas

hschroed
Beiträge: 30
Registriert: 14.03.2005 04:04:00

Re: Ports an OpenVPN Client weiterleiten

Beitrag von hschroed » 11.04.2014 08:04:41

Moin,

kann man vom Server aus die IP 10.8.0.50 anpingen?

wie sieht die Routing Tabelle auf der 10.8.0.50 aus ?

Funktioniert es mit NAT zu tun0 ?

Code: Alles auswählen

iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
Was zeigt tcpdump, wenn man versucht sich zu verbinden?

Code: Alles auswählen

tcpdump -lnvi tun0 port 9987
Falls da nichts zu sehen ist kann man auch noch mal bei iptables gucken:

Code: Alles auswählen

iptables -nvL PREROUTING -t nat
Sollte vorne keine Null haben, dann matcht die Regel

oder tracen der Packete mit:

Code: Alles auswählen

iptables -I PREROUTING -t raw -p UDP -d *ServerIP* --dport 9987 -j TRACE
dann im /var/log/messages schauen welche Regeln matchen und ob eine Regel DROP oder REJECT hat.

Den Trace hinterher wieder löschen:

Code: Alles auswählen

iptables -D PREROUTING -t raw -p UDP -d *ServerIP* --dport 9987 -j TRACE
*EDIT*

Ich sehe grade das die Regeln nicht matchen, dann mal direkt ein trace oder tcpdump aber dann:

Code: Alles auswählen

tcpdump -lnvi eth0 port 9987
Gruß,

hschroed

GFXG4M3R
Beiträge: 7
Registriert: 10.04.2014 15:55:09

Re: Ports an OpenVPN Client weiterleiten

Beitrag von GFXG4M3R » 11.04.2014 11:39:02

Hallo,
erstmal danke für ihre ausführliche Antwort.


Nein ich kann den Clienten nicht anpingen. (Ja, die OpenVPN Verbindung ist hergestellt)

Code: Alles auswählen

root@server:/# hping3 10.8.0.50
HPING 10.8.0.50 (tun0 10.8.0.50): NO FLAGS are set, 40 headers + 0 data bytes
^C
--- 10.8.0.50 hping statistic ---
34 packets transmitted, 0 packets received, 100% packet loss
round-trip min/avg/max = 0.0/0.0/0.0 ms
root@server:/# ping 10.8.0.50
PING 10.8.0.50 (10.8.0.50) 56(84) bytes of data.
^C
--- 10.8.0.50 ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3023ms


Der VNC Client läuft auf einem Windows PC und ich hoffe du meinst folgende Routingtabelle:

Code: Alles auswählen

C:\Users\Andreas>netstat

Aktive Verbindungen

  Proto  Lokale Adresse         Remoteadresse          Status
  TCP    127.0.0.1:1041         Andreas-PC:1042        HERGESTELLT
  TCP    127.0.0.1:1042         Andreas-PC:1041        HERGESTELLT
  TCP    127.0.0.1:1043         Andreas-PC:5354        HERGESTELLT
  TCP    127.0.0.1:1050         Andreas-PC:8743        HERGESTELLT
  TCP    127.0.0.1:1051         Andreas-PC:8643        HERGESTELLT
  TCP    127.0.0.1:1087         Andreas-PC:1088        HERGESTELLT
  TCP    127.0.0.1:1088         Andreas-PC:1087        HERGESTELLT
  TCP    127.0.0.1:1090         Andreas-PC:1091        HERGESTELLT
  TCP    127.0.0.1:1091         Andreas-PC:1090        HERGESTELLT
  TCP    127.0.0.1:1099         Andreas-PC:23560       HERGESTELLT
  TCP    127.0.0.1:1120         Andreas-PC:1121        HERGESTELLT
  TCP    127.0.0.1:1121         Andreas-PC:1120        HERGESTELLT
  TCP    127.0.0.1:1123         Andreas-PC:1124        HERGESTELLT
  TCP    127.0.0.1:1124         Andreas-PC:1123        HERGESTELLT
  TCP    127.0.0.1:1125         Andreas-PC:1126        HERGESTELLT
  TCP    127.0.0.1:1126         Andreas-PC:1125        HERGESTELLT
  TCP    127.0.0.1:1127         Andreas-PC:1128        HERGESTELLT
  TCP    127.0.0.1:1128         Andreas-PC:1127        HERGESTELLT
  TCP    127.0.0.1:1141         Andreas-PC:1142        HERGESTELLT
  TCP    127.0.0.1:1142         Andreas-PC:1141        HERGESTELLT
  TCP    127.0.0.1:1144         Andreas-PC:1145        HERGESTELLT
  TCP    127.0.0.1:1145         Andreas-PC:1144        HERGESTELLT
  TCP    127.0.0.1:1175         Andreas-PC:19872       HERGESTELLT
  TCP    127.0.0.1:1210         Andreas-PC:1211        HERGESTELLT
  TCP    127.0.0.1:1211         Andreas-PC:1210        HERGESTELLT
  TCP    127.0.0.1:1235         Andreas-PC:1236        HERGESTELLT
  TCP    127.0.0.1:1236         Andreas-PC:1235        HERGESTELLT
  TCP    127.0.0.1:1237         Andreas-PC:1238        HERGESTELLT
  TCP    127.0.0.1:1238         Andreas-PC:1237        HERGESTELLT
  TCP    127.0.0.1:1239         Andreas-PC:1240        HERGESTELLT
  TCP    127.0.0.1:1240         Andreas-PC:1239        HERGESTELLT
  TCP    127.0.0.1:1241         Andreas-PC:1242        HERGESTELLT
  TCP    127.0.0.1:1242         Andreas-PC:1241        HERGESTELLT
  TCP    127.0.0.1:1243         Andreas-PC:1244        HERGESTELLT
  TCP    127.0.0.1:1244         Andreas-PC:1243        HERGESTELLT
  TCP    127.0.0.1:1245         Andreas-PC:1246        HERGESTELLT
  TCP    127.0.0.1:1246         Andreas-PC:1245        HERGESTELLT
  TCP    127.0.0.1:1247         Andreas-PC:1248        HERGESTELLT
  TCP    127.0.0.1:1248         Andreas-PC:1247        HERGESTELLT
  TCP    127.0.0.1:1249         Andreas-PC:1250        HERGESTELLT
  TCP    127.0.0.1:1250         Andreas-PC:1249        HERGESTELLT
  TCP    127.0.0.1:1256         Andreas-PC:1257        HERGESTELLT
  TCP    127.0.0.1:1257         Andreas-PC:1256        HERGESTELLT
  TCP    127.0.0.1:1258         Andreas-PC:1259        HERGESTELLT
  TCP    127.0.0.1:1259         Andreas-PC:1258        HERGESTELLT
  TCP    127.0.0.1:1309         Andreas-PC:1310        HERGESTELLT
  TCP    127.0.0.1:1310         Andreas-PC:1309        HERGESTELLT
  TCP    127.0.0.1:1311         Andreas-PC:1312        HERGESTELLT
  TCP    127.0.0.1:1312         Andreas-PC:1311        HERGESTELLT
  TCP    127.0.0.1:1313         Andreas-PC:1314        HERGESTELLT
  TCP    127.0.0.1:1314         Andreas-PC:1313        HERGESTELLT
  TCP    127.0.0.1:1315         Andreas-PC:1316        HERGESTELLT
  TCP    127.0.0.1:1316         Andreas-PC:1315        HERGESTELLT
  TCP    127.0.0.1:3302         Andreas-PC:8085        WARTEND
  TCP    127.0.0.1:3303         Andreas-PC:8085        WARTEND
  TCP    127.0.0.1:3306         Andreas-PC:8085        WARTEND
  TCP    127.0.0.1:3320         Andreas-PC:3319        WARTEND
  TCP    127.0.0.1:3322         Andreas-PC:3321        WARTEND
  TCP    127.0.0.1:3324         Andreas-PC:3323        WARTEND
  TCP    127.0.0.1:3326         Andreas-PC:3325        WARTEND
  TCP    127.0.0.1:3329         Andreas-PC:3327        WARTEND
  TCP    127.0.0.1:3330         Andreas-PC:3328        WARTEND
  TCP    127.0.0.1:3332         Andreas-PC:3331        WARTEND
  TCP    127.0.0.1:3334         Andreas-PC:3333        WARTEND
  TCP    127.0.0.1:3336         Andreas-PC:3335        WARTEND
  TCP    127.0.0.1:3338         Andreas-PC:3337        WARTEND
  TCP    127.0.0.1:3345         Andreas-PC:3344        WARTEND
  TCP    127.0.0.1:3347         Andreas-PC:3346        WARTEND
  TCP    127.0.0.1:3349         Andreas-PC:3348        WARTEND
  TCP    127.0.0.1:3351         Andreas-PC:3350        WARTEND
  TCP    127.0.0.1:3354         Andreas-PC:3352        WARTEND
  TCP    127.0.0.1:3355         Andreas-PC:3353        WARTEND
  TCP    127.0.0.1:3358         Andreas-PC:3356        WARTEND
  TCP    127.0.0.1:3359         Andreas-PC:3357        WARTEND
  TCP    127.0.0.1:3362         Andreas-PC:3360        WARTEND
  TCP    127.0.0.1:3363         Andreas-PC:3361        WARTEND
  TCP    127.0.0.1:3366         Andreas-PC:3367        HERGESTELLT
  TCP    127.0.0.1:3367         Andreas-PC:3366        HERGESTELLT
  TCP    127.0.0.1:3370         Andreas-PC:3369        WARTEND
  TCP    127.0.0.1:3372         Andreas-PC:3371        WARTEND
  TCP    127.0.0.1:3374         Andreas-PC:3373        WARTEND
  TCP    127.0.0.1:3376         Andreas-PC:3375        WARTEND
  TCP    127.0.0.1:3379         Andreas-PC:3377        WARTEND
  TCP    127.0.0.1:3380         Andreas-PC:3378        WARTEND
  TCP    127.0.0.1:3383         Andreas-PC:3382        WARTEND
  TCP    127.0.0.1:3384         Andreas-PC:3381        WARTEND
  TCP    127.0.0.1:3386         Andreas-PC:3385        WARTEND
  TCP    127.0.0.1:3388         Andreas-PC:3387        WARTEND
  TCP    127.0.0.1:3391         Andreas-PC:3390        WARTEND
  TCP    127.0.0.1:3393         Andreas-PC:3392        WARTEND
  TCP    127.0.0.1:3395         Andreas-PC:3394        WARTEND
  TCP    127.0.0.1:3397         Andreas-PC:3396        WARTEND
  TCP    127.0.0.1:3399         Andreas-PC:3398        WARTEND
  TCP    127.0.0.1:3401         Andreas-PC:3400        WARTEND
  TCP    127.0.0.1:3403         Andreas-PC:3402        WARTEND
  TCP    127.0.0.1:3405         Andreas-PC:3404        WARTEND
  TCP    127.0.0.1:3407         Andreas-PC:3406        WARTEND
  TCP    127.0.0.1:3409         Andreas-PC:3408        WARTEND
  TCP    127.0.0.1:3422         Andreas-PC:3423        HERGESTELLT
  TCP    127.0.0.1:3423         Andreas-PC:3422        HERGESTELLT
  TCP    127.0.0.1:3425         Andreas-PC:3424        WARTEND
  TCP    127.0.0.1:3427         Andreas-PC:3426        WARTEND
  TCP    127.0.0.1:3429         Andreas-PC:3428        WARTEND
  TCP    127.0.0.1:3431         Andreas-PC:3430        WARTEND
  TCP    127.0.0.1:3433         Andreas-PC:3432        WARTEND
  TCP    127.0.0.1:3436         Andreas-PC:3434        WARTEND
  TCP    127.0.0.1:3437         Andreas-PC:3435        WARTEND
  TCP    127.0.0.1:3439         Andreas-PC:3438        WARTEND
  TCP    127.0.0.1:3442         Andreas-PC:3441        WARTEND
  TCP    127.0.0.1:3443         Andreas-PC:3440        WARTEND
  TCP    127.0.0.1:3445         Andreas-PC:3444        WARTEND
  TCP    127.0.0.1:3448         Andreas-PC:3447        WARTEND
  TCP    127.0.0.1:3449         Andreas-PC:3446        WARTEND
  TCP    127.0.0.1:3450         Andreas-PC:3453        WARTEND
  TCP    127.0.0.1:3453         Andreas-PC:3450        WARTEND
  TCP    127.0.0.1:3454         Andreas-PC:3451        WARTEND
  TCP    127.0.0.1:3455         Andreas-PC:3452        WARTEND
  TCP    127.0.0.1:3458         Andreas-PC:3456        WARTEND
  TCP    127.0.0.1:3460         Andreas-PC:3457        WARTEND
  TCP    127.0.0.1:3461         Andreas-PC:3459        WARTEND
  TCP    127.0.0.1:3463         Andreas-PC:3462        WARTEND
  TCP    127.0.0.1:3465         Andreas-PC:3464        WARTEND
  TCP    127.0.0.1:3467         Andreas-PC:3466        WARTEND
  TCP    127.0.0.1:3469         Andreas-PC:3468        WARTEND
  TCP    127.0.0.1:3471         Andreas-PC:3470        WARTEND
  TCP    127.0.0.1:3473         Andreas-PC:3472        WARTEND
  TCP    127.0.0.1:3475         Andreas-PC:3476        HERGESTELLT
  TCP    127.0.0.1:3476         Andreas-PC:3475        HERGESTELLT
  TCP    127.0.0.1:3478         Andreas-PC:3477        WARTEND
  TCP    127.0.0.1:3480         Andreas-PC:3479        WARTEND
  TCP    127.0.0.1:3482         Andreas-PC:3481        WARTEND
  TCP    127.0.0.1:3484         Andreas-PC:3483        WARTEND
  TCP    127.0.0.1:3486         Andreas-PC:3485        WARTEND
  TCP    127.0.0.1:3487         Andreas-PC:8085        WARTEND
  TCP    127.0.0.1:3489         Andreas-PC:3488        WARTEND
  TCP    127.0.0.1:3491         Andreas-PC:3490        WARTEND
  TCP    127.0.0.1:3493         Andreas-PC:3492        WARTEND
  TCP    127.0.0.1:3495         Andreas-PC:3494        WARTEND
  TCP    127.0.0.1:3497         Andreas-PC:3496        WARTEND
  TCP    127.0.0.1:3499         Andreas-PC:3498        WARTEND
  TCP    127.0.0.1:3501         Andreas-PC:3500        WARTEND
  TCP    127.0.0.1:3503         Andreas-PC:3502        WARTEND
  TCP    127.0.0.1:3505         Andreas-PC:3504        WARTEND
  TCP    127.0.0.1:3507         Andreas-PC:3506        WARTEND
  TCP    127.0.0.1:3509         Andreas-PC:3508        WARTEND
  TCP    127.0.0.1:3511         Andreas-PC:3510        WARTEND
  TCP    127.0.0.1:3513         Andreas-PC:3512        WARTEND
  TCP    127.0.0.1:3515         Andreas-PC:3514        WARTEND
  TCP    127.0.0.1:3517         Andreas-PC:3516        WARTEND
  TCP    127.0.0.1:3520         Andreas-PC:3519        WARTEND
  TCP    127.0.0.1:3522         Andreas-PC:3521        WARTEND
  TCP    127.0.0.1:3524         Andreas-PC:3523        WARTEND
  TCP    127.0.0.1:3526         Andreas-PC:3525        WARTEND
  TCP    127.0.0.1:3528         Andreas-PC:3527        WARTEND
  TCP    127.0.0.1:3532         Andreas-PC:3530        WARTEND
  TCP    127.0.0.1:3533         Andreas-PC:3531        WARTEND
  TCP    127.0.0.1:3535         Andreas-PC:3534        WARTEND
  TCP    127.0.0.1:3537         Andreas-PC:3536        WARTEND
  TCP    127.0.0.1:3539         Andreas-PC:3538        WARTEND
  TCP    127.0.0.1:3541         Andreas-PC:pnrp-port   WARTEND
  TCP    127.0.0.1:3544         Andreas-PC:3543        WARTEND
  TCP    127.0.0.1:3545         Andreas-PC:3542        WARTEND
  TCP    127.0.0.1:3548         Andreas-PC:3546        WARTEND
  TCP    127.0.0.1:3549         Andreas-PC:3547        WARTEND
  TCP    127.0.0.1:3550         Andreas-PC:8085        WARTEND
  TCP    127.0.0.1:5354         Andreas-PC:1043        HERGESTELLT
  TCP    127.0.0.1:5357         Andreas-PC:3368        WARTEND
  TCP    127.0.0.1:8085         Andreas-PC:3301        WARTEND
  TCP    127.0.0.1:8085         Andreas-PC:3305        WARTEND
  TCP    127.0.0.1:8085         Andreas-PC:3312        WARTEND
  TCP    127.0.0.1:8085         Andreas-PC:3316        WARTEND
  TCP    127.0.0.1:8085         Andreas-PC:ms-wbt-server  WARTEND
  TCP    127.0.0.1:8643         Andreas-PC:1051        HERGESTELLT
  TCP    127.0.0.1:8743         Andreas-PC:1050        HERGESTELLT
  TCP    127.0.0.1:19872        Andreas-PC:1175        HERGESTELLT
  TCP    127.0.0.1:23560        Andreas-PC:1099        HERGESTELLT
  TCP    169.254.123.236:3474   Andreas-PC:32469       HERGESTELLT
  TCP    169.254.123.236:32469  Andreas-PC:3474        HERGESTELLT
  TCP    169.254.243.200:3421   Andreas-PC:32469       HERGESTELLT
  TCP    169.254.243.200:32469  Andreas-PC:3421        HERGESTELLT
  TCP    192.168.91.1:3365      Andreas-PC:32469       HERGESTELLT
  TCP    192.168.91.1:32469     Andreas-PC:3365        HERGESTELLT
  TCP    192.168.178.20:443     Andreas-PC:3317        WARTEND
  TCP    192.168.178.20:443     Andreas-PC:3318        WARTEND
  TCP    192.168.178.20:1164    195.59.54.93:https     HERGESTELLT
  TCP    192.168.178.20:1202    snt-re1-9b:http        HERGESTELLT
  TCP    192.168.178.20:1318    ec2-54-225-249-228:4244  HERGESTELLT
  TCP    192.168.178.20:2076    fritz:2066             HERGESTELLT
  TCP    192.168.178.20:2368    KVM466:ssh             HERGESTELLT
  TCP    192.168.178.20:2565    KVM466:ssh             HERGESTELLT
  TCP    192.168.178.20:3300    mail:http              HERGESTELLT
  TCP    192.168.178.20:3311    no-dns-yet:4448        SYN_GESENDET
  TCP    192.168.178.20:3314    cmc:https              SYN_GESENDET
  TCP    192.168.178.20:3315    fritz:http             WARTEND
  TCP    192.168.178.20:3339    fritz:49000            HERGESTELLT
  TCP    192.168.178.20:3340    fritz:49000            HERGESTELLT
  TCP    192.168.178.20:3341    fritz:49000            HERGESTELLT
  TCP    192.168.178.20:3364    10.8.0.1:microsoft-ds  SYN_GESENDET
  TCP    192.168.178.20:3410    10.8.0.1:microsoft-ds  SYN_GESENDET
  TCP    192.168.178.20:3411    10.8.0.1:microsoft-ds  SYN_GESENDET
  TCP    192.168.178.20:3412    10.8.0.1:microsoft-ds  SYN_GESENDET
  TCP    192.168.178.20:3413    10.8.0.1:netbios-ssn   SYN_GESENDET
  TCP    192.168.178.20:3518    misc-2a:http           WARTEND
  TCP    192.168.178.20:3529    misc-2a:https          HERGESTELLT
  TCP    [::1]:1564             Andreas-PC:1566        HERGESTELLT
  TCP    [::1]:1566             Andreas-PC:1564        HERGESTELLT
  TCP    [::1]:2869             Andreas-PC:3420        HERGESTELLT
  TCP    [::1]:3420             Andreas-PC:icslap      HERGESTELLT
  TCP    [2001:a60:1766:201:210a:25:7b35:78a5]:3031  [2404:6800:4008:c01::88]:ht
tps  HERGESTELLT
  TCP    [2001:a60:1766:201:210a:25:7b35:78a5]:3032  fa-in-x65:https        HERG
ESTELLT
  TCP    [2001:a60:1766:201:210a:25:7b35:78a5]:3033  fa-in-x5f:https        HERG
ESTELLT
  TCP    [2001:a60:1766:201:210a:25:7b35:78a5]:3055  fa-in-x5e:https        HERG
ESTELLT
  TCP    [2001:a60:1766:201:210a:25:7b35:78a5]:3057  fra02s21-in-x1e:https  HERG
ESTELLT
  TCP    [2001:a60:1766:201:210a:25:7b35:78a5]:3059  fa-in-x78:https        HERG
ESTELLT
  TCP    [2001:a60:1766:201:210a:25:7b35:78a5]:3060  fa-in-x69:https        HERG
ESTELLT
  TCP    [2001:a60:1766:201:210a:25:7b35:78a5]:3062  fa-in-x8a:https        HERG
ESTELLT
  TCP    [2001:a60:1766:201:210a:25:7b35:78a5]:3065  fa-in-x5e:https        HERG
ESTELLT
  TCP    [2001:a60:1766:201:210a:25:7b35:78a5]:3076  fa-in-x78:https        HERG
ESTELLT
  TCP    [fd00::210a:25:7b35:78a5]:3343  fritz:microsoft-ds     HERGESTELLT
  TCP    [fe80::54a8:d168:9ed:16ba%11]:445  Andreas-PC:3342        HERGESTELLT
  TCP    [fe80::54a8:d168:9ed:16ba%11]:3342  Andreas-PC:microsoft-ds  HERGESTELLT

Mit dem NAT zu tun0 funktioniert es nicht, wenn damit folgender Befehl gemeint ist:

Code: Alles auswählen

iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE


Tcpdump zeigt folgendes an:

Code: Alles auswählen

root@server:/# tcpdump -lnvi tun0 port 9987
tcpdump: listening on tun0, link-type RAW (Raw IP), capture size 65535 bytes
05:28:29.360257 IP (tos 0x0, ttl 58, id 15616, offset 0, flags [none], proto UDP                                                                                                                                                              (17), length 62)
    10.8.0.1.7837 > 10.8.0.50.9987: UDP, length 34
05:28:29.360730 IP (tos 0x0, ttl 58, id 15617, offset 0, flags [none], proto UDP                                                                                                                                                              (17), length 212)
    10.8.0.1.7837 > 10.8.0.50.9987: UDP, length 184
05:28:29.898533 IP (tos 0x0, ttl 58, id 15802, offset 0, flags [none], proto UDP                                                                                                                                                              (17), length 62)
    10.8.0.1.7837 > 10.8.0.50.9987: UDP, length 34
05:28:29.898950 IP (tos 0x0, ttl 58, id 15803, offset 0, flags [none], proto UDP                                                                                                                                                              (17), length 212)
    10.8.0.1.7837 > 10.8.0.50.9987: UDP, length 184
05:28:30.598340 IP (tos 0x0, ttl 58, id 16036, offset 0, flags [none], proto UDP                                                                                                                                                              (17), length 62)
    10.8.0.1.7837 > 10.8.0.50.9987: UDP, length 34
05:28:30.599499 IP (tos 0x0, ttl 58, id 16037, offset 0, flags [none], proto UDP                                                                                                                                                              (17), length 212)
    10.8.0.1.7837 > 10.8.0.50.9987: UDP, length 184
05:28:31.598802 IP (tos 0x0, ttl 58, id 16372, offset 0, flags [none], proto UDP                                                                                                                                                              (17), length 62)
    10.8.0.1.7837 > 10.8.0.50.9987: UDP, length 34
05:28:31.600278 IP (tos 0x0, ttl 58, id 16373, offset 0, flags [none], proto UDP                                                                                                                                                              (17), length 212)
    10.8.0.1.7837 > 10.8.0.50.9987: UDP, length 184
05:28:32.899386 IP (tos 0x0, ttl 58, id 16809, offset 0, flags [none], proto UDP                                                                                                                                                              (17), length 62)
    10.8.0.1.7837 > 10.8.0.50.9987: UDP, length 34
05:28:32.999025 IP (tos 0x0, ttl 58, id 16845, offset 0, flags [none], proto UDP                                                                                                                                                              (17), length 212)
    10.8.0.1.7837 > 10.8.0.50.9987: UDP, length 184

10 packets captured
10 packets received by filter
0 packets dropped by kernel

Iptables zeigt:

Code: Alles auswählen

root@server:/# iptables -nvL PREROUTING -t nat
Chain PREROUTING (policy ACCEPT 52 packets, 4879 bytes)
 pkts bytes target     prot opt in     out     source               destination
    2   124 DNAT       udp  --  *      *       0.0.0.0/0            134.255.239.100      udp dpt:9987 to:10.8.0.50:9987


Sollte vorne keine Null haben, dann matcht die Regel

oder tracen der Packete mit:

Code: Alles auswählen

iptables -I PREROUTING -t raw -p UDP -d *ServerIP* --dport 9987 -j TRACE

dann im /var/log/messages schauen welche Regeln matchen und ob eine Regel DROP oder REJECT hat.

Den Trace hinterher wieder löschen:

Code: Alles auswählen

iptables -D PREROUTING -t raw -p UDP -d *ServerIP* --dport 9987 -j TRACE

Diesen Teil habe ich wegelassen, weil du den Beitrag nochmal bearbeitet hast und gesagt hast, dass die Regeln nicht matchen



Tcpdump gibt aus:

Code: Alles auswählen

root@server:/# tcpdump -lnvi eth0 port 9987
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
05:33:22.666246 IP (tos 0x0, ttl 59, id 2225, offset 0, flags [none], proto UDP (17), length 62)
    88.xxx.xxx.xxx.7843 > 134.xxx.xxx.xxx.9987: UDP, length 34
05:33:22.667041 IP (tos 0x0, ttl 59, id 2226, offset 0, flags [none], proto UDP (17), length 212)
    88.xxx.xxx.xxx.7843 > 134.xxx.xxx.xxx.9987: UDP, length 184
05:33:23.212075 IP (tos 0x0, ttl 59, id 2407, offset 0, flags [none], proto UDP (17), length 62)
    88.xxx.xxx.xxx.7843 > 134.xxx.xxx.xxx.9987: UDP, length 34
05:33:23.212595 IP (tos 0x0, ttl 59, id 2408, offset 0, flags [none], proto UDP (17), length 212)
    88.xxx.xxx.xxx.7843 > 134.xxx.xxx.xxx.9987: UDP, length 184
05:33:23.912354 IP (tos 0x0, ttl 59, id 2647, offset 0, flags [none], proto UDP (17), length 62)
    88.xxx.xxx.xxx.7843 > 134.xxx.xxx.xxx.9987: UDP, length 34
05:33:23.913096 IP (tos 0x0, ttl 59, id 2648, offset 0, flags [none], proto UDP (17), length 212)
    88.xxx.xxx.xxx.7843 > 134.xxx.xxx.xxx.9987: UDP, length 184
05:33:24.912394 IP (tos 0x0, ttl 59, id 2983, offset 0, flags [none], proto UDP (17), length 62)
    88.xxx.xxx.xxx.7843 > 134.xxx.xxx.xxx.9987: UDP, length 34
05:33:24.913065 IP (tos 0x0, ttl 59, id 2984, offset 0, flags [none], proto UDP (17), length 212)
    88.xxx.xxx.xxx.7843 > 134.xxx.xxx.xxx.9987: UDP, length 184
05:33:26.212093 IP (tos 0x0, ttl 59, id 3421, offset 0, flags [none], proto UDP (17), length 62)
    88.xxx.xxx.xxx.7843 > 134.xxx.xxx.xxx.9987: UDP, length 34
05:33:26.312953 IP (tos 0x0, ttl 59, id 3454, offset 0, flags [none], proto UDP (17), length 212)
    88.xxx.xxx.xxx.7843 > 134.xxx.xxx.xxx.9987: UDP, length 184
10 packets captured
10 packets received by filter
0 packets dropped by kernel


Ich hoffe ich konnte alle offenen Fragen zufriedenstellend beantworten und hoffe, dass du mir weiterhelfen kannst.




Mfg Andreas
Zuletzt geändert von GFXG4M3R am 12.04.2014 08:40:10, insgesamt 1-mal geändert.

hschroed
Beiträge: 30
Registriert: 14.03.2005 04:04:00

Re: Ports an OpenVPN Client weiterleiten

Beitrag von hschroed » 11.04.2014 14:28:54

Moin,

so wie es aussieht kommen die Pakete an der 10.8.0.50 an, sie werden also weitergeleitet, werden aber nicht beantwortet.
Da musst du noch mal am Client gucken, ob die da auch ankommen und ob der Server überhaupt auch auf die 10.8.0.50 lauscht.
Hast du eine Firewall am Client an ?

Gruß,

hschroed

GFXG4M3R
Beiträge: 7
Registriert: 10.04.2014 15:55:09

Re: Ports an OpenVPN Client weiterleiten

Beitrag von GFXG4M3R » 12.04.2014 08:43:14

Hallo,

das habe ich mir auch gedacht.
Da musst du noch mal am Client gucken, ob die da auch ankommen
Wie kann ich das an einem Windows PC machen?

ob der Server überhaupt auch auf die 10.8.0.50 lauscht
Wie kann ich das nachgucken?

Hast du eine Firewall am Client an ?
Nein ich habe die Firewall testweise ausgestellt.



Mfg Andreas

hschroed
Beiträge: 30
Registriert: 14.03.2005 04:04:00

Re: Ports an OpenVPN Client weiterleiten

Beitrag von hschroed » 14.04.2014 08:25:21

Du kannst Wireshark unter Windows nutzen um zu sehen, ob die Pakete ankommen.

Gruß,

hschroed

GFXG4M3R
Beiträge: 7
Registriert: 10.04.2014 15:55:09

Re: Ports an OpenVPN Client weiterleiten

Beitrag von GFXG4M3R » 15.04.2014 08:44:58

Hallo,

Nach einem RootServer Neustart konnte ich den Client anpingen.
Und Wireshark hat diese Pakete auch empfangen und bestätigt.

Nach einigem rumprobieren kommte ich dann auch den Teamspeak 3 Server über die RootServer IP erreichen.

Meine Iptables Regeln sind:

Code: Alles auswählen

iptables -t nat -A PREROUTING -t nat -p udp -d 134.xxx.xxx.xxx.xxx --dport 9987 -j DNAT --to 10.8.0.50:9987
Ich weiß nicht, warum es vorher nicht funktioniert hat, aber jetzt geht es.

Jetzt habe ich nurnoch eine Frage.
Kann ich auch Portbereiche weiterleiten?
Ich habe gerade gemerkt, wenn ich den Port weiterleite und einen Teamspeak3 Server auf meinem Root installiere, dass ich die Verbindung dahin nicht mehr aufbauen kann. Ist das normal? oder wie kann man das umgehen ?


Ich bedanke mich bei allen die mir bei meinem Problem geholfen haben.



Mfg Andreas

hschroed
Beiträge: 30
Registriert: 14.03.2005 04:04:00

Re: Ports an OpenVPN Client weiterleiten

Beitrag von hschroed » 16.04.2014 13:55:05

Moin,

wenn du nur eine IP hast und du den Port weiterleitest, kannst du dich auf den Server nicht mehr über die öffentliche IP anmelden, da diese ja umgeleitet ist.
Das bedeutet alle Ports die du umleitest sind nicht mehr auf dem Server selber erreichbar, leitest du also Port 22 z.B. um, kannst du nicht mehr per SSH auf die externe IP zugreifen, bei dem openVPN Port würde dann deine VPN nicht mehr funktionieren, also sei vorsichtig was du umleitest!

Umleiten von Port-Ranges geht auch mit:

--dport 9987:10000

Code: Alles auswählen

iptables -t nat -A PREROUTING -t nat -p udp -d 134.xxx.xxx.xxx.xxx --dport 9987:10000 -j DNAT --to 10.8.0.50
bei --to musst du keinen Port angeben, den brauchst du nur wenn du den ändern willst z.B. extern Port 1212 auf intern Port 80

Gruß,

hschroed

GFXG4M3R
Beiträge: 7
Registriert: 10.04.2014 15:55:09

Re: Ports an OpenVPN Client weiterleiten

Beitrag von GFXG4M3R » 17.04.2014 10:14:00

Hallo,

ich habe es gerade getestet und es klappt wunderbar.

Danke für deine Hilfe.




Mfg Andreas

Antworten