NixOS-Config/modules/system/devices/networking/firewall/server/default.nix

51 lines
2 KiB
Nix
Raw Normal View History

{ config, ... }:
2024-10-09 03:36:08 -04:00
{
2024-08-24 22:16:51 -04:00
# Allow forwarding
boot.kernel.sysctl."net.ipv4.ip_forward" = 1;
# Configure firewall
2024-10-22 08:02:35 -04:00
networking = {
2024-08-24 22:16:51 -04:00
firewall = {
allowPing = false;
extraInputRules = ''
ip saddr { ${config.ips.localSpan}.0/24, ${config.ips.wgSpan}.0/24 } tcp dport 2049 accept comment "Accept NFS"
ip saddr { ${config.ips.pc}, ${config.secrets.lunaIP}, ${config.secrets.cornIP} } tcp dport { 1935, 1945 } accept comment "Accept RTMP"
2024-08-24 22:16:51 -04:00
'';
};
# Enable nftables and forwarding
nftables = {
tables = {
forwarding = {
family = "ip";
content = ''
chain PREROUTING {
type nat hook prerouting priority dstnat; policy accept;
tcp dport 2211 dnat to ${config.ips.pc}:22 comment "SSH to PC"
2024-10-20 19:43:18 -04:00
tcp dport 2222 dnat to ${config.ips.wgSpan}.19:22 comment "SSH to Oracle VM"
2024-09-12 01:31:59 -04:00
udp dport { 27005, 27015, 7777 } dnat to ${config.ips.pc} comment "PC Hosted Games"
2024-09-12 01:31:59 -04:00
tcp dport { 58010, 57989, 57984 } dnat to ${config.ips.pc} comment "PC Sunshine TCP"
udp dport { 57998, 57999, 58000 } dnat to ${config.ips.pc} comment "PC Sunshine UDP"
2024-09-12 01:31:59 -04:00
tcp dport { 38010, 37989, 37984 } dnat to ${config.ips.vm} comment "VM Sunshine TCP"
udp dport { 37998, 37999, 38000 } dnat to ${config.ips.vm} comment "VM Sunshine UDP"
2024-09-12 01:31:59 -04:00
udp dport { 7790, 7791, 7792 } dnat to ${config.ips.hx} comment "Deus Ex"
2024-09-12 01:31:59 -04:00
ip saddr ${config.secrets.cornIP} tcp dport { 9943, 9944 } dnat to ${config.ips.vm} comment "VM ALVR TCP"
ip saddr ${config.secrets.cornIP} udp dport { 9943, 9944 } dnat to ${config.ips.vm} comment "VM ALVR UDP"
2024-08-24 22:16:51 -04:00
}
2024-08-24 22:16:51 -04:00
chain POSTROUTING {
type nat hook postrouting priority 100; policy accept;
oifname "${config.ips.netInt}" masquerade
2024-08-24 22:16:51 -04:00
}
'';
};
};
};
};
}