Debian Openvpn masquerade

Serverdienste ohne eigene Kategorie
termi11
Posts: 34
Joined: 2004-05-10 10:07
Location: Luxemburg
 

Debian Openvpn masquerade

Post by termi11 »

Hallo,
ich versuche seit einigen Tagen auf meinem root Server nen Openvpn zu installieren.
Bei mir, auf einem Rechner hinter einer Fritzbox läuft das Ganze super.
Jedoch krieg ich's auf dem root Server nicht hin.
VPN Verbindung baut sich auf.
eth0 = static ip beim provider
Traffic wird vom vpn client auf das tun0 interface gesendet.
Traffic geht auch über die eth0 raus, und die Antwort kommt zur eth0 zurück. (tcpdump!)
Jedoch wird dann der Traffic nicht zur tun0 bzw dem vpn client weiter geleitet:

Code: Select all

 iptables -L -n -v
Chain INPUT (policy ACCEPT 774 packets, 178K bytes)
 pkts bytes target     prot opt in     out     source               destination
   54  7036 ACCEPT     tcp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           tcp dpt:1195

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
   52  2721 ACCEPT     all  --  *      eth0    192.168.200.0/24     0.0.0.0/0
    0     0 ACCEPT     all  --  eth0   tun0    0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED

Chain OUTPUT (policy ACCEPT 282 packets, 83271 bytes)
 pkts bytes target     prot opt in     out     source               destination
   55  2365 ACCEPT     tcp  --  *      eth0    0.0.0.0/0            0.0.0.0/0           tcp spt:1195

Code: Select all

iptables -L -n -v -t nat
Chain PREROUTING (policy ACCEPT 128 packets, 10091 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain POSTROUTING (policy ACCEPT 17 packets, 1303 bytes)
 pkts bytes target     prot opt in     out     source               destination
   25  1357 MASQUERADE  all  --  *      eth0    192.168.200.0/24     0.0.0.0/0

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

Code: Select all

 route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.200.2   0.0.0.0         255.255.255.255 UH    0      0        0 tun0
192.168.200.0   192.168.200.2   255.255.255.0   UG    0      0        0 tun0
public network 0.0.0.0         255.255.255.0   U     0      0        0 eth0
0.0.0.0      public_network_gw       0.0.0.0         UG    0      0        0 eth0

Code: Select all

cat /proc/sys/net/ipv4/ip_forward
1
Server config:

Code: Select all

dev tun
proto tcp-server
comp-lzo
port 1195
#mode server
ifconfig-pool-persist ipp.txt
server 192.168.200.0 255.255.255.0
push "route 192.168.200.0 255.255.255.0"
push "redirect-gateway def1"
push "dhcp-option DNS 8.8.8.8"
keepalive 10 120
max-clients 5
user nobody
group nogroup
status /var/log/openvpn-status.log
log-append  /var/log/openvpn.log
verb 3
mute 10
ca /etc/openvpn/ca.crt
cert /etc/openvpn/server.crt
key /etc/openvpn/server.key 
dh /etc/openvpn/dh1024.pem
#tls-server
persist-key
persist-tun
tls-auth ta.key 0
#client-to-client
#chroot /tmp
#mssfix 1200

Code: Select all

eth0      Link encap:Ethernet  HWaddr 00:19:99:b2:44:a0
          inet addr:pub_ip  Bcast:pub_net  Mask:255.255.255.0
          inet6 addr: xxxxxxx/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:622790856 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1174283411 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:61040511529 (56.8 GiB)  TX bytes:1730264148513 (1.5 TiB)
          Interrupt:18

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:10819002 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10819002 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3445759831 (3.2 GiB)  TX bytes:3445759831 (3.2 GiB)

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:192.168.200.1  P-t-P:192.168.200.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)

Hat jemand ne Idee was hier nicht stimmt?

Besten Dank im Voraus!
Last edited by termi11 on 2013-04-05 18:16, edited 1 time in total.
termi11
Posts: 34
Joined: 2004-05-10 10:07
Location: Luxemburg
 

Re: Debian Openvpn nat

Post by termi11 »

Hab noch etwas rumgebastelt.
Was mir aufgefallen ist (kann sein dass ich falsch liege mit meiner Vermutung):

tun0 Verbindung ist aufgebaut:
Ist beim ifconfig client die P-t-p Adresse nicht falsch? Müsste doch die 192.168.200.1 sein ?
Ping funktioniert aber gegenseitig.

Code: Select all

Ping vom server aus
ping -c 1 192.168.200.1 -> sich selbst
PING 192.168.200.1 (192.168.200.1) 56(84) bytes of data.
64 bytes from 192.168.200.1: icmp_req=1 ttl=64 time=0.038 ms

ping -c 1 192.168.200.6 -> client
PING 192.168.200.6 (192.168.200.6) 56(84) bytes of data.
64 bytes from 192.168.200.6: icmp_req=1 ttl=64 time=27.2 ms
ifconfig server

Code: Select all

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:192.168.200.1  P-t-P:192.168.200.2  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:504 (504.0 B)  TX bytes:924 (924.0 B)

Code: Select all

Vom client aus:
root@test1:~# ping -c 1 192.168.200.6 -> sich selbst
PING 192.168.200.6 (192.168.200.6) 56(84) bytes of data.
64 bytes from 192.168.200.6: icmp_req=1 ttl=64 time=0.015 ms

root@test1:~# ping -c 1 192.168.200.1 -> den server
PING 192.168.200.1 (192.168.200.1) 56(84) bytes of data.
64 bytes from 192.168.200.1: icmp_req=1 ttl=64 time=28.4 ms
ifconfig client

Code: Select all

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:192.168.200.6  P-t-P:192.168.200.5  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:336 (336.0 B)  TX bytes:504 (504.0 B)