Tuesday, July 4, 2017
ddclient on a Debian 6 server
ddclient on a Debian 6 server
This post is an update to my original in March 2011.
Every time I reconnect to the internet, my router is given a different IP address by the upstream internet service provider. Thats called dynamic hosting. But if Im out on the internet, I cannot connect to my server unless I know the current IP. A Dynamic DNS (ddns) host simply tracks my ever-changing IP for me in an internet-accessible way.
The ddns host isnt psychic - I need a small piece of software (a ddns client) on my server that figures out whenever the IP changes, and sends that update to the ddns host.
- Register for a dynamic DNS service. Any good search engine can point you to a good free service.
- The ddclient package is the server program that sends the new IP to the ddns host. Install ddclient using the command
apt-get install ddclient
. The installer will ask questions about the newly-registered dynamic dns account. - There are two ways to run ddclient - as a daemon or as an occasionally-triggered non-daemon.
- To run ddclient as a daemon (always-on), edit the file /etc/init.d/ddclient, and change the line:
run_daemon=false #from
Restart ddclient (
run_daemon=true #toservice ddclient restart
) to reload the new config. - To run ddclient as a non-daemon, take a look in the /usr/share/doc/ddclient/examples directory for a bunch of possible trigger mechanisms.
I chose to run ddclient whenever my server picks up a new IP address:cp /usr/share/doc/ddclient/examples/sample-etc_dhclient-exit-hooks /etc/dhcp/dhclient-exit-hooks.d/ddclient
Its not perfect for my use, but well fix that later.
- To run ddclient as a daemon (always-on), edit the file /etc/init.d/ddclient, and change the line:
That should be it. ddclient should automatically update the ddns host regularly (or event-driven) now.
Usage: If youre out on the internet and need to know your servers IP, just look it up:
dig +short myaccount.dyndns.org # Elsewhere on the internetOr have the service look it up for you by simply using the domain name:
nslookup myaccount.dyndns.org ns.dyndns.org # Another way from the internet
http://www.dnscog.com/dig/myaccount.dyndns.org/ # As a web page
ssh myaccount.dyndns.org
Kingbaron: Sometimes my server is also an internet-facing router, sometimes its just a LAN server. I dont want it erroneously feeding LAN addresses to the ddns. Happily, the dhclient-exit-hook script thought of that already. If the new IP address is in the normal LAN range, ddclient ignores it.
download more info
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment