Test
This commit is contained in:
parent
a126b56b40
commit
2381911429
3 changed files with 128 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
||||||
{ config, lib, pkgs, modulesPath, desktop, username, ... }: {
|
{ config, lib, pkgs, modulesPath, desktop, username, ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
./disks.nix
|
./disks.nix
|
||||||
./xinetd.nix
|
./firewall.nix
|
||||||
./wireguard.nix
|
./wireguard.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
116
nixos/hosts/osaka-vultr-01/firewall.nix
Normal file
116
nixos/hosts/osaka-vultr-01/firewall.nix
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
{ 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 -A FORWARD -i ens3 -o wireguard0 -p tcp --syn --dport 80 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
iptables -A FORWARD -i ens3 -o wireguard0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
|
||||||
|
iptables -A FORWARD -i wireguard0 -o ens3 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
|
||||||
|
|
||||||
|
# TCP PORTS ##################################################################################################
|
||||||
|
# PORT 80
|
||||||
|
iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 80 -j DNAT --to-destination 10.100.0.2
|
||||||
|
iptables -t nat -A POSTROUTING -o wireguard0 -p tcp --dport 80 -d 10.100.0.2 -j SNAT --to-source 10.100.0.1
|
||||||
|
iptables -A FORWARD -i ens3 -o wireguard0 -p tcp --syn --dport 80 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
|
||||||
|
# PORT 443
|
||||||
|
iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 443 -j DNAT --to-destination 10.100.0.2
|
||||||
|
iptables -t nat -A POSTROUTING -o wireguard0 -p tcp --dport 443 -d 10.100.0.2 -j SNAT --to-source 10.100.0.1
|
||||||
|
iptables -A FORWARD -i ens3 -o wireguard0 -p tcp --syn --dport 443 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
|
||||||
|
# PORT 25
|
||||||
|
iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 25 -j DNAT --to-destination 10.100.0.2
|
||||||
|
iptables -t nat -A POSTROUTING -o wireguard0 -p tcp --dport 25 -d 10.100.0.2 -j SNAT --to-source 10.100.0.1
|
||||||
|
iptables -A FORWARD -i ens3 -o wireguard0 -p tcp --syn --dport 25 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
|
||||||
|
# PORT 465
|
||||||
|
iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 465 -j DNAT --to-destination 10.100.0.2
|
||||||
|
iptables -t nat -A POSTROUTING -o wireguard0 -p tcp --dport 465 -d 10.100.0.2 -j SNAT --to-source 10.100.0.1
|
||||||
|
iptables -A FORWARD -i ens3 -o wireguard0 -p tcp --syn --dport 465 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
|
||||||
|
# PORT 587
|
||||||
|
iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 587 -j DNAT --to-destination 10.100.0.2
|
||||||
|
iptables -t nat -A POSTROUTING -o wireguard0 -p tcp --dport 587 -d 10.100.0.2 -j SNAT --to-source 10.100.0.1
|
||||||
|
iptables -A FORWARD -i ens3 -o wireguard0 -p tcp --syn --dport 587 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
|
||||||
|
# PORT 143
|
||||||
|
iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 143 -j DNAT --to-destination 10.100.0.2
|
||||||
|
iptables -t nat -A POSTROUTING -o wireguard0 -p tcp --dport 143 -d 10.100.0.2 -j SNAT --to-source 10.100.0.1
|
||||||
|
iptables -A FORWARD -i ens3 -o wireguard0 -p tcp --syn --dport 143 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
|
||||||
|
# PORT 993
|
||||||
|
iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 993 -j DNAT --to-destination 10.100.0.2
|
||||||
|
iptables -t nat -A POSTROUTING -o wireguard0 -p tcp --dport 993 -d 10.100.0.2 -j SNAT --to-source 10.100.0.1
|
||||||
|
iptables -A FORWARD -i ens3 -o wireguard0 -p tcp --syn --dport 993 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
|
||||||
|
# PORT 4190
|
||||||
|
iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 4190 -j DNAT --to-destination 10.100.0.2
|
||||||
|
iptables -t nat -A POSTROUTING -o wireguard0 -p tcp --dport 4190 -d 10.100.0.2 -j SNAT --to-source 10.100.0.1
|
||||||
|
iptables -A FORWARD -i ens3 -o wireguard0 -p tcp --syn --dport 4190 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
|
||||||
|
# PORT 42420
|
||||||
|
iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 42420 -j DNAT --to-destination 10.100.0.2
|
||||||
|
iptables -t nat -A POSTROUTING -o wireguard0 -p tcp --dport 42420 -d 10.100.0.2 -j SNAT --to-source 10.100.0.1
|
||||||
|
iptables -A FORWARD -i ens3 -o wireguard0 -p tcp --syn --dport 42420 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
|
||||||
|
# PORT 25565
|
||||||
|
iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 25565 -j DNAT --to-destination 10.100.0.2
|
||||||
|
iptables -t nat -A POSTROUTING -o wireguard0 -p tcp --dport 25565 -d 10.100.0.2 -j SNAT --to-source 10.100.0.1
|
||||||
|
iptables -A FORWARD -i ens3 -o wireguard0 -p tcp --syn --dport 25565 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
|
||||||
|
# PORT 1443
|
||||||
|
iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 1443 -j DNAT --to-destination 10.100.0.2
|
||||||
|
iptables -t nat -A POSTROUTING -o wireguard0 -p tcp --dport 1443 -d 10.100.0.2 -j SNAT --to-source 10.100.0.1
|
||||||
|
iptables -A FORWARD -i ens3 -o wireguard0 -p tcp --syn --dport 1443 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
|
||||||
|
# PORT 4443
|
||||||
|
iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 4443 -j DNAT --to-destination 10.100.0.2
|
||||||
|
iptables -t nat -A POSTROUTING -o wireguard0 -p tcp --dport 4443 -d 10.100.0.2 -j SNAT --to-source 10.100.0.1
|
||||||
|
iptables -A FORWARD -i ens3 -o wireguard0 -p tcp --syn --dport 4443 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
|
||||||
|
# PORT 5222
|
||||||
|
iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 5222 -j DNAT --to-destination 10.100.0.2
|
||||||
|
iptables -t nat -A POSTROUTING -o wireguard0 -p tcp --dport 5222 -d 10.100.0.2 -j SNAT --to-source 10.100.0.1
|
||||||
|
iptables -A FORWARD -i ens3 -o wireguard0 -p tcp --syn --dport 5222 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
|
||||||
|
# PORT 5347
|
||||||
|
iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 5347 -j DNAT --to-destination 10.100.0.2
|
||||||
|
iptables -t nat -A POSTROUTING -o wireguard0 -p tcp --dport 5347 -d 10.100.0.2 -j SNAT --to-source 10.100.0.1
|
||||||
|
iptables -A FORWARD -i ens3 -o wireguard0 -p tcp --syn --dport 5347 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
|
||||||
|
# PORT 5280
|
||||||
|
iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 5280 -j DNAT --to-destination 10.100.0.2
|
||||||
|
iptables -t nat -A POSTROUTING -o wireguard0 -p tcp --dport 5280 -d 10.100.0.2 -j SNAT --to-source 10.100.0.1
|
||||||
|
iptables -A FORWARD -i ens3 -o wireguard0 -p tcp --syn --dport 5280 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
|
||||||
|
# UDP PORTS ##################################################################################################
|
||||||
|
# PORT 10000
|
||||||
|
iptables -t nat -A PREROUTING -i ens3 -p udp --dport 10000 -j DNAT --to-destination 10.100.0.2
|
||||||
|
iptables -t nat -A POSTROUTING -o wireguard0 -p udp --dport 10000 -d 10.100.0.2 -j SNAT --to-source 10.100.0.1
|
||||||
|
iptables -A FORWARD -i ens3 -o wireguard0 -p udp --syn --dport 10000 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
|
||||||
|
# PORT 3478
|
||||||
|
iptables -t nat -A PREROUTING -i ens3 -p udp --dport 3478 -j DNAT --to-destination 10.100.0.2
|
||||||
|
iptables -t nat -A POSTROUTING -o wireguard0 -p udp --dport 3478 -d 10.100.0.2 -j SNAT --to-source 10.100.0.1
|
||||||
|
iptables -A FORWARD -i ens3 -o wireguard0 -p udp --syn --dport 3478 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
'';
|
||||||
|
}
|
|
@ -22,12 +22,15 @@
|
||||||
];
|
];
|
||||||
|
|
||||||
networking.firewall.extraCommands = ''
|
networking.firewall.extraCommands = ''
|
||||||
${pkgs.iptables}/bin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to 64.176.54.57:80
|
${pkgs.iptables}/bin/iptables -A FORWARD -i ens3 -o wireguard0 -p tcp --syn --dport 80 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
${pkgs.iptables}/bin/iptables -t nat -A OUTPUT -d 10.100.0.2 -p tcp --dport 80 -j DNAT --to 64.176.54.57:80
|
${pkgs.iptables}/bin/iptables -A FORWARD -i ens3 -o wireguard0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
|
||||||
${pkgs.iptables}/bin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j DNAT --to 64.176.54.57:443
|
${pkgs.iptables}/bin/iptables -A FORWARD -i wireguard0 -o ens3 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
|
||||||
${pkgs.iptables}/bin/iptables -t nat -A OUTPUT -d 10.100.0.2 -p tcp --dport 443 -j DNAT --to 64.176.54.57:443
|
${pkgs.iptables}/bin/iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 80 -j DNAT --to-destination 10.100.0.2
|
||||||
${pkgs.iptables}/bin/iptables -t nat -A PREROUTING -i eth0 -p udp --dport 10000 -j DNAT --to 64.176.54.57:10000
|
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -o wireguard0 -p tcp --dport 80 -d 10.100.0.2 -j SNAT --to-source 10.100.0.1
|
||||||
${pkgs.iptables}/bin/iptables -t nat -A OUTPUT -d 10.100.0.2 -p udp --dport 10000 -j DNAT --to 64.176.54.57:10000
|
${pkgs.iptables}/bin/iptables -A FORWARD -i ens3 -o wireguard0 -p tcp --syn --dport 80 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
${pkgs.iptables}/bin/iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 443 -j DNAT --to-destination 10.100.0.2
|
||||||
|
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -o wireguard0 -p tcp --dport 443 -d 10.100.0.2 -j SNAT --to-source 10.100.0.1
|
||||||
|
${pkgs.iptables}/bin/iptables -A FORWARD -i ens3 -o wireguard0 -p tcp --syn --dport 443 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
'';
|
'';
|
||||||
|
|
||||||
services.xinetd = {
|
services.xinetd = {
|
||||||
|
|
Loading…
Reference in a new issue