Client fails to connect first time when using DDNS
Posted: Fri Feb 18, 2011 9:45 pm
I'm using a tun/UDP server/client configuration both with dynamic IPs. I have port forwarding properly configured on my router, and a No-IP updater installed on the server with the correct public IP address identified.
If I use the server's local IP address in my client's remote statement (i.e. remote #.#.#.#), the client connects to the server flawlessly every time. However, if I use the DDNS address in the client's remote statement (i.e. remote myServer.no-ip.org), then the first time I try to connect the client to the server it will fail, regardless of whether I place the client on the local network or a remote network.
I then have to either disconnect and reconnect, or wait for the client to attempt to reconnect automatically. After that everything works fine.
This is the relevant part of my client config file:
dev tun
proto udp
tun-mtu 1500
comp-lzo
client
port XXXX
remote myServer.no-ip.org XXXX #server's local IP works fine if client is on same subnet
float
keepalive 10 300
resolv-retry infinite
auth SHA
cipher BF-CBC
tls-cipher EXP-DES-CBC-SHA
tls-auth "ta.key" 1
tls-client
... and the relevant part of the server config:
dev tun
dev-node ServerTAP
proto udp
tun-mtu 1500
comp-lzo
server 10.10.10.0 255.255.255.248
port XXXX
ifconfig-pool-persist "ipp.txt"
float
keepalive 10 300
auth SHA
cipher BF-CBC
tls-cipher EXP-DES-CBC-SHA
tls-auth "ta.key" 0
tls-server
This is a portion of the client log file at the point the failed connection occurs:
Fri Feb 18 05:11:47 2011 LZO compression initialized
Fri Feb 18 05:11:48 2011 UDPv4 link local (bound): [undef]:XXXX
Fri Feb 18 05:11:48 2011 UDPv4 link remote: X.X.X.X:XXXX
Fri Feb 18 05:12:48 2011 TLS Error: TLS key negotiation failed to occur within 60 seconds (check your network connectivity)
Fri Feb 18 05:12:48 2011 TLS Error: TLS handshake failed
Fri Feb 18 05:12:48 2011 SIGUSR1[soft,tls-error] received, process restarting
and this is from the server log:
Fri Feb 18 05:10:58 2011 Sleeping for 10 seconds...
Fri Feb 18 05:11:08 2011 Successful ARP Flush on interface [262149] {58F8A3ED-D779-454C-AF11-3E22C63FC399}
Fri Feb 18 05:11:08 2011 UDPv4 link local (bound): [undef]:XXXX
Fri Feb 18 05:11:08 2011 UDPv4 link remote: [undef]
Fri Feb 18 05:11:08 2011 Initialization Sequence Completed
Fri Feb 18 05:11:42 2011 X.X.X.X:XXXX Re-using SSL/TLS context
Fri Feb 18 05:11:42 2011 X.X.X.X:XXXX LZO compression initialized
Fri Feb 18 05:12:42 2011 X.X.X.X:XXXX TLS Error: TLS key negotiation failed to occur within 60 seconds (check your network connectivity)
Fri Feb 18 05:12:42 2011 X.X.X.X:XXXX TLS Error: TLS handshake failed
Fri Feb 18 05:12:45 2011 Y.Y.Y.Y:YYYY Re-using SSL/TLS context
Fri Feb 18 05:12:45 2011 Y.Y.Y.Y:YYYY LZO compression initialized
Fri Feb 18 05:12:47 2011 Y.Y.Y.Y:YYYY [VPN-Client] Peer Connection Initiated with Y.Y.Y.Y:YYYY
I've changed my actual IPs and ports to X's and Y's, but the X's represent the public IP address of the server, and the Y's represent the IP address of the client.
This happens regardless of whether the client is physically located inside the local network or outside on another network. Subsequent reconnects succeed without any problems. It's a minor annoyance, but I'd like to resolve it if possible.
If I use the server's local IP address in my client's remote statement (i.e. remote #.#.#.#), the client connects to the server flawlessly every time. However, if I use the DDNS address in the client's remote statement (i.e. remote myServer.no-ip.org), then the first time I try to connect the client to the server it will fail, regardless of whether I place the client on the local network or a remote network.
I then have to either disconnect and reconnect, or wait for the client to attempt to reconnect automatically. After that everything works fine.
This is the relevant part of my client config file:
dev tun
proto udp
tun-mtu 1500
comp-lzo
client
port XXXX
remote myServer.no-ip.org XXXX #server's local IP works fine if client is on same subnet
float
keepalive 10 300
resolv-retry infinite
auth SHA
cipher BF-CBC
tls-cipher EXP-DES-CBC-SHA
tls-auth "ta.key" 1
tls-client
... and the relevant part of the server config:
dev tun
dev-node ServerTAP
proto udp
tun-mtu 1500
comp-lzo
server 10.10.10.0 255.255.255.248
port XXXX
ifconfig-pool-persist "ipp.txt"
float
keepalive 10 300
auth SHA
cipher BF-CBC
tls-cipher EXP-DES-CBC-SHA
tls-auth "ta.key" 0
tls-server
This is a portion of the client log file at the point the failed connection occurs:
Fri Feb 18 05:11:47 2011 LZO compression initialized
Fri Feb 18 05:11:48 2011 UDPv4 link local (bound): [undef]:XXXX
Fri Feb 18 05:11:48 2011 UDPv4 link remote: X.X.X.X:XXXX
Fri Feb 18 05:12:48 2011 TLS Error: TLS key negotiation failed to occur within 60 seconds (check your network connectivity)
Fri Feb 18 05:12:48 2011 TLS Error: TLS handshake failed
Fri Feb 18 05:12:48 2011 SIGUSR1[soft,tls-error] received, process restarting
and this is from the server log:
Fri Feb 18 05:10:58 2011 Sleeping for 10 seconds...
Fri Feb 18 05:11:08 2011 Successful ARP Flush on interface [262149] {58F8A3ED-D779-454C-AF11-3E22C63FC399}
Fri Feb 18 05:11:08 2011 UDPv4 link local (bound): [undef]:XXXX
Fri Feb 18 05:11:08 2011 UDPv4 link remote: [undef]
Fri Feb 18 05:11:08 2011 Initialization Sequence Completed
Fri Feb 18 05:11:42 2011 X.X.X.X:XXXX Re-using SSL/TLS context
Fri Feb 18 05:11:42 2011 X.X.X.X:XXXX LZO compression initialized
Fri Feb 18 05:12:42 2011 X.X.X.X:XXXX TLS Error: TLS key negotiation failed to occur within 60 seconds (check your network connectivity)
Fri Feb 18 05:12:42 2011 X.X.X.X:XXXX TLS Error: TLS handshake failed
Fri Feb 18 05:12:45 2011 Y.Y.Y.Y:YYYY Re-using SSL/TLS context
Fri Feb 18 05:12:45 2011 Y.Y.Y.Y:YYYY LZO compression initialized
Fri Feb 18 05:12:47 2011 Y.Y.Y.Y:YYYY [VPN-Client] Peer Connection Initiated with Y.Y.Y.Y:YYYY
I've changed my actual IPs and ports to X's and Y's, but the X's represent the public IP address of the server, and the Y's represent the IP address of the client.
This happens regardless of whether the client is physically located inside the local network or outside on another network. Subsequent reconnects succeed without any problems. It's a minor annoyance, but I'd like to resolve it if possible.