Linux dns client update

Dynamic DNS

Dynamic DNS (DDNS or DynDNS) is a method of automatically updating a name server in the Domain Name System (DNS), often in real time, with the active DDNS configuration of its configured hostnames, addresses or other information. The term is used to describe two different concepts. The first is «dynamic DNS updating» which refers to systems that are used to update traditional DNS records without manual editing. These mechanisms are explained in RFC 2136, and use the TSIG mechanism to provide security. The second kind of dynamic DNS permits lightweight and immediate updates often using an update client, which do not use the RFC2136 standard for updating DNS records. These clients provide a persistent addressing method for devices that change their location, configuration or IP address frequently.

For RFC2136 there is nsupdate(1) from bind . For dynamic DNS services there are several packages available, see #Update clients.

Router

If the device needing DDNS sits behind a router, you should first check if the router itself can update any DDNS services. Although the selection of services may be limited, there are several advantages to using the router: it will probably be easier to set up, will require little to no maintenance, and will have no downtime (if the router is down you will not have Internet anyway).

Update clients

Note that some dynamic DNS providers do not require a dedicated client and can be updated with cURL.

Multi-service clients

  • ddclient — Update dynamic DNS entries for accounts on many dynamic DNS services.
  • ddnsc — A simple & lightweight client written in python.
  • inadyn — Dynamic DNS client with SSL/TLS support.
  • inadyn-mt — A simple dynamic DNS client based on inadyn.
  • ndyndns — Supports DynDNS and Namecheap.
Читайте также:  Флеш плеер astra linux

Single-service clients

  • duckdns — Update your DuckDNS.org entries from your computer with systemd.
  • hetzner_ddns — Dynamic DNS daemon for Hetzner DNS
  • noip — Dynamic DNS Client Updater for no-ip.com services.
  • petrified — Bash client to update dynamic DNS at freedns.afraid.org.

ddclient

ddclient is compatible with many DDNS services and is the recommended tool for updating DDNS if your router is not an option. It includes systemd support.

After installing, edit the configuration file /etc/ddclient/ddclient.conf to set up your DDNS provider (it includes many examples). Then enable and start ddclient.service .

The configuration can be tested by running ddclient with the -noquiet and -debug options:

# ddclient -daemon=0 -noquiet -debug

Some of the compatible services are listed below, but you can also check the examples and protocols for more.

ddclient compatible services

Service Configuration notes
Now-DNS example
ChangeIP example
Duck DNS example
FreeDNS example
No-IP Use protocol noip , server dynupdate.no-ip.com
nsupdate.info Use protocol dyndns2
Dyn DNS example
Namecheap example
Dynu example

Note: Free users of no-ip are required to manually confirm their domain(s) every 30 days. Domain confirmation is not required for Enhanced users though. More info at Why is My Hostname Pending Deletion?

Use an external website to determine IP address

If ddclient is unable to detect your IP address, you can configure ddclient to fetch your IP from an external webpage such as checkip.dyndns.org. This address is used by default when use=web is specified. It is also recommended to increase the check interval to avoid frequent requests to the IP check service:

daemon=900 # obtain IP address from web status page use=web

An alternative IP check service can be specified with the web key:

daemon=900 # obtain IP address from web status page use=web, web=myonlineportal.net/checkip

Use a local script to determine IPv6 address

ddclient often gets the wrong IPv6 address or none at all, but instead of an external website the IPv6 address can be determined locally. This script can be used:

#!/bin/bash /sbin/ip -6 addr | grep inet6 | awk -F '[ \t]+|/' '' | grep -v ^::1 | grep -v ^fe80

Tell ddclient to use the script:

# obtain IP address from script use=cmd,cmd='/usr/local/bin/get-ip'

Use UPnP or NAT-PMP to determine external IPv4 address

If your router supports UPnP, install miniupnpc and use the external-ip utility:

# obtain IP address from script use=cmd,cmd='/usr/bin/external-ip'

For NAT-PMP, install libnatpmp and create a script wrapping the natpmpc output.

#!/bin/sh natpmpc | grep -oP 'Public IP address : \K\S+'

Make the script executable and tell ddclient to use it:

# obtain IP address from script use=cmd,cmd='/usr/local/bin/get-ip'

Starting ddclient after networking is up

If you find that ddclient is unable to update your IP properly, it may be that the ddclient process is starting before networking is up. To fix it, you can edit the unit file to depend on network-online.target:

/etc/systemd/system/ddclient.service.d/network-online.conf
[Unit] Wants=network-online.target After=network-online.target nss-lookup.target

Other providers

Other DDNS providers are not compatible with ddclient so updating your IP with them may require a special tool or some custom scripting. Remember that if the service allows you to update your IP using the command line, you can automate the process using tools such as cron or systemd/Timers.

  • This page was last edited on 10 April 2023, at 17:16.
  • Content is available under GNU Free Documentation License 1.3 or later unless otherwise noted.
  • Privacy policy
  • About ArchWiki
  • Disclaimers
Читайте также:  Настройка виртуального окружения python linux

Источник

How to update/flush dns cache on clients?

When I have made changes on the DNS host. How do I get the clients (servers) to update/flush their DNS cache, so they see the change right away?

3 Answers 3

You can restart BIND on Ubuntu using sudo rndc reload , on Centos I believe you have to /etc/init.d/bind restart .

You can also execute /etc/init.d/networking restart to flush the DNS/networking for local desktops running Ubuntu.

If you make a change to the bind configurations, then it’s better to flush the dns server using rndc , than restarting the service. If you change the hosts file, then flushing this is done via /etc/init.d/networking restart . I often find myself flushing these configurations.

None if these methods work on my debian wheezy box 🙁 Also tried installing nscd and bind9 just for flushing through those, didn’t work.

I have found that a simple restart does not always clear the cache. The other way of doing it, would be to use the nscd command and invalidate the hosts cache.

Then you don’t even need to restart the caching service.

Depending on you distribution, the clients may not cache by default. For Ubuntu or CentOS, try this command: sudo /etc/init.d/nscd status

. to see if the caching demon is running. If it is, then your client is caching DNS and you can flush it with this: sudo /etc/init.d/nscd restart

if NSCD is not running then there is nothing to flush on the client and you need to: 1. make sure the old entry is not in the /etc/hosts file 2. make sure the DNS change has already propagated to any DNS slaves (check the resolv.conf for where it is resolving to)

Читайте также:  Линукс роса не загружается

Источник

Оцените статью
Adblock
detector