1

I'm running an Ubuntu 14.04.3 LTS server that launches a few things at startup, two of them being OpenVPN for my VPN service and a Dynamic DNS Update Client to update my noip host to my current IP.

I've tried with the official noip DUC and with ddclient (see here why I changed) and both of them incorrectly update to the IP I have before my VPN connects (the ISP IP).

The OpenVPN connection is working when I login via SSH, so it means the DUC reports the IP before OpenVPN is working or something like that. Before asking here, I've tried to modify the init.d script of ddclient with an openvpn requirement :

# Required-Start:    $local_fs $remote_fs $network $syslog $openvpn

For rcX.d files, openvpn has something like S16openvpn and ddclient has S99ddclient, so normally ddclient starts after openvpn right ? I'm not really comfortable with those things.

That didn't change anything. I hope someone can help me, it means each time I reboot my server, I have to restart the DUC client service for my noip host to work correctly.

A plan B if nothing can be found is to ask service ddclient to restart after everything has launched, so that I don't have to do it and I won't forget. But of course making ddclient update to the right IP in the first place would be better.

P.S. : If you ask why I want the IP to be the VPN IP, it's because some services like Teamspeak 3 server have to be reachable so my ddns.net must point to the VPN IP, because when pointing to my ISP public IP, they are not reachable anymore (linked to how VPN works I guess).

0

So, I've learned that OpenVPN provides a way to start a script after the tunnel is created. For that, in my file /etc/openvpn/toto.conf, I added the line

# run /etc/openvpn/titi.sh when the connection is set up
up /etc/openvpn/titi.sh

Note that the parameter script-security in the conf file must be correctly set (at least script-security 2, see man of openvpn).

Here is the content of my script titi.sh :

#!/bin/bash
(sleep 60 && ddclient -daemon=0 -debug -verbose -noquiet -force >> launch_dd.log) &

First script didn't have the sleep 60, but strangely when the script was called and ddclient launched, my IP was still my ISP IP and not the VPN IP, even if it was launched with the OpenVPN up parameter. That's maybe why it was not working in the first place.

So I simply told the script to wait 60 seconds before launching. Now my IP is set to the VPN IP when I reboot the server.

| improve this answer | |
  • the needed sleep in the up script and the fact that the init.d $openvpn requirement don't work is 99% sure due to the fact the ddclient should execute after the routes are added, but adding the routes is executed after openvpn is "officially" launched and after the up command (I think, please correct me if needed) – Kriegalex Oct 29 '15 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.