From 6dd186d26fb86ba2e4f052a5320228d7234d9a92 Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Sat, 17 Aug 2024 14:52:15 +0300 Subject: [PATCH] Network : Use tcp/udp constants. --- host/home/Network.nix | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/host/home/Network.nix b/host/home/Network.nix index 0bd29272..e8bb5908 100644 --- a/host/home/Network.nix +++ b/host/home/Network.nix @@ -35,6 +35,10 @@ in { # Container configs. cfg = config.container.module; + # Const. + tcp = "tcp"; + udp = "udp"; + # Create port forwarding rule. mkForward = src: sport: dst: dport: proto: "iptables -t nat -I PREROUTING -d ${src} -p ${proto} --dport ${toString sport} -j DNAT --to-destination ${dst}:${toString dport}\n"; in '' @@ -48,33 +52,33 @@ in { iptables -I INPUT -j ACCEPT -i ${lan} -d ${internal} '' # Expose DNS server for internal network. - + (mkForward internal cfg.dns.port cfg.dns.address cfg.dns.port "tcp") - + (mkForward internal cfg.dns.port cfg.dns.address cfg.dns.port "udp") + + (mkForward internal cfg.dns.port cfg.dns.address cfg.dns.port tcp) + + (mkForward internal cfg.dns.port cfg.dns.address cfg.dns.port udp) # Email server. - + (mkForward external 25 cfg.mail.address 25 "tcp") - + (mkForward internal 25 cfg.mail.address 25 "tcp") - + (mkForward internal 465 cfg.mail.address 465 "tcp") - + (mkForward internal 993 cfg.mail.address 993 "tcp") + + (mkForward external 25 cfg.mail.address 25 tcp) + + (mkForward internal 25 cfg.mail.address 25 tcp) + + (mkForward internal 465 cfg.mail.address 465 tcp) + + (mkForward internal 993 cfg.mail.address 993 tcp) # FRKN internal proxy server. - + (mkForward internal cfg.zapret.port cfg.zapret.address cfg.zapret.port "tcp") - + (mkForward internal cfg.zapret.torport cfg.zapret.address cfg.zapret.torport "tcp") - + (mkForward internal cfg.zapret.port cfg.zapret.address cfg.zapret.port "udp") - + (mkForward internal cfg.zapret.torport cfg.zapret.address cfg.zapret.torport "udp") + + (mkForward internal cfg.zapret.port cfg.zapret.address cfg.zapret.port tcp) + + (mkForward internal cfg.zapret.torport cfg.zapret.address cfg.zapret.torport tcp) + + (mkForward internal cfg.zapret.port cfg.zapret.address cfg.zapret.port udp) + + (mkForward internal cfg.zapret.torport cfg.zapret.address cfg.zapret.torport udp) # Allow VPN connections from Wan. - + (mkForward external cfg.vpn.port cfg.vpn.address cfg.vpn.port "udp") + + (mkForward external cfg.vpn.port cfg.vpn.address cfg.vpn.port udp) # Nginx HTTP access from Wan. - + (mkForward external cfg.proxy.port cfg.proxy.address cfg.proxy.port "tcp") - + (mkForward internal cfg.proxy.port cfg.proxy.address cfg.proxy.port "tcp") + + (mkForward external cfg.proxy.port cfg.proxy.address cfg.proxy.port tcp) + + (mkForward internal cfg.proxy.port cfg.proxy.address cfg.proxy.port tcp) # Download ports for torrents. - + (mkForward external 54630 cfg.download.address 54630 "tcp") - + (mkForward external 54631 cfg.download.address 54631 "tcp") - + (mkForward external 54630 cfg.download.address 54630 "udp") - + (mkForward external 54631 cfg.download.address 54631 "udp") + + (mkForward external 54630 cfg.download.address 54630 tcp) + + (mkForward external 54631 cfg.download.address 54631 tcp) + + (mkForward external 54630 cfg.download.address 54630 udp) + + (mkForward external 54631 cfg.download.address 54631 udp) ; };