1 (edytowany przez yatkha 2011-05-25 21:32:15)

Temat: openvpn konfiguracja

Mam dwa routery:
1) N16 ddwrt, server openvpn, hostname: gate01, 192.168.7.1 (serwer działa dobrze, korzystam z niego łącząc się Tunnelbick'em)
2) MR3420 openwrt, client openvpn, hostname: Gargoyle, 192.168.11.1

Nie potrafię poradzić sobie (chyba) z przekazywaniem pakietów. Proszę o pomoc.

Objawy:
root@gate01:~# ping 192.168.11.1
PING 192.168.11.1 (192.168.11.1): 56 data bytes
--- 192.168.11.1 ping statistics ---
11 packets transmitted, 0 packets received, 100% packet loss

ale

root@Gargoyle:~$ ping 192.168.7.1
PING 192.168.7.1 (192.168.7.1): 56 data bytes
64 bytes from 192.168.7.1: seq=0 ttl=64 time=95.104 ms
mimo że mogę pingować, nie mogę połączyć się z GUI

Załączam konfigurację obu routerów:
--------------------------------------------
root@Gargoyle:~$ iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
bw_ingress  all  --  anywhere             anywhere           
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere           
syn_flood  tcp  --  anywhere             anywhere            tcp flags:FIN,SYN,RST,ACK/SYN
input_rule  all  --  anywhere             anywhere           
input      all  --  anywhere             anywhere           

Chain FORWARD (policy DROP)
target     prot opt source               destination         
bw_ingress  all  --  anywhere             anywhere           
ingress_restrictions  all  --  anywhere             anywhere           
egress_restrictions  all  --  anywhere             anywhere           
zone_wan_MSSFIX  all  --  anywhere             anywhere           
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
forwarding_rule  all  --  anywhere             anywhere           
forward    all  --  anywhere             anywhere           
reject     all  --  anywhere             anywhere           

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere           
output_rule  all  --  anywhere             anywhere           
output     all  --  anywhere             anywhere           

root@Gargoyle:~$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.64.64.64     *               255.255.255.255 UH    0      0        0 3g-wan
192.168.66.1    192.168.66.5    255.255.255.255 UGH   0      0        0 tun0
192.168.66.5    *               255.255.255.255 UH    0      0        0 tun0
192.168.7.0     192.168.66.5    255.255.255.0   UG    0      0        0 tun0
192.168.11.0    *               255.255.255.0   U     0      0        0 br-lan
default         10.64.64.64     0.0.0.0         UG    0      0        0 3g-wan

--------------------------------------------

root@gate01:~# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:https
ACCEPT     0    --  anywhere             anywhere            state RELATED,ESTABLISHED
invalid    0    --  anywhere             anywhere            state INVALID
ACCEPT     0    --  anywhere             anywhere           
DROP       udp  --  anywhere             anywhere            udp dpt:route
ACCEPT     0    --  anywhere             anywhere           
ACCEPT     udp  --  anywhere             anywhere            udp dpt:1194
ACCEPT     0    --  anywhere             anywhere           
DROP       udp  --  anywhere             anywhere            udp dpt:route
ACCEPT     udp  --  anywhere             anywhere            udp dpt:route
logdrop    icmp --  anywhere             anywhere           
logdrop    igmp --  anywhere             anywhere           
ACCEPT     udp  --  anywhere             anywhere            udp dpt:5060
DROP       udp  --  anywhere             239.255.255.0/24    udp dpt:upnp
logdrop    0    --  anywhere             anywhere           

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
TCPMSS     tcp  --  anywhere             anywhere            tcp flags:SYN,RST/SYN TCPMSS clamp to PMTU
ACCEPT     0    --  anywhere             anywhere            state RELATED,ESTABLISHED
invalid    0    --  anywhere             anywhere            state INVALID
ACCEPT     0    --  anywhere             anywhere           
ACCEPT     0    --  anywhere             anywhere           
ACCEPT     0    --  anywhere             anywhere           
ACCEPT     0    --  anywhere             anywhere           
ACCEPT     0    --  192.168.66.0/24      anywhere           
ACCEPT     gre  --  192.168.7.0/24       anywhere           
ACCEPT     tcp  --  192.168.7.0/24       anywhere            tcp dpt:1723
ACCEPT     0    --  anywhere             anywhere           
ACCEPT     0    --  anywhere             anywhere           
logaccept  tcp  --  anywhere             192.168.7.42        tcp dpt:tproxy
logaccept  udp  --  anywhere             192.168.7.42        udp dpt:tproxy
logaccept  tcp  --  anywhere             192.168.7.44        tcp dpt:8082
logaccept  udp  --  anywhere             192.168.7.44        udp dpt:8082
logaccept  tcp  --  anywhere             192.168.7.46        tcp dpt:8083
logaccept  udp  --  anywhere             192.168.7.46        udp dpt:8083
logaccept  0    --  anywhere             anywhere            state NEW
logdrop    0    --  anywhere             anywhere           

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

