nix/nixos/hosts/osaka-linode-01/firewall.nix
2023-12-06 19:48:09 +09:00

43 lines
No EOL
2.5 KiB
Nix

{ config, lib, pkgs, ... }: {
networking.firewall.allowedUDPPorts = [
3478 # Headscale DERP UDP
10000 # Jitsi
];
networking.firewall.allowedTCPPorts = [
80 # HTTP
443 # HTTPS
25 # SMTP (explicit TLS => STARTTLS)
465 # ESMTP (implicit TLS)
587 # ESMTP (explicit TLS => STARTTLS)
143 # IMAP4 (explicit TLS => STARTTLS)
993 # IMAP4 (implicit TLS)
4190 # Sieve support
42420 # Vintage Story
25565 # Minecraft
1443 # Headscale DERP
4443 # jitsi-jvb
5222 # Jitsi
5347 # Jitsi
5280 # Jitsi
];
networking.firewall.extraCommands = ''
iptables -t nat -A PREROUTING -i enp0s4 -d 172.234.84.222 --dport 80 -j DNAT --to-destination 10.100.0.2
iptables -t nat -A PREROUTING -i enp0s4 -d 172.234.84.222 --dport 443 -j DNAT --to-destination 10.100.0.2
iptables -t nat -A PREROUTING -i enp0s4 -d 172.234.84.222 --dport 25 -j DNAT --to-destination 10.100.0.2
iptables -t nat -A PREROUTING -i enp0s4 -d 172.234.84.222 --dport 465 -j DNAT --to-destination 10.100.0.2
iptables -t nat -A PREROUTING -i enp0s4 -d 172.234.84.222 --dport 587 -j DNAT --to-destination 10.100.0.2
iptables -t nat -A PREROUTING -i enp0s4 -d 172.234.84.222 --dport 143 -j DNAT --to-destination 10.100.0.2
iptables -t nat -A PREROUTING -i enp0s4 -d 172.234.84.222 --dport 993 -j DNAT --to-destination 10.100.0.2
iptables -t nat -A PREROUTING -i enp0s4 -d 172.234.84.222 --dport 4190 -j DNAT --to-destination 10.100.0.2
iptables -t nat -A PREROUTING -i enp0s4 -d 172.234.84.222 --dport 42420 -j DNAT --to-destination 10.100.0.2
iptables -t nat -A PREROUTING -i enp0s4 -d 172.234.84.222 --dport 25565 -j DNAT --to-destination 10.100.0.2
iptables -t nat -A PREROUTING -i enp0s4 -d 172.234.84.222 --dport 1443 -j DNAT --to-destination 10.100.0.2
iptables -t nat -A PREROUTING -i enp0s4 -d 172.234.84.222 --dport 4443 -j DNAT --to-destination 10.100.0.2
iptables -t nat -A PREROUTING -i enp0s4 -d 172.234.84.222 --dport 5222 -j DNAT --to-destination 10.100.0.2
iptables -t nat -A PREROUTING -i enp0s4 -d 172.234.84.222 --dport 5347 -j DNAT --to-destination 10.100.0.2
iptables -t nat -A PREROUTING -i enp0s4 -d 172.234.84.222 --dport 5280 -j DNAT --to-destination 10.100.0.2
iptables -t nat -A PREROUTING -i enp0s4 -d 172.234.84.222 --dport 10000 -j DNAT --to-destination 10.100.0.2
iptables -t nat -A PREROUTING -i enp0s4 -d 172.234.84.222 --dport 3478 -j DNAT --to-destination 10.100.0.2
'';
}