summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-06-10 07:45:36 +0200
committerGitHub <noreply@github.com>2023-06-10 07:45:36 +0200
commit0b99a4cba1279b5a27d2fa013004501f89b3edce (patch)
treed2db029afbd2b3cbaa656414f66d41da5f2bbd6a
parenta7ee793b4e1f038e9b0f0774f10c407fc36ec164 (diff)
parent2e79de15fc3852a67d2fa4ae557ecd091a3ad780 (diff)
downloadvyos-1x-0b99a4cba1279b5a27d2fa013004501f89b3edce.tar.gz
vyos-1x-0b99a4cba1279b5a27d2fa013004501f89b3edce.zip
Merge pull request #2035 from indrajitr/ddclient-improvement-round-4
dns: T5144: Improve dynamic dns monitor and log and miscellaneous updates
-rw-r--r--data/templates/dns-dynamic/ddclient.conf.j29
-rw-r--r--data/templates/dns-dynamic/override.conf.j21
-rw-r--r--interface-definitions/dns-dynamic.xml.in2
-rw-r--r--interface-definitions/dns-forwarding.xml.in2
-rw-r--r--op-mode-definitions/dns-dynamic.xml.in35
-rw-r--r--op-mode-definitions/dns-forwarding.xml.in10
-rwxr-xr-xsrc/conf_mode/dns_dynamic.py8
7 files changed, 50 insertions, 17 deletions
diff --git a/data/templates/dns-dynamic/ddclient.conf.j2 b/data/templates/dns-dynamic/ddclient.conf.j2
index a19b79c00..4da7153c7 100644
--- a/data/templates/dns-dynamic/ddclient.conf.j2
+++ b/data/templates/dns-dynamic/ddclient.conf.j2
@@ -28,6 +28,9 @@ syslog=yes
ssl=yes
pid={{ config_file | replace('.conf', '.pid') }}
cache={{ config_file | replace('.conf', '.cache') }}
+{# Explicitly override global options for reliability #}
+web=googledomains {# ddclient default ('dyndns') doesn't support ssl and results in process lockup #}
+use=no {# ddclient default ('ip') results in confusing warning message in log #}
{% if address is vyos_defined %}
{% for address, service_cfg in address.items() %}
@@ -58,9 +61,9 @@ cache={{ config_file | replace('.conf', '.cache') }}
{% set ip_suffixes = ['v4', 'v6'] if config.ip_version == 'both'
else (['v6'] if config.ip_version == 'ipv6' else ['']) %}
# Web service dynamic DNS configuration for {{ name }}: [{{ config.protocol }}, {{ host }}]
-{# For ipv4 only setup, don't append 'new-style' compliant suffix ('usev4', 'ifv4', 'webv4' etc.)
- to the properties and instead live through the deprecation warnings for better compatibility
- with most ddclient protocols. #}
+{# For ipv4 only setup or legacy ipv6 setup, don't append 'new-style' compliant suffix
+ ('usev4', 'ifv4', 'webv4' etc.) to the properties and instead live through the
+ deprecation warnings for better compatibility with most ddclient protocols. #}
{{ render_config(host, address, service_cfg.web_options, ip_suffixes,
protocol=config.protocol, server=config.server, zone=config.zone,
login=config.username, password=config.password) }}
diff --git a/data/templates/dns-dynamic/override.conf.j2 b/data/templates/dns-dynamic/override.conf.j2
index 8a9dfcd70..6ca1b8a45 100644
--- a/data/templates/dns-dynamic/override.conf.j2
+++ b/data/templates/dns-dynamic/override.conf.j2
@@ -4,7 +4,6 @@ ConditionPathExists={{ config_file }}
After=vyos-router.service
[Service]
-PIDFile=
PIDFile={{ config_file | replace('.conf', '.pid') }}
EnvironmentFile=
ExecStart=
diff --git a/interface-definitions/dns-dynamic.xml.in b/interface-definitions/dns-dynamic.xml.in
index 292c50603..c7b45b8f7 100644
--- a/interface-definitions/dns-dynamic.xml.in
+++ b/interface-definitions/dns-dynamic.xml.in
@@ -4,7 +4,7 @@
<children>
<node name="dns">
<properties>
- <help>Domain Name System related services</help>
+ <help>Domain Name System (DNS) related services</help>
</properties>
<children>
<node name="dynamic" owner="${vyos_conf_scripts_dir}/dns_dynamic.py">
diff --git a/interface-definitions/dns-forwarding.xml.in b/interface-definitions/dns-forwarding.xml.in
index ced1c9c31..86dc47a47 100644
--- a/interface-definitions/dns-forwarding.xml.in
+++ b/interface-definitions/dns-forwarding.xml.in
@@ -5,7 +5,7 @@
<children>
<node name="dns">
<properties>
- <help>Domain Name System related services</help>
+ <help>Domain Name System (DNS) related services</help>
</properties>
<children>
<node name="forwarding" owner="${vyos_conf_scripts_dir}/dns_forwarding.py">
diff --git a/op-mode-definitions/dns-dynamic.xml.in b/op-mode-definitions/dns-dynamic.xml.in
index 8047d55cd..4f0399964 100644
--- a/op-mode-definitions/dns-dynamic.xml.in
+++ b/op-mode-definitions/dns-dynamic.xml.in
@@ -1,16 +1,40 @@
<?xml version="1.0"?>
<interfaceDefinition>
+ <node name="monitor">
+ <children>
+ <node name="log">
+ <children>
+ <node name="dns">
+ <properties>
+ <help>Monitor last lines of Domain Name System (DNS) related services</help>
+ </properties>
+ <children>
+ <node name="dynamic">
+ <properties>
+ <help>Monitor last lines of Dynamic DNS update service</help>
+ </properties>
+ <command>journalctl --no-hostname --follow --boot --unit ddclient.service</command>
+ </node>
+ </children>
+ </node>
+ </children>
+ </node>
+ </children>
+ </node>
<node name="show">
<children>
<node name="log">
<children>
<node name="dns">
+ <properties>
+ <help>Show log for Domain Name System (DNS) related services</help>
+ </properties>
<children>
<node name="dynamic">
<properties>
- <help>Show log for dynamic DNS</help>
+ <help>Show log for Dynamic DNS update service</help>
</properties>
- <command>cat $(printf "%s\n" /var/log/messages* | sort -nr) | grep -e "ddclient"</command>
+ <command>journalctl --no-hostname --boot --unit ddclient.service</command>
</node>
</children>
</node>
@@ -18,7 +42,7 @@
</node>
<node name="dns">
<properties>
- <help>Show DNS information</help>
+ <help>Show Domain Name System (DNS) related information</help>
</properties>
<children>
<node name="dynamic">
@@ -41,6 +65,9 @@
<node name="restart">
<children>
<node name="dns">
+ <properties>
+ <help>Restart specific Domain Name System (DNS) related service</help>
+ </properties>
<children>
<node name="dynamic">
<properties>
@@ -59,7 +86,7 @@
<children>
<node name="dns">
<properties>
- <help>Update DNS information</help>
+ <help>Update Domain Name System (DNS) related information</help>
</properties>
<children>
<node name="dynamic">
diff --git a/op-mode-definitions/dns-forwarding.xml.in b/op-mode-definitions/dns-forwarding.xml.in
index c8ca117be..a4c650c38 100644
--- a/op-mode-definitions/dns-forwarding.xml.in
+++ b/op-mode-definitions/dns-forwarding.xml.in
@@ -6,7 +6,7 @@
<children>
<node name="dns">
<properties>
- <help>Monitor last lines of Domain Name Service (DNS)</help>
+ <help>Monitor last lines of Domain Name System (DNS) related services</help>
</properties>
<children>
<node name="forwarding">
@@ -27,7 +27,7 @@
<children>
<node name="dns">
<properties>
- <help>Show log for Domain Name Service (DNS)</help>
+ <help>Show log for Domain Name System (DNS) related services</help>
</properties>
<children>
<node name="forwarding">
@@ -42,7 +42,7 @@
</node>
<node name="dns">
<properties>
- <help>Show DNS information</help>
+ <help>Show Domain Name System (DNS) related information</help>
</properties>
<children>
<node name="forwarding">
@@ -66,7 +66,7 @@
<children>
<node name="dns">
<properties>
- <help>Restart specific DNS service</help>
+ <help>Restart specific Domain Name System (DNS) related service</help>
</properties>
<children>
<leafNode name="forwarding">
@@ -83,7 +83,7 @@
<children>
<node name="dns">
<properties>
- <help>Reset a DNS service state</help>
+ <help>Reset Domain Name System (DNS) related service state</help>
</properties>
<children>
<node name="forwarding">
diff --git a/src/conf_mode/dns_dynamic.py b/src/conf_mode/dns_dynamic.py
index e070a3502..67134e681 100755
--- a/src/conf_mode/dns_dynamic.py
+++ b/src/conf_mode/dns_dynamic.py
@@ -117,13 +117,17 @@ def generate(dyndns):
return None
def apply(dyndns):
+ systemd_service = 'ddclient.service'
+ # Reload systemd manager configuration
+ call('systemctl daemon-reload')
+
# bail out early - looks like removal from running config
if not dyndns or 'address' not in dyndns:
- call('systemctl stop ddclient.service')
+ call(f'systemctl stop {systemd_service}')
if os.path.exists(config_file):
os.unlink(config_file)
else:
- call('systemctl restart ddclient.service')
+ call(f'systemctl reload-or-restart {systemd_service}')
return None