diff --git a/bundles/network/metadata.py b/bundles/network/metadata.py index 77a18d5..d9d0d23 100644 --- a/bundles/network/metadata.py +++ b/bundles/network/metadata.py @@ -50,7 +50,7 @@ def units(metadata): }, 'Network': { 'DHCP': network_conf.get('dhcp', 'no'), - 'IPv6AcceptRA': network_conf.get('dhcp', 'no'), + 'IPv6AcceptRA': network_conf.get('IPv6AcceptRA', 'no'), 'VLAN': set( other_network_name for other_network_name, other_network_conf in metadata.get('network', {}).items() diff --git a/bundles/pppoe/files/dhcpcd.conf b/bundles/pppoe/files/dhcpcd.conf new file mode 100644 index 0000000..5d1e053 --- /dev/null +++ b/bundles/pppoe/files/dhcpcd.conf @@ -0,0 +1,7 @@ +# /etc/dhcpcd.conf + +allowinterfaces ppp0 +ipv6only + +interface ppp0 + waitip 6 \ No newline at end of file diff --git a/bundles/pppoe/files/dhcpcd.exit-hook b/bundles/pppoe/files/dhcpcd.exit-hook new file mode 100644 index 0000000..1b671a7 --- /dev/null +++ b/bundles/pppoe/files/dhcpcd.exit-hook @@ -0,0 +1,48 @@ +#!/bin/sh + +logger -t dhcpcd "===== dhcpcd.exit-hook gestartet: interface=$interface, reason=$reason =====" + +# 1) nur auf ppp0 reagieren +if [ "$interface" != "ppp0" ]; then + logger -t dhcpcd "Skipping hook: interface ist '$interface' (nicht ppp0)" + return 0 +fi +logger -t dhcpcd "Hook für ppp0, reason=$reason" + +# 2) nur bei ROUTERADVERT (RA vom Provider) +if [ "$reason" != "ROUTERADVERT" ]; then + logger -t dhcpcd "Skipping hook: reason ist '$reason' (nicht ROUTERADVERT)" + return 0 +fi +logger -t dhcpcd "Verarbeite ROUTERADVERT" + +# 3) IPv6-Prefix auf ppp0 ermitteln +PREFIX=$(ip -6 addr show dev ppp0 scope global dynamic \ + | awk '/scope global/ { print $2; exit }') +logger -t dhcpcd "Ermittelter PREFIX: ${PREFIX:-}" + +if [ -z "$PREFIX" ]; then + logger -t dhcpcd "Fehler: kein gültiger IPv6-Prefix auf ppp0 gefunden" + return 1 +fi + +# 4) radvd.conf erzeugen +logger -t dhcpcd "Erzeuge /etc/radvd.conf aus Template" +if sed "s|__IP6PREFIX__|$PREFIX|g" /etc/radvd.conf.template > /etc/radvd.conf; then + logger -t dhcpcd "Template erfolgreich ersetzt" +else + logger -t dhcpcd "Fehler beim Ersetzen des Templates" + return 1 +fi + +# 5) radvd neu laden +logger -t dhcpcd "Lade radvd neu" +if systemctl reload-or-restart radvd; then + logger -t dhcpcd "radvd neu geladen" +else + logger -t dhcpcd "Fehler beim Neuladen von radvd" + return 1 +fi + +logger -t dhcpcd "===== dhcpcd.exit-hook erfolgreich beendet =====" +return 0 \ No newline at end of file diff --git a/bundles/pppoe/files/isp b/bundles/pppoe/files/isp index 7a64957..2895e92 100644 --- a/bundles/pppoe/files/isp +++ b/bundles/pppoe/files/isp @@ -11,7 +11,7 @@ replacedefaultroute # ersetzt vorherige Default-Route +ipv6 # IPv6CP aktivieren ipv6cp-accept-local # lokale IPv6 vom ISP übernehmen ipv6cp-accept-remote # remote IPv6 vom ISP übernehmen -ipv6cp-use-ipaddr # statt Link-Local die zugewiesene IPv6 nutzen +#ipv6cp-use-ipaddr # statt Link-Local die zugewiesene IPv6 nutzen defaultroute6 # --- Verbindungsmanagement --- diff --git a/bundles/pppoe/files/radvd.conf.template b/bundles/pppoe/files/radvd.conf.template new file mode 100644 index 0000000..40434c7 --- /dev/null +++ b/bundles/pppoe/files/radvd.conf.template @@ -0,0 +1,9 @@ +interface enp1s0f0 { + AdvSendAdvert on; + prefix __IP6PREFIX__ { + AdvOnLink on; + AdvAutonomous on; + AdvValidLifetime 86400; + AdvPreferredLifetime 14400; + }; +}; diff --git a/bundles/pppoe/items.py b/bundles/pppoe/items.py index c79c279..5032212 100644 --- a/bundles/pppoe/items.py +++ b/bundles/pppoe/items.py @@ -25,6 +25,22 @@ files = { 'pkg_apt:pppoe', }, }, + '/etc/dhcpcd.conf': { + 'content_type': 'mako', + }, + '/etc/dhcpcd.exit-hook': { + 'mode': '0755', + }, + '/etc/radvd.conf.template': { + 'content_type': 'mako', + }, +} + +actions = { + 'touch_radvd.conf': { + 'command': 'touch /etc/radvd.conf', + 'unless': 'ls /etc/radvd.conf', + }, } svc_systemd = { @@ -39,4 +55,17 @@ svc_systemd = { 'svc_systemd:pppoe-isp.service', }, }, + 'dhcpcd.service': { + 'needs': { + 'pkg_apt:dhcpcd5', + 'file:/etc/dhcpcd.conf', + 'file:/etc/dhcpcd.exit-hook', + 'action:touch_radvd.conf', + }, + }, + 'radvd.service': { + 'needs': { + 'pkg_apt:radvd', + }, + }, } diff --git a/bundles/pppoe/metadata.py b/bundles/pppoe/metadata.py index 9073b4d..a2c15db 100644 --- a/bundles/pppoe/metadata.py +++ b/bundles/pppoe/metadata.py @@ -2,6 +2,8 @@ defaults = { 'apt': { 'packages': { 'pppoe': {}, + 'dhcpcd5': {}, + 'radvd': {}, }, }, 'nftables': { @@ -11,6 +13,11 @@ defaults = { }, 'systemd': { 'units': { + 'dhcpcd.service.d/override.conf': { + 'Service': { + 'ReadWritePaths': {'/etc/radvd.conf'}, + }, + }, 'pppoe-isp.service': { 'Unit': { 'Description': 'PPPoE Internet Connection', @@ -18,7 +25,7 @@ defaults = { }, 'Service': { 'Type': 'forking', - 'ExecStart': '/usr/sbin/pppd call isp', + 'ExecStart': '/usr/sbin/pppd call isp updetach', 'Restart': 'on-failure', 'RestartSec': 5, }, @@ -26,7 +33,11 @@ defaults = { 'qdisc-ppp0.service': { 'Unit': { 'Description': 'setup queuing discipline for interface ppp0', - 'After': 'sys-devices-virtual-net-ppp0.device', + 'After': { + 'pppoe-isp.service', + 'sys-devices-virtual-net-ppp0.device', + }, + 'PartOf': 'pppoe-isp.service', 'BindsTo': 'sys-devices-virtual-net-ppp0.device', }, 'Service': { @@ -35,7 +46,7 @@ defaults = { 'RemainAfterExit': 'yes', }, 'Install': { - 'WantedBy': 'network-online.target', + 'WantedBy': 'multi-user.target', }, } }, diff --git a/nodes/home.backups.py b/nodes/home.backups.py index 3b4bc5d..d48aa68 100644 --- a/nodes/home.backups.py +++ b/nodes/home.backups.py @@ -21,6 +21,8 @@ 'interface': 'enp1s0f0', 'ipv4': '10.0.0.5/24', 'gateway4': '10.0.0.1', + 'ipv6': 'fd00:10:0:0::5/64', + 'IPv6AcceptRA': 'yes', 'mac': '98:b7:85:01:ca:a6', }, 'wakeonlan': { diff --git a/nodes/home.router.py b/nodes/home.router.py index 5adff9b..c3eb346 100644 --- a/nodes/home.router.py +++ b/nodes/home.router.py @@ -71,6 +71,9 @@ 'ipv4': { 'ip_forward': 1, }, + 'ipv6': { + 'ip_forward': 1, + }, }, }, 'wireguard': {