2021-04-14 20:04:28 +02:00
|
|
|
{ hostName, config, lib, ... }:
|
|
|
|
|
2024-02-05 03:45:05 +01:00
|
|
|
let
|
|
|
|
hostConfig = config.site.hosts.${hostName};
|
|
|
|
|
|
|
|
in
|
|
|
|
lib.mkIf hostConfig.firewall.enable {
|
2021-04-14 20:04:28 +02:00
|
|
|
networking.firewall = {
|
|
|
|
enable = true;
|
|
|
|
extraCommands = ''
|
2024-02-05 03:45:05 +01:00
|
|
|
${lib.optional hostConfig.isRouter ''
|
|
|
|
ip46tables -I nixos-fw -p ospfigp -j ACCEPT
|
|
|
|
''}
|
|
|
|
|
2021-04-14 20:04:28 +02:00
|
|
|
ip46tables -A FORWARD -i core -m state --state ESTABLISHED,RELATED -j ACCEPT
|
2024-02-04 22:33:47 +01:00
|
|
|
ip46tables -A FORWARD -i core -j REJECT
|
2021-04-14 20:04:28 +02:00
|
|
|
'';
|
|
|
|
extraStopCommands = ''
|
|
|
|
ip46tables -F FORWARD
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|