Automatic fail over/load balancing fail in openvpn
Posted: Thu Sep 19, 2019 9:36 am
Hello Team,
I have created one openvpn server and create client key over this server. The client tunnel up is coming up and working fine. Then i created another server by coping the configuration of existing server over new server and change the virtual address IP pool according to below article:
https://openvpn.net/community-resources ... iguration/
In client.conf/ovpn file i used both server ip one by one and its working fine. Then i used both server ip together to achieve high availability and stop the openvpn service over one server. To test the automatic fail over. But client unable to connect with second server and below are the logs:
```
Sep 19 10:10:08 redismaster ovpn-rana[3361]: Connection reset, restarting [0]
Sep 19 10:10:08 redismaster ovpn-rana[3361]: SIGUSR1[soft,connection-reset] received, process restarting
Sep 19 10:10:08 redismaster ovpn-rana[3361]: Restart pause, 5 second(s)
Sep 19 10:10:13 redismaster ovpn-rana[3361]: NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
Sep 19 10:10:13 redismaster ovpn-rana[3361]: Socket Buffers: R=[87380->87380] S=[16384->16384]
Sep 19 10:10:13 redismaster ovpn-rana[3361]: Attempting to establish TCP connection with [AF_INET]first_server_ip:443 [nonblock]
Sep 19 10:10:14 redismaster ovpn-rana[3361]: TCP: connect to [AF_INET]first_server_ip:443 failed, will try again in 5 seconds: Connection refused
Sep 19 10:10:14 redismaster ovpn-rana[3361]: SIGUSR1[soft,init_instance] received, process restarting
Sep 19 10:10:14 redismaster ovpn-rana[3361]: Restart pause, 5 second(s)
Sep 19 10:10:19 redismaster ovpn-rana[3361]: NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
Sep 19 10:10:19 redismaster ovpn-rana[3361]: Socket Buffers: R=[87380->87380] S=[16384->16384]
Sep 19 10:10:19 redismaster ovpn-rana[3361]: Attempting to establish TCP connection with [AF_INET]second_server_ip:443 [nonblock]
Sep 19 10:10:20 redismaster ovpn-rana[3361]: TCP connection established with [AF_INET]second_server_ip:443
Sep 19 10:10:20 redismaster ovpn-rana[3361]: TCPv4_CLIENT link local: [undef]
Sep 19 10:10:20 redismaster ovpn-rana[3361]: TCPv4_CLIENT link remote: [AF_INET]second_server_ip:443
Sep 19 10:10:20 redismaster ovpn-rana[3361]: TLS: Initial packet from [AF_INET]second_server_ip, sid=ea7f416f 9a427c23
Sep 19 10:10:20 redismaster ovpn-rana[3361]: VERIFY OK: depth=1, C=IN, ST=MH, L=Pune, O=ABC Technology, OU=Community, CN=ABC Technology CA, name=Community, emailAddress=abc@xyz.com
Sep 19 10:10:20 redismaster ovpn-rana[3361]: Validating certificate key usage
Sep 19 10:10:20 redismaster ovpn-rana[3361]: ++ Certificate has key usage 00a0, expects 00a0
Sep 19 10:10:20 redismaster ovpn-rana[3361]: VERIFY KU OK
Sep 19 10:10:20 redismaster ovpn-rana[3361]: Validating certificate extended key usage
Sep 19 10:10:20 redismaster ovpn-rana[3361]: ++ Certificate has EKU (str) TLS Web Server Authentication, expects TLS Web Server Authentication
Sep 19 10:10:20 redismaster ovpn-rana[3361]: VERIFY EKU OK
Sep 19 10:10:20 redismaster ovpn-rana[3361]: VERIFY OK: depth=0, C=IN, ST=MH, L=Pune, O=Promobi Technology, OU=Community, CN=server, name=Community, emailAddress=abc@xyz.com
Sep 19 10:10:20 redismaster ovpn-rana[3361]: Data Channel Encrypt: Cipher 'AES-128-CBC' initialized with 128 bit key
Sep 19 10:10:20 redismaster ovpn-rana[3361]: Channel Encrypt: Using 256 bit message hash 'SHA256' for HMAC authentication
Sep 19 10:10:20 redismaster ovpn-rana[3361]: Data Channel Decrypt: Cipher 'AES-128-CBC' initialized with 128 bit key
Sep 19 10:10:20 redismaster ovpn-rana[3361]: Data Channel Decrypt: Using 256 bit message hash 'SHA256' for HMAC authentication
Sep 19 10:10:20 redismaster ovpn-rana[3361]: Control Channel: TLSv1.2, cipher TLSv1/SSLv3 DHE-RSA-AES256-GCM-SHA384, 2048 bit RSA
Sep 19 10:10:20 redismaster ovpn-rana[3361]: [server] Peer Connection Initiated with [AF_INET]first_server_ip:443
Sep 19 10:10:23 redismaster ovpn-rana[3361]: SENT CONTROL [server]: 'PUSH_REQUEST' (status=1)
Sep 19 10:10:23 redismaster ovpn-rana[3361]: PUSH: Received control message: 'PUSH_REPLY,redirect-gateway def1 bypass-dhcp,dhcp-option DNS 208.67.222.222,dhcp-option DNS 208.67.220.220,route 10.8.0.1,topology net30,ping 10,ping-restart 60,ifconfig 10.8.0.10 10.8.0.9'
Sep 19 10:10:23 redismaster ovpn-rana[3361]: OPTIONS IMPORT: timers and/or timeouts modified
Sep 19 10:10:23 redismaster ovpn-rana[3361]: OPTIONS IMPORT: --ifconfig/up options modified
Sep 19 10:10:23 redismaster ovpn-rana[3361]: OPTIONS IMPORT: route options modified
Sep 19 10:10:23 redismaster ovpn-rana[3361]: OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified
Sep 19 10:10:23 redismaster ovpn-rana[3361]: Preserving previous TUN/TAP instance: tun0
Sep 19 10:10:23 redismaster ovpn-rana[3361]: NOTE: Pulled options changed on restart, will need to close and reopen TUN/TAP device.
Sep 19 10:10:23 redismaster ovpn-rana[3361]: /sbin/ip route del 10.8.1.1/32
Sep 19 10:10:23 redismaster ovpn-rana[3361]: ERROR: Linux route delete command failed: external program exited with error status: 2
Sep 19 10:10:23 redismaster ovpn-rana[3361]: /sbin/ip route del 68.183.181.138/32
Sep 19 10:10:23 redismaster ovpn-rana[3361]: ERROR: Linux route delete command failed: external program exited with error status: 2
Sep 19 10:10:23 redismaster ovpn-rana[3361]: /sbin/ip route del 0.0.0.0/1
Sep 19 10:10:23 redismaster ovpn-rana[3361]: ERROR: Linux route delete command failed: external program exited with error status: 2
Sep 19 10:10:23 redismaster ovpn-rana[3361]: /sbin/ip route del 128.0.0.0/1
Sep 19 10:10:23 redismaster ovpn-rana[3361]: ERROR: Linux route delete command failed: external program exited with error status: 2
Sep 19 10:10:23 redismaster ovpn-rana[3361]: Closing TUN/TAP interface
Sep 19 10:10:23 redismaster ovpn-rana[3361]: /sbin/ip addr del dev tun0 local 10.8.1.6 peer 10.8.1.5
Sep 19 10:10:23 redismaster ovpn-rana[3361]: Linux ip addr del failed: external program exited with error status: 2
Sep 19 10:10:23 redismaster ovpn-rana[3361]: /etc/openvpn/update-resolv-conf tun0 1500 1572 10.8.1.6 10.8.1.5 init
Sep 19 10:10:23 redismaster ovpn-rana[3361]: WARNING: Failed running command (--up/--down): external program exited with error status: 1
Sep 19 10:10:23 redismaster ovpn-rana[3361]: Exiting due to fatal error
Sep 19 10:10:23 redismaster systemd[1]: openvpn@rana.service: Main process exited, code=exited, status=1/FAILURE
Sep 19 10:10:23 redismaster systemd[1]: openvpn@rana.service: Unit entered failed state.
Sep 19 10:10:23 redismaster systemd[1]: openvpn@rana.service: Failed with result 'exit-code'.
```
Can you please help me to fix this issue. What configuration changes are required at client end or server end?
Any help will be appreciated.
I have created one openvpn server and create client key over this server. The client tunnel up is coming up and working fine. Then i created another server by coping the configuration of existing server over new server and change the virtual address IP pool according to below article:
https://openvpn.net/community-resources ... iguration/
In client.conf/ovpn file i used both server ip one by one and its working fine. Then i used both server ip together to achieve high availability and stop the openvpn service over one server. To test the automatic fail over. But client unable to connect with second server and below are the logs:
```
Sep 19 10:10:08 redismaster ovpn-rana[3361]: Connection reset, restarting [0]
Sep 19 10:10:08 redismaster ovpn-rana[3361]: SIGUSR1[soft,connection-reset] received, process restarting
Sep 19 10:10:08 redismaster ovpn-rana[3361]: Restart pause, 5 second(s)
Sep 19 10:10:13 redismaster ovpn-rana[3361]: NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
Sep 19 10:10:13 redismaster ovpn-rana[3361]: Socket Buffers: R=[87380->87380] S=[16384->16384]
Sep 19 10:10:13 redismaster ovpn-rana[3361]: Attempting to establish TCP connection with [AF_INET]first_server_ip:443 [nonblock]
Sep 19 10:10:14 redismaster ovpn-rana[3361]: TCP: connect to [AF_INET]first_server_ip:443 failed, will try again in 5 seconds: Connection refused
Sep 19 10:10:14 redismaster ovpn-rana[3361]: SIGUSR1[soft,init_instance] received, process restarting
Sep 19 10:10:14 redismaster ovpn-rana[3361]: Restart pause, 5 second(s)
Sep 19 10:10:19 redismaster ovpn-rana[3361]: NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
Sep 19 10:10:19 redismaster ovpn-rana[3361]: Socket Buffers: R=[87380->87380] S=[16384->16384]
Sep 19 10:10:19 redismaster ovpn-rana[3361]: Attempting to establish TCP connection with [AF_INET]second_server_ip:443 [nonblock]
Sep 19 10:10:20 redismaster ovpn-rana[3361]: TCP connection established with [AF_INET]second_server_ip:443
Sep 19 10:10:20 redismaster ovpn-rana[3361]: TCPv4_CLIENT link local: [undef]
Sep 19 10:10:20 redismaster ovpn-rana[3361]: TCPv4_CLIENT link remote: [AF_INET]second_server_ip:443
Sep 19 10:10:20 redismaster ovpn-rana[3361]: TLS: Initial packet from [AF_INET]second_server_ip, sid=ea7f416f 9a427c23
Sep 19 10:10:20 redismaster ovpn-rana[3361]: VERIFY OK: depth=1, C=IN, ST=MH, L=Pune, O=ABC Technology, OU=Community, CN=ABC Technology CA, name=Community, emailAddress=abc@xyz.com
Sep 19 10:10:20 redismaster ovpn-rana[3361]: Validating certificate key usage
Sep 19 10:10:20 redismaster ovpn-rana[3361]: ++ Certificate has key usage 00a0, expects 00a0
Sep 19 10:10:20 redismaster ovpn-rana[3361]: VERIFY KU OK
Sep 19 10:10:20 redismaster ovpn-rana[3361]: Validating certificate extended key usage
Sep 19 10:10:20 redismaster ovpn-rana[3361]: ++ Certificate has EKU (str) TLS Web Server Authentication, expects TLS Web Server Authentication
Sep 19 10:10:20 redismaster ovpn-rana[3361]: VERIFY EKU OK
Sep 19 10:10:20 redismaster ovpn-rana[3361]: VERIFY OK: depth=0, C=IN, ST=MH, L=Pune, O=Promobi Technology, OU=Community, CN=server, name=Community, emailAddress=abc@xyz.com
Sep 19 10:10:20 redismaster ovpn-rana[3361]: Data Channel Encrypt: Cipher 'AES-128-CBC' initialized with 128 bit key
Sep 19 10:10:20 redismaster ovpn-rana[3361]: Channel Encrypt: Using 256 bit message hash 'SHA256' for HMAC authentication
Sep 19 10:10:20 redismaster ovpn-rana[3361]: Data Channel Decrypt: Cipher 'AES-128-CBC' initialized with 128 bit key
Sep 19 10:10:20 redismaster ovpn-rana[3361]: Data Channel Decrypt: Using 256 bit message hash 'SHA256' for HMAC authentication
Sep 19 10:10:20 redismaster ovpn-rana[3361]: Control Channel: TLSv1.2, cipher TLSv1/SSLv3 DHE-RSA-AES256-GCM-SHA384, 2048 bit RSA
Sep 19 10:10:20 redismaster ovpn-rana[3361]: [server] Peer Connection Initiated with [AF_INET]first_server_ip:443
Sep 19 10:10:23 redismaster ovpn-rana[3361]: SENT CONTROL [server]: 'PUSH_REQUEST' (status=1)
Sep 19 10:10:23 redismaster ovpn-rana[3361]: PUSH: Received control message: 'PUSH_REPLY,redirect-gateway def1 bypass-dhcp,dhcp-option DNS 208.67.222.222,dhcp-option DNS 208.67.220.220,route 10.8.0.1,topology net30,ping 10,ping-restart 60,ifconfig 10.8.0.10 10.8.0.9'
Sep 19 10:10:23 redismaster ovpn-rana[3361]: OPTIONS IMPORT: timers and/or timeouts modified
Sep 19 10:10:23 redismaster ovpn-rana[3361]: OPTIONS IMPORT: --ifconfig/up options modified
Sep 19 10:10:23 redismaster ovpn-rana[3361]: OPTIONS IMPORT: route options modified
Sep 19 10:10:23 redismaster ovpn-rana[3361]: OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified
Sep 19 10:10:23 redismaster ovpn-rana[3361]: Preserving previous TUN/TAP instance: tun0
Sep 19 10:10:23 redismaster ovpn-rana[3361]: NOTE: Pulled options changed on restart, will need to close and reopen TUN/TAP device.
Sep 19 10:10:23 redismaster ovpn-rana[3361]: /sbin/ip route del 10.8.1.1/32
Sep 19 10:10:23 redismaster ovpn-rana[3361]: ERROR: Linux route delete command failed: external program exited with error status: 2
Sep 19 10:10:23 redismaster ovpn-rana[3361]: /sbin/ip route del 68.183.181.138/32
Sep 19 10:10:23 redismaster ovpn-rana[3361]: ERROR: Linux route delete command failed: external program exited with error status: 2
Sep 19 10:10:23 redismaster ovpn-rana[3361]: /sbin/ip route del 0.0.0.0/1
Sep 19 10:10:23 redismaster ovpn-rana[3361]: ERROR: Linux route delete command failed: external program exited with error status: 2
Sep 19 10:10:23 redismaster ovpn-rana[3361]: /sbin/ip route del 128.0.0.0/1
Sep 19 10:10:23 redismaster ovpn-rana[3361]: ERROR: Linux route delete command failed: external program exited with error status: 2
Sep 19 10:10:23 redismaster ovpn-rana[3361]: Closing TUN/TAP interface
Sep 19 10:10:23 redismaster ovpn-rana[3361]: /sbin/ip addr del dev tun0 local 10.8.1.6 peer 10.8.1.5
Sep 19 10:10:23 redismaster ovpn-rana[3361]: Linux ip addr del failed: external program exited with error status: 2
Sep 19 10:10:23 redismaster ovpn-rana[3361]: /etc/openvpn/update-resolv-conf tun0 1500 1572 10.8.1.6 10.8.1.5 init
Sep 19 10:10:23 redismaster ovpn-rana[3361]: WARNING: Failed running command (--up/--down): external program exited with error status: 1
Sep 19 10:10:23 redismaster ovpn-rana[3361]: Exiting due to fatal error
Sep 19 10:10:23 redismaster systemd[1]: openvpn@rana.service: Main process exited, code=exited, status=1/FAILURE
Sep 19 10:10:23 redismaster systemd[1]: openvpn@rana.service: Unit entered failed state.
Sep 19 10:10:23 redismaster systemd[1]: openvpn@rana.service: Failed with result 'exit-code'.
```
Can you please help me to fix this issue. What configuration changes are required at client end or server end?
Any help will be appreciated.