root@gate01:~# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.12.1       *               255.255.255.255 UH    0      0        0 vlan2
192.168.66.2    *               255.255.255.255 UH    0      0        0 tun0
192.168.7.0     *               255.255.255.0   U     0      0        0 br0
192.168.66.0    192.168.66.2    255.255.255.0   UG    0      0        0 tun0
10.0.12.0       *               255.255.255.0   U     0      0        0 vlan2
169.254.0.0     *               255.255.0.0     U     0      0        0 br0
127.0.0.0       *               255.0.0.0       U     0      0        0 lo
default         10.0.12.1       0.0.0.0         UG    0      0        0 vlan2

Log po stronie klienta:
May 25 21:09:30 Gargoyle daemon.notice openvpn(sample_client)[2309]: OpenVPN 2.1.4 mips-openwrt-linux [SSL] [LZO2] [EPOLL] built on May 14 2011
May 25 21:09:30 Gargoyle daemon.warn openvpn(sample_client)[2309]: WARNING: No server certificate verification method has been enabled.  See http://openvpn.net/howto.html#mitm for more info.
May 25 21:09:30 Gargoyle daemon.warn openvpn(sample_client)[2309]: NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables
May 25 21:09:30 Gargoyle daemon.warn openvpn(sample_client)[2309]: WARNING: file '/etc/openvpn/client2.key' is group or others accessible
May 25 21:09:30 Gargoyle daemon.notice openvpn(sample_client)[2309]: Control Channel MTU parms [ L:1543 D:140 EF:40 EB:0 ET:0 EL:0 ]
May 25 21:09:30 Gargoyle daemon.notice openvpn(sample_client)[2309]: Socket Buffers: R=[87380->131072] S=[16384->131072]
May 25 21:09:30 Gargoyle daemon.notice openvpn(sample_client)[2309]: Data Channel MTU parms [ L:1543 D:1450 EF:43 EB:4 ET:0 EL:0 ]
May 25 21:09:30 Gargoyle daemon.notice openvpn(sample_client)[2309]: Attempting to establish TCP connection with xxx.xxx.xxx.xxx:443 [nonblock]
May 25 21:09:31 Gargoyle daemon.notice openvpn(sample_client)[2309]: TCP connection established with xxx.xxx.xxx.xxx:443
May 25 21:09:31 Gargoyle daemon.notice openvpn(sample_client)[2309]: TCPv4_CLIENT link local: [undef]
May 25 21:09:31 Gargoyle daemon.notice openvpn(sample_client)[2309]: TCPv4_CLIENT link remote: xxx.xxx.xxx.xxx:443
May 25 21:09:31 Gargoyle daemon.notice openvpn(sample_client)[2309]: TLS: Initial packet from xxx.xxx.xxx.xxx:443, sid=ba3b16a4 40ff7ac2
May 25 21:09:37 Gargoyle daemon.notice openvpn(sample_client)[2309]: VERIFY OK: depth=1, xxxxxxxx
May 25 21:09:37 Gargoyle daemon.notice openvpn(sample_client)[2309]: VERIFY OK: depth=0, xxxxxxxx
May 25 21:09:42 Gargoyle daemon.notice openvpn(sample_client)[2309]: Data Channel Encrypt: Cipher 'BF-CBC' initialized with 128 bit key
May 25 21:09:42 Gargoyle daemon.notice openvpn(sample_client)[2309]: Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
May 25 21:09:42 Gargoyle daemon.notice openvpn(sample_client)[2309]: Data Channel Decrypt: Cipher 'BF-CBC' initialized with 128 bit key
May 25 21:09:42 Gargoyle daemon.notice openvpn(sample_client)[2309]: Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
May 25 21:09:42 Gargoyle daemon.notice openvpn(sample_client)[2309]: Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 1024 bit RSA
May 25 21:09:42 Gargoyle daemon.notice openvpn(sample_client)[2309]: [server] Peer Connection Initiated with xxx.xxx.xxx.xxx:443
May 25 21:09:44 Gargoyle daemon.notice openvpn(sample_client)[2309]: SENT CONTROL [server]: 'PUSH_REQUEST' (status=1)
May 25 21:09:44 Gargoyle daemon.notice openvpn(sample_client)[2309]: PUSH: Received control message: 'PUSH_REPLY,route 192.168.7.0 255.255.255.0,route 192.168.66.1,topology net30,ping 10,ping-restart 120,ifconfig 192.168.66.6 192.168.66.5'
May 25 21:09:44 Gargoyle daemon.notice openvpn(sample_client)[2309]: OPTIONS IMPORT: timers and/or timeouts modified
May 25 21:09:44 Gargoyle daemon.notice openvpn(sample_client)[2309]: OPTIONS IMPORT: --ifconfig/up options modified
May 25 21:09:44 Gargoyle daemon.notice openvpn(sample_client)[2309]: OPTIONS IMPORT: route options modified
May 25 21:09:44 Gargoyle daemon.notice openvpn(sample_client)[2309]: TUN/TAP device tun0 opened
May 25 21:09:44 Gargoyle daemon.notice openvpn(sample_client)[2309]: TUN/TAP TX queue length set to 100
May 25 21:09:44 Gargoyle daemon.notice openvpn(sample_client)[2309]: /sbin/ifconfig tun0 192.168.66.6 pointopoint 192.168.66.5 mtu 1500
May 25 21:09:44 Gargoyle daemon.notice openvpn(sample_client)[2309]: /sbin/route add -net 192.168.7.0 netmask 255.255.255.0 gw 192.168.66.5
May 25 21:09:44 Gargoyle daemon.notice openvpn(sample_client)[2309]: /sbin/route add -net 192.168.66.1 netmask 255.255.255.255 gw 192.168.66.5
May 25 21:09:44 Gargoyle daemon.notice openvpn(sample_client)[2309]: Initialization Sequence Completed

