Hallo,
Ich versuche openvpn zum laufen zu bekommen. Die Anmeldung funktioniert gut, nur ich denke ich habe irgendeinen Fehler im Routing bzw. dem NAT drin.
ich komme z.B. auf den lokalen ssh-Server drauf (eth0-ip [192.168.0.5:22]), aber nicht auf den ebenfalls lokalen https-Server (192.168.0.5:443), auch sftp, welches über den SSH-Server läuft ([192.168.0.5:22]) funktioniert nicht 😲 .
zur Client-Anmeldung nutze ich die Android-App "Openvpn für Android" über einen Hotspot (Telekom).
in den IPtables habe ich das Logging eingeschaltet, aber es wird nichts relevantes gedroppt...daher gehe ich von einem routing/NAT-Fehler aus
hier mal meine Tables:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | Chain INPUT (policy DROP 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 48 2852 ABGELEHNT tcp -- ppp0 any anywhere anywhere tcp dpt:ssh state NEW recent: UPDATE seconds: 60 hit_count: 4 name: DEFAULT side: source 131 7144 tcp -- ppp0 any anywhere anywhere tcp dpt:ssh state NEW recent: SET name: DEFAULT side: source 1 68 ACCEPT all -- lo any anywhere anywhere 379K 457M ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED 26 958 ACCEPT icmp -- any any anywhere anywhere limit: avg 5/sec burst 5 icmp echo-request 141 7724 ACCEPT tcp -- any any anywhere anywhere tcp dpt:ssh 53 2857 ACCEPT tcp -- any any anywhere anywhere tcp dpt:https 3596 258K ACCEPT all -- eth0 any anywhere anywhere 2 84 ACCEPT udp -- any any anywhere anywhere udp dpt:openvpn 3 180 ACCEPT all -- tun0 any anywhere anywhere 29909 978K ACCEPT all -- wlan0 any anywhere anywhere 1266 86366 ABGELEHNT all -- any any anywhere anywhere Chain FORWARD (policy DROP 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 0 0 ABGELEHNT all -- any ppp0 anywhere anywhere source IP range 192.168.0.100-192.168.0.254 0 0 ABGELEHNT all -- any ppp0 anywhere anywhere source IP range 192.168.2.100-192.168.2.254 0 0 ABGELEHNT all -- any ppp0 anywhere anywhere source IP range 192.168.5.100-192.168.5.254 0 0 ABGELEHNT ipv6 -- any any anywhere anywhere 0 0 ABGELEHNT ipv6-route-- any any anywhere anywhere 0 0 ABGELEHNT ipv6-frag-- any any anywhere anywhere 0 0 ABGELEHNT ipv6-icmp-- any any anywhere anywhere 0 0 ABGELEHNT ipv6-nonxt-- any any anywhere anywhere 0 0 ABGELEHNT ipv6-opts-- any any anywhere anywhere 0 0 ACCEPT tcp -- any any anywhere anywhere tcp dpt:ssh 74139 11M ACCEPT tcp -- any any anywhere anywhere tcp dpt:https 6646 872K ACCEPT all -- eth0 ppp0 anywhere anywhere 34465 32M ACCEPT all -- ppp0 eth0 anywhere anywhere state RELATED,ESTABLISHED 396 33401 ACCEPT all -- tun0 any anywhere anywhere 715 555K ACCEPT all -- any tun0 anywhere anywhere 0 0 ACCEPT all -- eth0 eth1 anywhere anywhere 0 0 ACCEPT all -- eth1 eth0 anywhere anywhere state RELATED,ESTABLISHED 0 0 ACCEPT all -- wlan0 eth1 anywhere anywhere 0 0 ACCEPT all -- eth1 wlan0 anywhere anywhere state RELATED,ESTABLISHED 14805 1408K ACCEPT all -- wlan0 ppp0 anywhere anywhere 84313 65M ACCEPT all -- ppp0 wlan0 anywhere anywhere state RELATED,ESTABLISHED 0 0 ACCEPT all -- wlan0 eth0 anywhere anywhere 0 0 ACCEPT all -- eth0 wlan0 anywhere anywhere 0 0 ABGELEHNT all -- any any anywhere anywhere Chain OUTPUT (policy DROP 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 2 136 ACCEPT all -- any lo anywhere anywhere 260K 31M ACCEPT all -- any any anywhere anywhere 0 0 ACCEPT all -- any tun0 anywhere anywhere 0 0 ABGELEHNT all -- any any anywhere anywhere Chain ABGELEHNT (13 references) pkts bytes target prot opt in out source destination 1288 87738 LOG all -- any any anywhere anywhere limit: avg 10/min burst 5 LOG level warning prefix "NETFILTER4-ABGELEHNT: " 1151 54890 REJECT tcp -- any any anywhere anywhere reject-with tcp-reset 146 31398 REJECT udp -- any any anywhere anywhere reject-with icmp-port-unreachable 17 2930 DROP all -- any any anywhere anywhere |
edit: mal noch die NAT-Regeln:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | Chain PREROUTING (policy ACCEPT 18065 packets, 1074K bytes) pkts bytes target prot opt in out source destination 0 0 DNAT tcp -- any any anywhere anywhere tcp dpt:222 to:192.168.0.1:22 0 0 DNAT tcp -- any any anywhere anywhere tcp dpt:2443 to:192.168.0.1:443 Chain INPUT (policy ACCEPT 6280 packets, 412K bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 8340 packets, 679K bytes) pkts bytes target prot opt in out source destination Chain POSTROUTING (policy ACCEPT 26 packets, 7952 bytes) pkts bytes target prot opt in out source destination 13413 949K MASQUERADE all -- any ppp0 anywhere anywhere 0 0 MASQUERADE all -- any tun0 anywhere anywhere 0 0 MASQUERADE all -- any eth1 anywhere anywhere |
die zeilen aus meinem Script Openvpn-relevant:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #openvpn #${ipt} -A FORWARD -o eth0 -i tun0 -s 10.8.0.0/24 -m conntrack --ctstate NEW -j ACCEPT #${ipt} -A FORWARD -i tun0 -s 10.8.0.0/24 -m conntrack --ctstate NEW -j ACCEPT #${ipt} -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT ${ipt} -A INPUT -p udp --dport 1194 -j ACCEPT #openvpn eingehend #${ipt} -A FORWARD -i eth0 -o tun0 -m state --state ESTABLISHED,RELATED -j ACCEPT #${ipt} -A FORWARD -s 10.8.0.0/24 -o eth0 -j ACCEPT #${ipt} -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE #${ipt} -t nat -A POSTROUTING -o eth0 -j MASQUERADE ${ipt} -t nat -A POSTROUTING -o tun0 -j MASQUERADE ${ipt} -A INPUT -i tun0 -j ACCEPT ${ipt} -A OUTPUT -o tun0 -j ACCEPT ${ipt} -A FORWARD -i tun0 -j ACCEPT ${ipt} -A FORWARD -o tun0 -j ACCEPT |
prinzipiell möchte ich vom Client ins Intranet und Intranet (192.168.x.x). deswegen habe testhalber den Traffic von/zum tun-device komplett freigegeben und das NAT auf das tun aufgesetzt, statt wie im Wiki auf die ethernet-Schnittstelle.
prinzipell gibt es eth0 (LAN), eth1 (Schnittstelle zum DSL-Modem), PPP0 (Internet-Einwahl) und wlan0
zwischen lan/wlan/ppp0 funktioniert alles fehlerfrei...habe nur für openvpn die obigen Regeln ergänzt.
routen auf dem Server:
1 2 3 4 5 6 7 8 9 | default dev ppp0 scope link 10.8.0.0/24 via 10.8.0.2 dev tun0 10.8.0.2 dev tun0 proto kernel scope link src 10.8.0.1 192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.5 192.168.1.0/24 via 192.168.0.1 dev eth0 192.168.2.0/24 via 192.168.0.2 dev eth0 192.168.3.0/24 via 192.168.0.3 dev eth0 192.168.5.0/24 dev wlan0 proto kernel scope link src 192.168.5.1 217.0.x.x dev ppp0 proto kernel scope link src <internet-ip> |
anhand der Seite http://wiki.nefarius.at/linux/mit_openvpn_ins_internet habe ich noch mit Client-optionen wie redirect-gateway etc. rumprobiert, aber ohne Erfolg...config habe ich angehängt
Meiner Meinung nach müsste es eigentlich funktionieren, aber bin nicht ganz so der Profi mit NAT/PAT/DNAT ☺
Gruß Frank