Hallo zusammen,
Es gibt zu diesem Thema schon genug Posts und Anleitungen, nur leider hilft mir keine weiter. Ich sitze nun schon 6 Tage Abends am Openvpn-Server, das ganze läuft auf einem Vserver. Es ist ein Ubuntu-Server 10.04 bei Strato.
Kurze Beschreibung:
Openvpn-Server läuft. Ich kann mich über den NM mit Openvpn-Plugin zum Server verbinden, bekomme auch eine IP zugewiesen, das Openvpn-Netz ist 10.8.0.0/24. Ping auf das Netzwerk 10.8.0.0/24, besser gesagt auf 10.8.0.1, geht nicht.
Ich möchte in erste Line die VPN Verbindung als Internet-Gateway nutzen.
UDP Port 1194 ist auf dem Server offen, Portforwarding vom Router/DSL Modem ankommend 1194 auf interne IP 192.168.178.10 Port 1194. Ein Nachteil von meinem Router (Speedport W723v B Version), ich kann keine statischen Routen setzen, falls sie denn für VPN gebraucht werden, was ich mir durchaus vorstellen könnte.
Nachfrage bei Strato wegen Tun/Tab, es würde gehn, da mir mit modprobe tun und lsmod nichts angezeigt wurde habe ich folgendes gemacht.
Tun Device angelegt:
sudo mkdir -p /dev/net sudo mknod /dev/net/tun c 10 200 sudo chmod 600 /dev/net/tun
Ifconfig auf dem Server gibt mir folgendes aus:
lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:52359 errors:0 dropped:0 overruns:0 frame:0 TX packets:52359 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:62758267 (62.7 MB) TX bytes:62758267 (62.7 MB) tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 inet addr:10.8.0.1 P-t-P:10.8.0.2 Mask:255.255.255.255 UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) venet0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 inet addr:127.0.0.1 P-t-P:127.0.0.1 Bcast:0.0.0.0 Mask:255.255.255.255 inet6 addr: ::1/128 Scope:Host UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1 RX packets:17546 errors:0 dropped:0 overruns:0 frame:0 TX packets:15159 errors:0 dropped:5 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:3091487 (3.0 MB) TX bytes:11065004 (11.0 MB) venet0:0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 inet addr:xx.xxx.xxx.179 P-t-P:xx.xxx.xxx.179 Bcast:0.0.0.0 Mask:255.255.255.255 UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1
In der Datei /etc/sysctl.conf ist Forwarding aktiv:
# Uncomment the next line to enable packet forwarding for IPv4 net.ipv4.ip_forward=1
Iptables iptables -L -nvx -t nat
Chain PREROUTING (policy ACCEPT 1097 packets, 112626 bytes) pkts bytes target prot opt in out source destination Chain POSTROUTING (policy ACCEPT 651 packets, 40754 bytes) pkts bytes target prot opt in out source destination 0 0 SNAT all -- * * 10.8.0.0/24 0.0.0.0/0 to:xx.xxx.xxx.179 Chain OUTPUT (policy ACCEPT 651 packets, 40754 bytes) pkts bytes target prot opt in out source destination
Server.conf:
;local a.b.c.d port 1194 proto udp dev tun ca ./easy-rsa/keys/ca.crt cert ./easy-rsa/keys/server.crt key ./easy-rsa/keys/server.key dh ./easy-rsa/keys/dh1024.pem server 10.8.0.0 255.255.255.0 ifconfig-pool-persist ipp.txt push "redirect-gateway def1 bypass-dhcp" push "dhcp-option DNS 8.8.8.8" push "dhcp-option DNS 208.67.220.220" keepalive 10 120 comp-lzo user openvpn1 group openvpn1 persist-key persist-tun status openvpn-status.log log openvpn.log log-append openvpn.log verb 3
Client config (für das Starten per Terminal) sudo openvpn --config client.conf
client remote xx.xxx.xxx.xxx 1194 # Hostname/externe IP und Port des Servers proto udp dev tun ca ca.crt cert ralf.crt key ralf.key ns-cert-type server comp-lzo verb 3 mute 50
Ausgabe:
Fri Dec 7 09:39:19 2012 OpenVPN 2.2.1 x86_64-linux-gnu [SSL] [LZO2] [EPOLL] [PKCS11] [eurephia] [MH] [PF_INET6] [IPv6 payload 20110424-2 (2.2RC2)] built on Oct 8 2012 Fri Dec 7 09:39:19 2012 IMPORTANT: OpenVPN's default port number is now 1194, based on an official port number assignment by IANA. OpenVPN 2.0-beta16 and earlier used 5000 as the default port. Fri Dec 7 09:39:19 2012 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables Fri Dec 7 09:39:19 2012 LZO compression initialized Fri Dec 7 09:39:19 2012 Control Channel MTU parms [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ] Fri Dec 7 09:39:19 2012 Socket Buffers: R=[212992->131072] S=[212992->131072] Fri Dec 7 09:39:19 2012 Data Channel MTU parms [ L:1542 D:1450 EF:42 EB:135 ET:0 EL:0 AF:3/1 ] Fri Dec 7 09:39:19 2012 Local Options hash (VER=V4): '41690919' Fri Dec 7 09:39:19 2012 Expected Remote Options hash (VER=V4): '530fdded' Fri Dec 7 09:39:19 2012 UDPv4 link local (bound): [undef] Fri Dec 7 09:39:19 2012 UDPv4 link remote: [AF_INET]xx.xxx.xxx.179:1194 Fri Dec 7 09:39:19 2012 TLS: Initial packet from [AF_INET]xxx.xxx.xxx.179:1194, sid=c3ce5075 549b0c28 Fri Dec 7 09:39:19 2012 VERIFY OK: depth=1, /C=DE/ST=xxxxx/L=xxxxxx/O=xxxxx/CN=xxxxx/emailAddress=xxxx@xxxx Fri Dec 7 09:39:19 2012 VERIFY OK: nsCertType=SERVER Fri Dec 7 09:39:19 2012 VERIFY OK: depth=0, /C=DE/ST=THR/L=Berlin/O=Fort-Funston/OU=xxxx/CN=xxxx/emailAddress=xxx@xxx.de Fri Dec 7 09:39:20 2012 Data Channel Encrypt: Cipher 'BF-CBC' initialized with 128 bit key Fri Dec 7 09:39:20 2012 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication Fri Dec 7 09:39:20 2012 Data Channel Decrypt: Cipher 'BF-CBC' initialized with 128 bit key Fri Dec 7 09:39:20 2012 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication Fri Dec 7 09:39:20 2012 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 1024 bit RSA Fri Dec 7 09:39:20 2012 [Webjab] Peer Connection Initiated with [AF_INET]xx.xxx.xxx.179:1194 Fri Dec 7 09:39:22 2012 SENT CONTROL [Webjab]: 'PUSH_REQUEST' (status=1) Fri Dec 7 09:39:22 2012 PUSH: Received control message: 'PUSH_REPLY,redirect-gateway def1 bypass-dhcp,dhcp-option DNS 8.8.8.8,dhcp-option DNS 208.67.220.220,route 10.8.0.1,topology net30,ping 10,ping-restart 120,ifconfig 10.8.0.6 10.8.0.5' Fri Dec 7 09:39:22 2012 OPTIONS IMPORT: timers and/or timeouts modified Fri Dec 7 09:39:22 2012 OPTIONS IMPORT: --ifconfig/up options modified Fri Dec 7 09:39:22 2012 OPTIONS IMPORT: route options modified Fri Dec 7 09:39:22 2012 OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified Fri Dec 7 09:39:22 2012 ROUTE default_gateway=192.168.178.1 Fri Dec 7 09:39:22 2012 TUN/TAP device tun0 opened Fri Dec 7 09:39:22 2012 TUN/TAP TX queue length set to 100 Fri Dec 7 09:39:22 2012 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0 Fri Dec 7 09:39:22 2012 /sbin/ifconfig tun0 10.8.0.6 pointopoint 10.8.0.5 mtu 1500 Fri Dec 7 09:39:22 2012 /sbin/route add -net xx.xxx.xxx.179 netmask 255.255.255.255 gw 192.168.178.1 Fri Dec 7 09:39:22 2012 /sbin/route add -net 0.0.0.0 netmask 128.0.0.0 gw 10.8.0.5 Fri Dec 7 09:39:22 2012 /sbin/route add -net 128.0.0.0 netmask 128.0.0.0 gw 10.8.0.5 Fri Dec 7 09:39:22 2012 /sbin/route add -net 10.8.0.1 netmask 255.255.255.255 gw 10.8.0.5 Fri Dec 7 09:39:22 2012 Initialization Sequence Completed
Auch habe ich schon Routen gesetzt, leider hat keine funktioniert, und wieder entfernt, Beispielen gefolgt von OpenVPN und Router (Abschnitt „Portweiterleitung“)
Update: Werde folgendes noch mal testen:
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -j SNAT --to xx.xxx.xxx.179
Ausgabe:
Chain POSTROUTING (policy ACCEPT 1093 packets, 69347 bytes) pkts bytes target prot opt in out source destination 0 0 SNAT all -- * * 10.8.0.0/24 0.0.0.0/0 to:xx.xxx.xxx.179 0 0 SNAT all -- * * 10.8.0.0/24 0.0.0.0/0 to:xx.xxx.xxx.179
Jetzt ist die Route zweimal drinnen:(
Ich habe keine Plan mehr, und der Kopf ist leer;)
Danke schon mal im Voraus,
MfG Ralf