OpenVPN Ports für Anwendungen weiterleiten?

D

dj_mytze

Schnuffi
Hallo, ich versuchs kurz zu machen:
Sitze bis auf weiteres wegen Montage im Hotel, Internet gibts auch, soweit so gut. Dummerweise sind alle Ports außer 80, 443 und ironischer Weise 22 gesperrt.
Das bedeutet: Nur surfen, kein Teamspeak, kein Zugriff aufn Heimserver(eben nicht auf Port 22 konfiguriert), kein zocken, Steam lässt sich nichtmal anmelden....

Hatte zuerst die Idee mir mittels SSH die benötigten Ports zu tunneln, wird aber irgendwie etwas zu aufwändig bei der benötigten Menge :D
Also "schnell" nen OpenVPN-Server auf meinen Bastel-Root gepspielt und nach nur kurzen 5h habe ich endlich Internetzugriff via VPN. Gibt viele Tutorials, wirklich brauchbar sind die wenigsten O.o
Was immer noch nicht geht:
Zocken, Heimserver, Teamspeak.
Gehe jetzt davon aus, dass ich noch ein paar Ports aufm Server forwarden muss, komm aber jetzt endgültig nicht mehr weiter.

Kurz zu Info:
Client(is auch Backtrack drauf, da kann ich aber nicht drunter zocken^^):
Windows 7 Pro x64 mit OpenVPN Client. Config:
Code:
client
dev tun
dev-node MyTap
proto tcp
remote 85.xxx.99.xxx 443
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert xxxx.crt
key xxxx.key
ns-cert-type server
tls-auth xxxx.key 1
comp-lzo
# Set log file verbosity.
verb 3

Server:
Strato V-Server SE mit Debian 6 Kernel 2.6.32-028stab091.2 mit OpenVPN Server
Code:
server 10.8.0.0 255.255.255.0
local 85.xxx.99.xxx
port 443
proto tcp
dev tun

ca /etc/openvpn/easy-rsa/keys/xxxx.crt
cert /etc/openvpn/easy-rsa/keys/xxx.crt
key /etc/openvpn/easy-rsa/keys/xxxx.key  # This file should be kept secret
dh /etc/openvpn/easy-rsa/keys/xxxxxx.pem
tls-auth /etc/openvpn/easy-rsa/keys/xxxx.key 0 # This file is secret

ping-timer-rem
ifconfig-pool-persist ipp.txt
push "redirect-gateway"
keepalive 10 120
comp-lzo
max-clients 5
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log
log-append  openvpn.log
verb 3
mute 50

die benötigten Settings fürs Routing hab ich mir in ein Script gepackt, falls mal Server rebootet wird:
Code:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -F POSTROUTING
iptables -t nat -A POSTROUTING -o venet0:0 -s 10.8.0.0/24 -j SNAT --to 85.xxx.99.xxx
iptables -I FORWARD -i tun0 -j ACCEPT
iptables -I FORWARD -o tun0 -j ACCEPT

Was will ich?
Am liebsten wärs mir, wenn sämtlicher Traffic der an venet0:0 (WAN-Interface vom Root)ankommt gleich ans VPN-Interface weitergereicht wird und umgekehrt. Läuft eh nix anderes aufm Server im Moment, darum würde mir erstmal ne Quick'n'Dirty-Lösung reichen.

Wenn das nicht so einfach gehen sollte geht, bräuchte ich mindestens ich die folgenden Ports:
29000 - 30000
20000 - 21000
9000 - 9999
Battelfield 3 Ports?

Danke schonmal, wär nett wenn mir einer ne halbwegs fertige Lösung anbieten könnte :-)

mfg
 
Zuletzt bearbeitet:
ok, dann nicht O.o
Es hat sich herausgestellt, das es an mindestens einem fehlenden iptables_modul im virtuellen Kernel liegt...

Habs mittlwerweile über meinen HTPC mit Kernel 3.x und Ubuntu 11 laufen, da funzt alles.

Was ich durch Zufall gesehen habe, aber nur für Linux-Clients interessant: https://github.com/apenwarr/sshuttle

mfg
 
Hab doch ein kleines Problem:
Was muss ich machen, um auf dem Server, auf dem der OpenVPN Server läuft, zu einem Dienst zu verbinden?

Mal als Beispiel: VPN-Verbindung läuft über Rechner mit IP 1.2.3.4 und auf dem gleiche Rechner läuft meinetwegen ein SSH Server auf Port 22. Wenn ich jetzt versuche auf 1.2.3.4:22 zu connecten, gibts nur nen Timeout.

