How to Use Dynamic DNS With a PPP Connection in Linux

By | February 2, 2010

Dynamic DNS represents a DNS management system, that allows to periodically update DNS records. Since almost any DNS server provides this functionality, dynamic DNS is used when updates need to be more frequent than usually and updated DNS becomes the most important point in user activity (more than speed, system stability, etc).

When you need to establish connection with a hostname, that has a dynamic IP address (most typical situation – a hostname, that has an unstable Internet connection), Dynamic DNS becomes a simple yet stable solution.

When a hostname obtains an IP address, it is automatically sent to Dynamic DNS system, but users are able to connect using a symbolic name, that remains unchanged (for example, hostname.com).  In order to prevent IP caching, Dynamic DNS records have low TTL values (e.g. 60 seconds).

We’re going to cover the process of using such a configuration with a pppd connection, this package is widely used in Linux with almost all types of Internet connections.

We will take dyndns.org as a Dynamic DNS provider (you’re welcome to select another one: there is no real difference between them). We won’t describe the process of signing up and creating DNS records, but you’re always welcome to follow this guide, and ask us if anything is unclear, though it should be.

We will use inadyn for our connections. It gives the possibility to have your own fixed hostname registered on the internet, although your IP might be changing. It checks periodically whether the IP address stored by the DNS server is the real current IP address of the machine that is running INADYN. Though there are some limitations, that are described here, it is a simple solution, that doesn’t require any specific knowledge. It is a free software, that allows to connect with many Dynamic DNS providers, and you can obtain it by following this link.

You will need to download it, unpack and compile using make.

We will use it in the following way:

inadyn is started when the connection is being established (pppd acquires an IP address and creates an interface). Immediately after that it tries to perform an update and then remains in memory to periodically check for updates. If inadyn is already present in memory, it will be terminated before running a new instance.

In order to do that, we need to touch /etc/ppp/ip-up.local file (create a new one if it doesn’t exist) with the following contents:

#!/bin/sh
kill `ps -A |grep inadyn |sed ‘s/[ |t].*$//’`
sleep 1
/etc/ppp/inadyn -u login -p xxxxx -a lampdocs.dyndns.org –background –update_period_sec 3600

Replace xxxxx with your password, login with your username, obtained at dyndns.org and lampdocs.dyndns.org with a symbolic name you’ve set for your host with dynamic IP.

You can change kill `ps -A |grep inadyn |sed ‘s/[ |t].*$//’` if you don’t like it. Here is another variant:

#!/bin/sh
pkill inadyn
sleep 1
/etc/ppp/inadyn -u login -p xxxxx -a lampdocs.dyndns.org –background –update_period_sec 3600

That’s enough for configuration. Inadyn will be automatically started when a new pppd connection is established. You might need to enable inadyn requests in firewall, so it could connect using http without any problems. Inadyn requires just 2 addresses to connect, and both of them have fixed IPs:

checkip.dyndns.org (IP 208.78.70.70)
members.dyndns.org (IP 204.13.248.112)

You can enable these requests by issuing the following commands:

iptables -t filter -I OUTPUT -p tcp -d 208.78.70.70 –destination-port 80 -j ACCEPT
iptables -t filter -I OUTPUT -p tcp -d 204.13.248.112 –destination -port 80 -j ACCEPT

Then you should input

iptables -t filter -I INPUT -p tcp -s 208.78.70.70 –source-port 80 -j ACCEPT
iptables -t filter -I INPUT -p tcp -s 204.13.248.112 –source-port 80 -j ACCEPT

Or

iptables -t filter -I INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT

– they have the same functionality for our needs. That’s all, Dynamic DNS should be working for you. Note, that you will have to configure inadyn if you choose another Dynamic DNS provider, the configuration is not complicated and you can find it in inadyn documentation.

Please, let us know if you have any problems using Dynamic DNS.