1
0
vcp-bula-nixfiles/hosts/router/ppp.nix
2022-07-15 01:16:51 +02:00

70 lines
1.5 KiB
Nix

{ config, pkgs, ... }:
{
# Setting default routes based on interfaces in different tables
environment.etc."ppp/ip-up" = {
text = ''
#! ${pkgs.runtimeShell} -e
case $IFNAME in
ppp-uplink-a)
ip route flush table 20001 || true
ip route add default dev ppp-uplink-a table 20001
;;
ppp-uplink-b)
ip route flush table 20002 || true
ip route add default dev ppp-uplink-b table 20002
;;
esac
'';
mode = "555";
};
environment.etc."ppp/ip-down" = {
text = ''
#! ${pkgs.runtimeShell} -e
case $IFNAME in
ppp-uplink-a)
ip route flush table 20001 || true
;;
ppp-uplink-b)
ip route flush table 20002 || true
;;
esac
'';
mode = "555";
};
environment.etc."ppp/ipv6-up" = {
text = ''
#! ${pkgs.runtimeShell} -e
case $IFNAME in
ppp-uplink-a)
ip -6 route flush table 20001 || true
ip -6 route add default dev ppp-uplink-a table 20001
;;
ppp-uplink-b)
ip -6 route flush table 20002 || true
ip -6 route add default dev ppp-uplink-b table 20002
;;
esac
'';
mode = "555";
};
environment.etc."ppp/ipv6-down" = {
text = ''
#! ${pkgs.runtimeShell} -e
case $IFNAME in
ppp-uplink-a)
ip -6 route flush table 20001 || true
;;
ppp-uplink-b)
ip -6 route flush table 20002 || true
;;
esac
'';
mode = "555";
};
}