From b047855b80754d78cab4d3161ad0e97c21f479bc Mon Sep 17 00:00:00 2001 From: jack9603301 Date: Mon, 30 Nov 2020 20:03:00 +0800 Subject: nptv6: T2518: Initial support for nat66 (NPT) --- src/systemd/ndppd.service | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/systemd/ndppd.service (limited to 'src/systemd') diff --git a/src/systemd/ndppd.service b/src/systemd/ndppd.service new file mode 100644 index 000000000..566172fb0 --- /dev/null +++ b/src/systemd/ndppd.service @@ -0,0 +1,15 @@ +[Unit] +Description=NDP Proxy Daemon +After=network.target vyos-router.service +ConditionPathExists=/run/ndppd/ndppd.conf +StartLimitIntervalSec=0 + +[Service] +ExecStart=/usr/sbin/ndppd -d -p /var/run/ndppd/ndppd.pid -c /var/run/ndppd/ndppd.conf +Type=forking +PIDFile=/var/run/ndppd/ndppd.pid +Restart=on-failure +RestartSec=20 + +[Install] +WantedBy=multi-user.target -- cgit v1.2.3 From d05593e68ff0978c278b13a42f246edcfad3902d Mon Sep 17 00:00:00 2001 From: jack9603301 Date: Fri, 22 Jan 2021 13:16:55 +0800 Subject: nptv6: T2518: Optimized implementation --- data/templates/proxy-ndp/ndppd.conf.tmpl | 4 ++-- src/conf_mode/nat66.py | 14 ++++++++++---- src/systemd/ndppd.service | 6 +++--- 3 files changed, 15 insertions(+), 9 deletions(-) (limited to 'src/systemd') diff --git a/data/templates/proxy-ndp/ndppd.conf.tmpl b/data/templates/proxy-ndp/ndppd.conf.tmpl index f9485a1cb..6ef9f3f8b 100644 --- a/data/templates/proxy-ndp/ndppd.conf.tmpl +++ b/data/templates/proxy-ndp/ndppd.conf.tmpl @@ -37,8 +37,8 @@ proxy {{ i }} { timeout 500 ttl 30000 {% for map in global.ndppd_prefixs %} -{% if map['interface'] == i %} -{% set p = map['rule'] %} +{% if map.interface == i %} +{% set p = map.rule %} rule {{ p }} { static } diff --git a/src/conf_mode/nat66.py b/src/conf_mode/nat66.py index a5c74259f..7190961e8 100755 --- a/src/conf_mode/nat66.py +++ b/src/conf_mode/nat66.py @@ -151,10 +151,16 @@ def generate(nat): return None def apply(nat): - cmd(f'{iptables_nat_config}') - cmd('systemctl restart ndppd') - if os.path.isfile(iptables_nat_config): - os.unlink(iptables_nat_config) + if not nat: + return None + else: + cmd(f'{iptables_nat_config}') + if 'deleted' in nat or not dict_search('source.rule', nat): + cmd('systemctl stop ndppd') + else: + cmd('systemctl restart ndppd') + if os.path.isfile(iptables_nat_config): + os.unlink(iptables_nat_config) return None diff --git a/src/systemd/ndppd.service b/src/systemd/ndppd.service index 566172fb0..db471c518 100644 --- a/src/systemd/ndppd.service +++ b/src/systemd/ndppd.service @@ -1,13 +1,13 @@ [Unit] Description=NDP Proxy Daemon -After=network.target vyos-router.service +After=vyos-router.service ConditionPathExists=/run/ndppd/ndppd.conf StartLimitIntervalSec=0 [Service] -ExecStart=/usr/sbin/ndppd -d -p /var/run/ndppd/ndppd.pid -c /var/run/ndppd/ndppd.conf +ExecStart=/usr/sbin/ndppd -d -p /run/ndppd/ndppd.pid -c /run/ndppd/ndppd.conf Type=forking -PIDFile=/var/run/ndppd/ndppd.pid +PIDFile=/run/ndppd/ndppd.pid Restart=on-failure RestartSec=20 -- cgit v1.2.3 From 455d77a674794951cff6fdb84f33b2022050a0d6 Mon Sep 17 00:00:00 2001 From: jack9603301 Date: Sun, 24 Jan 2021 13:43:17 +0800 Subject: nptv6: T2515: Modify the field order of ndppd --- src/systemd/ndppd.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/systemd') diff --git a/src/systemd/ndppd.service b/src/systemd/ndppd.service index db471c518..5790d37f1 100644 --- a/src/systemd/ndppd.service +++ b/src/systemd/ndppd.service @@ -5,8 +5,8 @@ ConditionPathExists=/run/ndppd/ndppd.conf StartLimitIntervalSec=0 [Service] -ExecStart=/usr/sbin/ndppd -d -p /run/ndppd/ndppd.pid -c /run/ndppd/ndppd.conf Type=forking +ExecStart=/usr/sbin/ndppd -d -p /run/ndppd/ndppd.pid -c /run/ndppd/ndppd.conf PIDFile=/run/ndppd/ndppd.pid Restart=on-failure RestartSec=20 -- cgit v1.2.3