# Local DDNS, sometimes with OpenVPN, sometimes with DHCP



## dvl@ (Nov 18, 2013)

My laptop connects to my home network in one of two says:


directly
OpenVPN

When connected directly, the laptop gets an IP address of 10.55.0.60. Through OpenVPN, it gets 10.8.1.60.  It's not feasible to give it the same address in both situations because I'd have to get into bridging, and I really don't need that.

The main objective: laptop.example.org always resolves to the correct IP address, whichever one is in use at the time.

So far:

My DNS and DHCP servers setups are similar to that described in Dynamic DNS with BIND and ISC DHCP SERVER.

My OpenVPN server is set up to use the --learn-address option.

The scenario I can't get my head around:

- connect in via OpenVPN, laptop.example.org gets set to 10.8.1.60
- disconnect from OpenVPN (probably just close the lid, so there's no actual shutdown)
- come home, connect via WIFI
- get assigned 10.55.0.60

In this situation, the A record already exists, and is set to 10.8.1.60 (from the OpenVPN session).  Does DNS know to delete the old record and replace it with a new record?  I think it is not doing this, because of the following log entry I keep seeing:


```
dhcpd: Forward map from laptop.example.org to 10.55.0.60 FAILED: Has an address record but no DHCID, not mine.
```

I think this log entry indicates that DHCPD thinks: Yes, there is an A record in there, but I didn't create it (i.e. Because there is no DHCID on that record, I know I didn't create it), so I'm not going to amend it because something is wrong.

I suspect this particular A record is left over from my non-ddns days and it does not necessarily indicate an incorrect configuration.

I know that updates work; I've tested them already.

Stay tuned for tonight when I try again. This time, I've deleted that old A record via nsupdate.


----------



## dvl@ (Nov 18, 2013)

When I got home, I deleted the A record using something like this:


```
# nsupdate -k /usr/local/openvpn/Kkopenvpnupdate.+157+50354.key
> server 10.0.0.73
> zone example.org
> update delete dent.example.org
> send
> quit
```

I fired up the laptop and was given an IP address, 10.55.0.60, as expected. Checking /var/log/messages on the DHCPD server, there was no FAILED message as shown in the first post.

Most importantly, this is the current state of the hostname:


```
$ host dent.unixathome.org
dent.unixathome.org has address 10.55.0.60
```

Next update will be after I've used an OpenVPN connection.


----------



## dvl@ (Nov 25, 2013)

All working as expected.


----------

