diff --git a/bundles/radvd/files/ip-down b/bundles/radvd/files/ip-down new file mode 100644 index 0000000..7d45425 --- /dev/null +++ b/bundles/radvd/files/ip-down @@ -0,0 +1,3 @@ +#!/bin/bash + +systemctl stop radvd diff --git a/bundles/radvd/files/ip-up b/bundles/radvd/files/ip-up new file mode 100644 index 0000000..8c91851 --- /dev/null +++ b/bundles/radvd/files/ip-up @@ -0,0 +1,3 @@ +#!/bin/bash + +systemctl start radvd diff --git a/bundles/radvd/files/radvd.conf b/bundles/radvd/files/radvd.conf new file mode 100644 index 0000000..e240d58 --- /dev/null +++ b/bundles/radvd/files/radvd.conf @@ -0,0 +1,16 @@ +% for interface, config in sorted(interfaces.items()): +interface ${interface} +{ + AdvSendAdvert on; + prefix ${config.get('prefix', '::/64')} + { + AdvOnLink on; + AdvAutonomous on; + AdvRouterAddr on; + }; + RDNSS ${' '.join(sorted(config['rdnss']))} + { + AdvRDNSSLifetime 900; + }; +}; +% endfor diff --git a/bundles/radvd/items.py b/bundles/radvd/items.py new file mode 100644 index 0000000..6c59bce --- /dev/null +++ b/bundles/radvd/items.py @@ -0,0 +1,36 @@ +if node.metadata.get('radvd', {}).get('integrate-with-pppd', False): + files['/etc/ppp/ip-up.d/radvd'] = { + 'source': 'ip-up', + 'mode': '0755', + } + files['/etc/ppp/ip-down.d/radvd'] = { + 'source': 'ip-down', + 'mode': '0755', + } + + # Will be started and stopped by pppd. + should_be_running = None + should_be_enabled = False +else: + should_be_running = True + should_be_enabled = True + +files['/etc/radvd.conf'] = { + 'content_type': 'mako', + 'context': { + 'interfaces': node.metadata['radvd']['interfaces'], + }, + 'triggers': { + 'svc_systemd:radvd:restart', + }, +} + +svc_systemd = { + 'radvd': { + 'running': should_be_running, + 'enabled': should_be_enabled, + 'needs': { + 'file:/etc/radvd.conf', + }, + }, +} diff --git a/bundles/radvd/metadata.py b/bundles/radvd/metadata.py new file mode 100644 index 0000000..d9a503f --- /dev/null +++ b/bundles/radvd/metadata.py @@ -0,0 +1,7 @@ +defaults = { + 'apt': { + 'packages': { + 'radvd': {}, + }, + }, +} diff --git a/nodes/home/router.py b/nodes/home/router.py index 58eaf09..2a8c143 100644 --- a/nodes/home/router.py +++ b/nodes/home/router.py @@ -5,6 +5,7 @@ nodes['home.router'] = { 'bundles': { 'iptables', 'pppd', + 'radvd', 'dhcpd', 'wide-dhcp6c', }, @@ -46,6 +47,17 @@ nodes['home.router'] = { 'nameservers': atomic({ '9.9.9.10', }), + 'radvd': { + 'integrate-with-pppd': True, + 'interfaces': { + 'enp1s0.42': { + 'rdnss': { + '2001:4860:4860::8888', + '2001:4860:4860::8844', + }, + }, + }, + }, 'pppd': { 'username': vault.decrypt('encrypt$gAAAAABfruZ5AZbgJ3mfMLWqIMx8o4bBRMJsDPD1jElh-vWN_gnhiuZVjrQ1-7Y6zDXNkxXiyhx8rxc2enmvo26axd7EBI8FqknCptXAPruVtDZrBCis4TE='), 'password': vault.decrypt('encrypt$gAAAAABfruaXEDkaFksFMU8g97ydWyJF8p2KcSDJJBlzaOLDsLL6oCDYjG1kMPVESOzqjn8ThtSht1uZDuMCstA-sATmLS-EWQ=='),