2

Odp: openvpn konfiguracja

Dla uproszczenia sytuacji po obu stronach zrobiłem iptables -F i dodałem route:

root@gate01:~# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.12.1       *               255.255.255.255 UH    0      0        0 vlan2
192.168.66.2    *               255.255.255.255 UH    0      0        0 tun0
192.168.7.0     *               255.255.255.0   U     0      0        0 br0
192.168.66.0    192.168.66.2    255.255.255.0   UG    0      0        0 tun0
10.0.12.0       *               255.255.255.0   U     0      0        0 vlan2
192.168.11.0    192.168.66.2    255.255.255.0   UG    0      0        0 tun0
169.254.0.0     *               255.255.0.0     U     0      0        0 br0
127.0.0.0       *               255.0.0.0       U     0      0        0 lo
default         10.0.12.1       0.0.0.0         UG    0      0        0 vlan2


root@Gargoyle:~$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.64.64.64     *               255.255.255.255 UH    0      0        0 3g-wan
192.168.66.5    *               255.255.255.255 UH    0      0        0 tun0
192.168.7.0     192.168.66.5    255.255.255.0   UG    0      0        0 tun0
192.168.66.0    192.168.66.5    255.255.255.0   UG    0      0        0 tun0
192.168.11.0    *               255.255.255.0   U     0      0        0 br-lan
default         10.64.64.64     0.0.0.0         UG    0      0        0 3g-wan

ping Gargoyle -> gate01 OK
ping Gargoyle <- gate01 nie przechodzi

Konfiguracja serwera:
push "route 192.168.7.0 255.255.255.0"
server 192.168.66.0 255.255.255.0
port 443
dev tun0
proto tcp
keepalive 10 120
dh /tmp/openvpn/dh.pem
ca /tmp/openvpn/ca.crt
cert /tmp/openvpn/cert.pem
key /tmp/openvpn/key.pem
management localhost 5001
client-to-client

konfiguracja klienta:
config openvpn sample_client
        option enable 1
        option client 1
        option dev tun
        option proto tcp
        list remote "xxx.xxx.xxx.xxx 443"
        option resolv_retry infinite
        option nobind 1
        option persist_key 1
        option persist_tun 1
        option ca /etc/openvpn/ca.crt
        option cert /etc/openvpn/client2.crt
        option key /etc/openvpn/client2.key
        option verb 4

Może ktoś pomóc?

3

Odp: openvpn konfiguracja

Po zainstalowaniu BF to samo, co na GargoylePL.
Skrajne wyczerpanie mnie dopadło, dlatego proszę o konkretne instrukcje (iptables, route, i inne wymagane),
jakie powinienem zrobić na czystej instalacji, żeby kilent openvpn połączył się do serwera.
Może coś przeoczyłem i kręcę się w koło...

4 (edytowany przez yatkha 2011-05-26 20:07:42)

Odp: openvpn konfiguracja

Wyłączyłem po obu stronach wf i nadal źle:
ping z klienta do servera i sieci za nim - OK.
ping z servera do klinta i sieci za nim - nie przechodzi.

iptables -I FORWARD -j ACCEPT
iptables -I INPUT -j ACCEPT

Co muszę skonfigurować jeszcze na kliencie oprócz openvpn.conf i cert?
A może jeszcze coś trzeba nagrzebać w po stornie serwera, żeby szło w drugą stronę?

5

Odp: openvpn konfiguracja

a 'route' dodac po stronie kliena probowales?

ZyXEL NBG6716 (Gargoyle by obsy)

6

Odp: openvpn konfiguracja

Zagadnienie ciekawe, ale już rozwiązane: client-config-dir ccd.
Co prawda jeszcze nie wszystko działa, tak jakbym chciał, ale mam już punkt zaczepienia.

Może ktoś będzie potrzebował i nie będzie miał czasu na szukanie:
http://openvpn.net/index.php/open-sourc … html#scope
"Expanding the scope of the VPN to include additional machines on either the client or server subnet"