4

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

0

1 Answer 1

3

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]
else:
    ip = env['IP4_ADDRESS_'+str(n-1)].split('/')[0]

ret = subprocess.call(['/usr/sbin/ddclient', '-daemon=0', '-syslog', '-use=ip', '-ip='+ip])
sys.exit(ret)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .