summaryrefslogtreecommitdiff
path: root/docs/services/dynamic-dns.rst
blob: f526009f277e3cb4ff7c0369a7ae17df27a7fe09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
.. _dynamic-dns:

###########
Dynamic DNS
###########

VyOS is able to update a remote DNS record when an interface gets a new IP
address. In order to do so, VyOS includes ddclient_, a Perl script written for
this only one purpose.

ddclient_ uses two methods to update a DNS record. The first one will send
updates directly to the DNS daemon, in compliance with :rfc:`2136`. The second
one involves a third party service, like DynDNS.com or any other similar
website. This method uses HTTP requests to transmit the new IP address. You
can configure both in VyOS.

Configuration
=============

:rfc:`2136` Based
-----------------

.. cfgcmd:: set service dns dynamic interface <interface> rfc2136 <service-name>

   Create new :rfc:`2136` DNS update configuration which will update the IP
   address assigned to `<interface>` on the service you configured under
   `<service-name>`.

.. cfgcmd:: set service dns dynamic interface <interface> rfc2136 <service-name> key <keyfile>

   File identified by `<keyfile>` containing the secret RNDC key shared with
   remote DNS server.

.. cfgcmd:: set service dns dynamic interface <interface> rfc2136 <service-name> server <server>

   Configure the DNS `<server>` IP/FQDN used when updating this dynamic
   assignment.

.. cfgcmd:: set service dns dynamic interface <interface> rfc2136 <service-name> zone <zone>

   Configure DNS `<zone>` to be updated.

.. cfgcmd:: set service dns dynamic interface <interface> rfc2136 <service-name> record <record>

   Configure DNS `<record>` which should be updated. This can be set multiple
   times.

.. cfgcmd:: set service dns dynamic interface <interface> rfc2136 <service-name> ttl <ttl>

   Configure optional TTL value on the given resource record. This defualts to
   600 seconds.

Example
^^^^^^^

* Register DNS record ``example.vyos.io`` on DNS server ``ns1.vyos.io``
* Use auth key file at ``/config/auth/my.key``
* Set TTL to 300 seconds

.. code-block:: none

  vyos@vyos# show service dns dynamic
   interface eth0.7 {
       rfc2136 VyOS-DNS {
           key /config/auth/my.key
           record example.vyos.io
           server ns1.vyos.io
           ttl 300
           zone vyos.io
       }
   }

This will render the following ddclient_ configuration entry:

.. code-block:: none

  #
  # ddclient configuration for interface "eth0.7":
  #
  use=if, if=eth0.7

  # RFC2136 dynamic DNS configuration for example.vyos.io.vyos.io
  server=ns1.vyos.io
  protocol=nsupdate
  password=/config/auth/my.key
  ttl=300
  zone=vyos.io
  example.vyos.io

.. note:: You can also keep different DNS zone updated. Just create a new
   config node: ``set service dns dynamic interface <interface> rfc2136
   <other-service-name>``

HTTP based services
-------------------

VyOS is also able to use any service relying on protocols supported by ddclient.

To use such a service, one must define a login, password, one or multiple
hostnames, protocol and server.

.. cfgcmd:: set service dns dynamic interface <interface> service <service> host-name <hostname>

   Setup the dynamic DNS hostname `<hostname>` associated with the DynDNS
   provider identified by `<service>` when the IP address on interface
   `<interface>` changes.

.. cfgcmd:: set service dns dynamic interface <interface> service <service> login <username>

   Configure `<username>` used when authenticating the update request for
   DynDNS service identified by `<service>`.

.. cfgcmd:: set service dns dynamic interface <interface> service <service> password <password>

   Configure `<password>` used when authenticating the update request for
   DynDNS service identified by `<service>`.

.. cfgcmd:: set service dns dynamic interface <interface> service <service> protocol <protocol>

   When a ``custom`` DynDNS provider is used the protocol used for communicating
   to the provider must be specified under `<protocol>`. See the embedded
   completion helper for available protocols.

.. cfgcmd:: set service dns dynamic interface <interface> service <service> server <server>

   When a ``custom`` DynDNS provider is used the `<server>` where update
   requests are being sent to must be specified.

Example:
^^^^^^^^

Use DynDNS as your preferred provider:

.. code-block:: none

  set service dns dynamic interface eth0 service dyndns
  set service dns dynamic interface eth0 service dyndns login my-login
  set service dns dynamic interface eth0 service dyndns password my-password
  set service dns dynamic interface eth0 service dyndns host-name my-dyndns-hostname

.. note:: Multiple services can be used per interface. Just specify as many
   serives per interface as you like!

Running Behind NAT
------------------

By default, ddclient_ will update a dynamic dns record using the IP address
directly attached to the interface. If your VyOS instance is behind NAT, your
record will be updated to point to your internal IP.

ddclient_ has another way to determine the WAN IP address. This is controlled
by:

.. cfgcmd:: set service dns dynamic interface <interface> use-web url <url>

   Use configured `<url>` to determine your IP address. ddclient_ will load
   `<url>` and tries to extract your IP address from the response.

.. cfgcmd:: set service dns dynamic interface <interface> use-web skip <pattern>

   ddclient_ will skip any address located before the string set in `<pattern>`.

.. _ddclient: https://github.com/ddclient/ddclient