Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I make ddclient update my dyndns address whenever NetworkManager makes or cuts a connection?

share|improve this question
up vote 1 down vote accepted

NetworkManager automatically calls scripts placed in /etc/NetworkManager/dispatcher.d with some interesting environment variables set. This is documented to some degree under man NetworkManager, but not all environment variables are explained there. I use a script like the one below, because i prefer the IP-Adress of the VPN-connection to be used on dyndns. The script also uses the last of multiple listed addresses, in the hope that it will be the most current, most important one.

#!/usr/bin/env python

import sys
import os
import subprocess

env = os.environ
n = int(env['IP4_NUM_ADDRESSES'])
nvpn = int(env.get('VPN_IP4_NUM_ADDRESSES',0))

if nvpn>0:
    ip = env['VPN_IP4_ADDRESS_'+str(nvpn-1)].split('/')[0]
    ip = env['IP4_ADDRESS_'+str(n-1)].split('/')[0]

ret =['/usr/sbin/ddclient', '-daemon=0', '-syslog', '-use=ip', '-ip='+ip])
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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