wip
This commit is contained in:
parent
983ad1b1ae
commit
bdbfcc3043
9 changed files with 114 additions and 5 deletions
|
@ -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()
|
||||
|
|
7
bundles/pppoe/files/dhcpcd.conf
Normal file
7
bundles/pppoe/files/dhcpcd.conf
Normal file
|
@ -0,0 +1,7 @@
|
|||
# /etc/dhcpcd.conf
|
||||
|
||||
allowinterfaces ppp0
|
||||
ipv6only
|
||||
|
||||
interface ppp0
|
||||
waitip 6
|
48
bundles/pppoe/files/dhcpcd.exit-hook
Normal file
48
bundles/pppoe/files/dhcpcd.exit-hook
Normal file
|
@ -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:-<leer>}"
|
||||
|
||||
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
|
|
@ -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 ---
|
||||
|
|
9
bundles/pppoe/files/radvd.conf.template
Normal file
9
bundles/pppoe/files/radvd.conf.template
Normal file
|
@ -0,0 +1,9 @@
|
|||
interface enp1s0f0 {
|
||||
AdvSendAdvert on;
|
||||
prefix __IP6PREFIX__ {
|
||||
AdvOnLink on;
|
||||
AdvAutonomous on;
|
||||
AdvValidLifetime 86400;
|
||||
AdvPreferredLifetime 14400;
|
||||
};
|
||||
};
|
|
@ -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',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
},
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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': {
|
||||
|
|
|
@ -71,6 +71,9 @@
|
|||
'ipv4': {
|
||||
'ip_forward': 1,
|
||||
},
|
||||
'ipv6': {
|
||||
'ip_forward': 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
'wireguard': {
|
||||
|
|
Loading…
Reference in a new issue