2022-07-15 01:16:51 +02:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
{
|
2022-07-23 16:46:03 +02:00
|
|
|
sops.secrets.ppp_secrets = {
|
|
|
|
path = "/etc/ppp/pap-secrets";
|
|
|
|
mode = "0440";
|
|
|
|
};
|
2022-07-15 01:16:51 +02:00
|
|
|
# Setting default routes based on interfaces in different tables
|
|
|
|
environment.etc."ppp/ip-up" = {
|
|
|
|
text = ''
|
|
|
|
#! ${pkgs.runtimeShell} -e
|
|
|
|
|
2022-07-23 17:55:31 +02:00
|
|
|
case $1 in
|
2022-07-15 01:16:51 +02:00
|
|
|
ppp-uplink-a)
|
2022-07-23 17:55:31 +02:00
|
|
|
${pkgs.iproute2}/bin/ip route flush table 20001 || true
|
|
|
|
${pkgs.iproute2}/bin/ip route add default dev ppp-uplink-a table 20001
|
2022-07-15 01:16:51 +02:00
|
|
|
;;
|
|
|
|
ppp-uplink-b)
|
2022-07-23 17:55:31 +02:00
|
|
|
${pkgs.iproute2}/bin/ip route flush table 20002 || true
|
|
|
|
${pkgs.iproute2}/bin/ip route add default dev ppp-uplink-b table 20002
|
2022-07-15 01:16:51 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
'';
|
|
|
|
mode = "555";
|
|
|
|
};
|
|
|
|
environment.etc."ppp/ip-down" = {
|
|
|
|
text = ''
|
|
|
|
#! ${pkgs.runtimeShell} -e
|
|
|
|
|
2022-07-23 17:55:31 +02:00
|
|
|
case $1 in
|
2022-07-15 01:16:51 +02:00
|
|
|
ppp-uplink-a)
|
2022-07-23 17:55:31 +02:00
|
|
|
${pkgs.iproute2}/bin/ip route flush table 20001 || true
|
2022-07-15 01:16:51 +02:00
|
|
|
;;
|
|
|
|
ppp-uplink-b)
|
2022-07-23 17:55:31 +02:00
|
|
|
${pkgs.iproute2}/bin/ip route flush table 20002 || true
|
2022-07-15 01:16:51 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
'';
|
|
|
|
mode = "555";
|
|
|
|
};
|
|
|
|
environment.etc."ppp/ipv6-up" = {
|
|
|
|
text = ''
|
|
|
|
#! ${pkgs.runtimeShell} -e
|
|
|
|
|
2022-07-23 17:55:31 +02:00
|
|
|
case $1 in
|
2022-07-15 01:16:51 +02:00
|
|
|
ppp-uplink-a)
|
2022-07-23 17:55:31 +02:00
|
|
|
${pkgs.iproute2}/bin/ip -6 route flush table 20001 || true
|
|
|
|
${pkgs.iproute2}/bin/ip -6 route add default dev ppp-uplink-a table 20001
|
2022-07-15 01:16:51 +02:00
|
|
|
;;
|
|
|
|
ppp-uplink-b)
|
2022-07-23 17:55:31 +02:00
|
|
|
${pkgs.iproute2}/bin/ip -6 route flush table 20002 || true
|
|
|
|
${pkgs.iproute2}/bin/ip -6 route add default dev ppp-uplink-b table 20002
|
2022-07-15 01:16:51 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
'';
|
|
|
|
mode = "555";
|
|
|
|
};
|
|
|
|
environment.etc."ppp/ipv6-down" = {
|
|
|
|
text = ''
|
|
|
|
#! ${pkgs.runtimeShell} -e
|
|
|
|
|
2022-07-23 17:55:31 +02:00
|
|
|
case $1 in
|
2022-07-15 01:16:51 +02:00
|
|
|
ppp-uplink-a)
|
2022-07-23 17:55:31 +02:00
|
|
|
${pkgs.iproute2}/bin/ip -6 route flush table 20001 || true
|
2022-07-15 01:16:51 +02:00
|
|
|
;;
|
|
|
|
ppp-uplink-b)
|
2022-07-23 17:55:31 +02:00
|
|
|
${pkgs.iproute2}/bin/ip -6 route flush table 20002 || true
|
2022-07-15 01:16:51 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
'';
|
|
|
|
mode = "555";
|
|
|
|
};
|
|
|
|
}
|