Muss ich da noch was routen?

mfg
 
hatte es mittlerweile unter Windows hinbekommen, jetzt sitz ich mit meinem Backtrack wieder vor einem Problem:
Mit der hier geposteten CFG läufts zwar unter Windows, aber nicht unter Linux :-(
Server OS: Debian 6
Client OS: Backtrack 5 R3 (Ubuntu Lucid @ Kernel 3.2.6)

Also, gleiches Problem, anderes OS: VPN-Verbindung ins Inet steht, Verbindungen zur VPN-Host-IP funktionieren nicht, da das falsche Gateway gesetzt wird.

Das Problem:
Code:
uk3k@bt:~$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.10.9.5       128.0.0.0       UG    0      0        0 tun0
0.0.0.0         192.168.7.1     0.0.0.0         UG    100    0        0 eth0
10.10.9.0       10.10.9.5       255.255.255.0   UG    0      0        0 tun0
10.10.9.5       0.0.0.0         255.255.255.255 UH    0      0        0 tun0
85.xx.xx.xx  192.168.7.1     255.255.255.255 UGH   0      0        0 eth0
128.0.0.0       10.10.9.5       128.0.0.0       UG    0      0        0 tun0
192.168.7.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
--> 85.xx.xx.xx 192.168.7.1 255.255.255.255 UGH 0 0 0 eth0
--> aller traffic zur Host-IP (auf der ua mein TS3 läuft wird nicht! durch den VPN-Tunnel geschickt, sondern direkt und funktioniert somit nicht, da ohne VPN die erforderlichen Ports nicht offen sind :-(

Server-CFG:
Code:
port 22
proto tcp
dev tun

ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/mainserver.uk3k.crt
key /etc/openvpn/easy-rsa/keys/mainserver.uk3k.key
dh /etc/openvpn/easy-rsa/keys/dh2048.pem
tls-auth /etc/openvpn/easy-rsa/keys/ta.key 0

server 10.10.9.0 255.255.255.0
ifconfig-pool-persist /etc/openvpn/ipp.txt
keepalive 10 120
comp-lzo
user nobody
persist-key
persist-tun
resolv-retry infinite

push "redirect-gateway def1"
push "dhcp-option DNS 62.4.64.86"
push "dhcp-option DNS 62.26.185.2"

client-to-client
max-clients 5

status openvpn-status.log
log vpn.

Client-CFG:
Code:
client
dev tun
proto tcp
remote 85.xx.xx.xx
resolv-retry infinite
nobind
persist-key
persist-tun
comp-lzo
verb 3
mute 20

redirect-gateway def1

ca /home/uk3k/openvpn/uk3k.mainserver/ca.crt
cert /home/uk3k/openvpn/uk3k.mainserver/uk3k.crt
key /home/uk3k/openvpn/uk3k.mainserver/uk3k.key

ns-cert-type server
tls-auth /home/uk3k/openvpn/uk3k.mainserver/ta.key 1

OpenVPN-Output nach erfolgreicher Verbindung:
Code:
Sat Sep  1 14:10:42 2012 OpenVPN 2.1.0 x86_64-pc-linux-gnu [SSL] [LZO2] [EPOLL] [PKCS11] [MH] [PF_INET6] [eurephia] built on Jul 20 2010
Sat Sep  1 14:10:42 2012 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables
Sat Sep  1 14:10:42 2012 WARNING: file '/home/uk3k/openvpn/uk3k.mainserver/uk3k.key' is group or others accessible
Sat Sep  1 14:10:42 2012 /usr/bin/openssl-vulnkey -q -b 2048 -m <modulus omitted>
Sat Sep  1 14:10:42 2012 WARNING: file '/home/uk3k/openvpn/uk3k.mainserver/ta.key' is group or others accessible
Sat Sep  1 14:10:42 2012 Control Channel Authentication: using '/home/uk3k/openvpn/uk3k.mainserver/ta.key' as a OpenVPN static key file
Sat Sep  1 14:10:42 2012 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
Sat Sep  1 14:10:42 2012 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
Sat Sep  1 14:10:42 2012 LZO compression initialized
Sat Sep  1 14:10:42 2012 Control Channel MTU parms [ L:1544 D:168 EF:68 EB:0 ET:0 EL:0 ]
Sat Sep  1 14:10:42 2012 Data Channel MTU parms [ L:1544 D:1450 EF:44 EB:135 ET:0 EL:0 AF:3/1 ]
Sat Sep  1 14:10:42 2012 Local Options hash (VER=V4): 'ee93268d'
Sat Sep  1 14:10:42 2012 Expected Remote Options hash (VER=V4): 'bd577cd1'
Sat Sep  1 14:10:42 2012 Attempting to establish TCP connection with [AF_INET]85.xx.xx.xx [nonblock]
Sat Sep  1 14:10:43 2012 TCP connection established with [AF_INET]85.xx.xx.xx
Sat Sep  1 14:10:43 2012 Socket Buffers: R=[87380->131072] S=[24040->131072]
Sat Sep  1 14:10:43 2012 TCPv4_CLIENT link local: [undef]
Sat Sep  1 14:10:43 2012 TCPv4_CLIENT link remote: [AF_INET]85.xx.xx.xx:22
Sat Sep  1 14:10:43 2012 TLS: Initial packet from [AF_INET]85.xx.xx.xx:22, sid=32ade74a f1e2cf4e
Sat Sep  1 14:10:43 2012 VERIFY OK: depth=1, /C=DE/ST=DE/L=Dusseldorf/O=xxxx_VPN_Main/CN=uk3k.de_VPN_Main_CA/emailAddress=xxx
Sat Sep  1 14:10:43 2012 VERIFY OK: nsCertType=SERVER
Sat Sep  1 14:10:43 2012 VERIFY OK: depth=0, /C=DE/ST=DE/L=Dusseldorf/O=xxxx_VPN_Main/CN=mainserver.uk3k/emailAddress=xxxx
Sat Sep  1 14:10:45 2012 Data Channel Encrypt: Cipher 'BF-CBC' initialized with 128 bit key
Sat Sep  1 14:10:45 2012 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Sat Sep  1 14:10:45 2012 Data Channel Decrypt: Cipher 'BF-CBC' initialized with 128 bit key
Sat Sep  1 14:10:45 2012 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Sat Sep  1 14:10:45 2012 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 2048 bit RSA
Sat Sep  1 14:10:45 2012 [mainserver.uk3k] Peer Connection Initiated with [AF_INET]85.xx.xx.xx:22
Sat Sep  1 14:10:47 2012 SENT CONTROL [mainserver.uk3k]: 'PUSH_REQUEST' (status=1)
Sat Sep  1 14:10:47 2012 PUSH: Received control message: 'PUSH_REPLY,redirect-gateway def1,dhcp-option DNS 62.4.64.86,dhcp-option DNS 62.26.185.2,route 10.10.9.0 255.255.255.0,topology net30,ping 10,ping-restart 120,ifconfig 10.10.9.6 10.10.9.5'
Sat Sep  1 14:10:47 2012 OPTIONS IMPORT: timers and/or timeouts modified
Sat Sep  1 14:10:47 2012 OPTIONS IMPORT: --ifconfig/up options modified
Sat Sep  1 14:10:47 2012 OPTIONS IMPORT: route options modified
Sat Sep  1 14:10:47 2012 OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified
Sat Sep  1 14:10:47 2012 ROUTE default_gateway=192.168.7.1
Sat Sep  1 14:10:47 2012 TUN/TAP device tun0 opened
Sat Sep  1 14:10:47 2012 TUN/TAP TX queue length set to 100
Sat Sep  1 14:10:47 2012 /sbin/ifconfig tun0 10.10.9.6 pointopoint 10.10.9.5 mtu 1500
Sat Sep  1 14:10:47 2012 /sbin/route add -net 85.xx.xx.xx netmask 255.255.255.255 gw 192.168.7.1
Sat Sep  1 14:10:47 2012 /sbin/route add -net 0.0.0.0 netmask 128.0.0.0 gw 10.10.9.5
Sat Sep  1 14:10:47 2012 /sbin/route add -net 128.0.0.0 netmask 128.0.0.0 gw 10.10.9.5
Sat Sep  1 14:10:47 2012 /sbin/route add -net 10.10.9.0 netmask 255.255.255.0 gw 10.10.9.5
Sat Sep  1 14:10:47 2012 Initialization Sequence Completed

Könnte mir bitte mal jemand unter die Arme greifen? Fehlt doch nur eine Route oder?

Oder liegts daran: ROUTE default_gateway=192.168.7.1
-->was dagegen tun?

mfg
 

Ähnliche Themen

OpenVPN traffic redirect

Openvpn will nicht

OpenVPN - Server kann clients nicht erreichen.

openvpn auf debian eingerichtet, probleme mit iptables und routing

openvpn bridged mode

Zurück
Oben