Thursday, December 22, 2011

Missing a file during compile

During a compile, I kept getting 'missing file' errors.

Solution: Use to fing the package that includes the missing file, so I can install it.

Friday, December 2, 2011

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. That's called dynamic hosting. But if I'm 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 isn't 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.

  1. Register for a dynamic DNS service. Any good search engine can point you to a good free service.

  2. 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.

  3. 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
      run_daemon=true   #to
      Restart ddclient (service 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
      It's not perfect for my use, but we'll fix that later.

That should be it. ddclient should automatically update the ddns host regularly (or event-driven) now.

Usage: If you're out on the internet and need to know your server's IP, just look it up:
dig +short                              # Elsewhere on the internet
nslookup                  # Another way from the internet              # As a web page
Or have the service look it up for you by simply using the domain name: ssh

Kingbaron: Sometimes my server is also an internet-facing router, sometimes it's just a LAN server. I don't 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.