partly support getting IPv6 addresses

- gets interface id from ppp
- runs odhcpc to get RA and prefix delegation
- doesn't do anything useful with the data yet
This commit is contained in:
Daniel Barlow
2023-05-24 23:01:50 +01:00
parent 339c2d9873
commit 447f068569
6 changed files with 98 additions and 1 deletions

View File

@@ -232,6 +232,25 @@ in rec {
down = "echo 0 > ${filename}";
};
services.dhcp6 =
let
name = "dhcp6c.wan";
luafile = pkgs.runCommand "udhcpc-script" {} ''
${pkgs.luaSmall.pkgs.fennel}/bin/fennel --compile ${./udhcp6-script.fnl} > $out
'';
script = pkgs.writeAshScript "dhcp6-notify" {} ''
. ${serviceFns}
(in_outputs ${name}; ${pkgs.luaSmall}/bin/lua ${luafile} "$@")
'';
in longrun {
inherit name;
run = ''
${pkgs.odhcp6c}/bin/odhcp6c -s ${script} -e -v -p /run/${name}.pid -P 48 $(output ${services.wan} ifname)
)
'';
dependencies = [ services.wan ];
};
services.default = target {
name = "default";
contents = with config.services; [
@@ -248,6 +267,7 @@ in rec {
resolvconf
sshd
config.services.hostname
dhcp6
];
};
defaultProfile.packages = with pkgs; [min-collect-garbage nftables tcpdump] ;

View File

@@ -0,0 +1,47 @@
(fn write-value [name value]
(with-open [fout (io.open name :w)]
(when value (fout:write value))))
(write-value "state" (. arg 2))
(write-value "ifname" (. arg 1))
(fn write-value-from-env [name]
(write-value name (os.getenv (string.upper name))))
(let [wanted
[
:addresses
:aftr
:cer
:domains
:lw406
:mape
:mapt
:ntp_fqdn
:ntp_ip
:option_1
:option_2
:option_3
:option_4
:option_5
:passthru
:prefixes
:ra_addresses
:ra_dns
:ra_domains
:ra_hoplimit
:ra_mtu
:ra_reachable
:ra_retransmit
:ra_routes
:rdnss
:server
:sip_domain
:sip_ip
:sntp_ip
:sntp_fqdn
]]
(each [_ n (ipairs wanted)]
(write-value-from-env n)))