2024-08-30 01:17:50 -04:00
|
|
|
{outputs, ...}: {
|
2024-08-24 22:16:51 -04:00
|
|
|
# Allow forwarding
|
|
|
|
boot.kernel.sysctl."net.ipv4.ip_forward" = 1;
|
|
|
|
|
|
|
|
# Configure firewall
|
|
|
|
networking = let
|
2024-08-24 22:32:58 -04:00
|
|
|
ips = import ../modules/ips.nix;
|
2024-08-24 22:16:51 -04:00
|
|
|
in {
|
|
|
|
firewall = {
|
|
|
|
allowPing = false;
|
|
|
|
allowedTCPPortRanges = [
|
|
|
|
{ from = 8100; to = 8150; } # Azuracast
|
|
|
|
];
|
|
|
|
|
|
|
|
# Add extra input rules using nftables
|
|
|
|
extraInputRules = ''
|
|
|
|
ip saddr ${ips.localSpan}.0/24 tcp dport 2049 accept comment "Accept NFS"
|
2024-08-30 01:17:50 -04:00
|
|
|
ip saddr { ${ips.pc}, ${outputs.secrets.lunaIP}, ${outputs.secrets.cornIP}, ${outputs.secrets.vertIP} } tcp dport { 1935, 1945 } accept comment "Accept RTMP"
|
2024-08-24 22:16:51 -04:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
# Enable nftables and forwarding
|
|
|
|
nftables = {
|
|
|
|
enable = true;
|
|
|
|
tables = {
|
|
|
|
forwarding = {
|
|
|
|
family = "ip";
|
|
|
|
content = ''
|
|
|
|
chain PREROUTING {
|
|
|
|
type nat hook prerouting priority dstnat; policy accept;
|
|
|
|
tcp dport 2211 dnat to ${ips.pc}:22 comment "SSH to PC"
|
|
|
|
udp dport { 27005, 27015, 7777 } dnat to ${ips.pc} comment "Games to PC"
|
|
|
|
|
|
|
|
tcp dport { 58010, 57989, 57984 } dnat to ${ips.pc} comment "Sunshine TCP to PC"
|
|
|
|
udp dport { 57998, 57999, 58000 } dnat to ${ips.pc} comment "Sunshine UDP to PC"
|
|
|
|
|
|
|
|
tcp dport { 38010, 37989, 37984 } dnat to ${ips.vm} comment "Sunshine TCP to VM"
|
|
|
|
udp dport { 37998, 37999, 38000 } dnat to ${ips.vm} comment "Sunshine UDP to VM"
|
|
|
|
|
2024-08-30 01:17:50 -04:00
|
|
|
ip saddr ${outputs.secrets.cornIP} tcp dport { 9943, 9944 } dnat to ${ips.vm} comment "ALVR TCP to VM"
|
|
|
|
ip saddr ${outputs.secrets.cornIP} udp dport { 9943, 9944 } dnat to ${ips.vm} comment "ALVR UDP to VM"
|
2024-08-24 22:16:51 -04:00
|
|
|
}
|
|
|
|
chain POSTROUTING {
|
|
|
|
type nat hook postrouting priority 100; policy accept;
|
|
|
|
oifname "${ips.netInt}" masquerade
|
2024-09-06 01:18:21 -04:00
|
|
|
ip saddr 10.100.0.0/24 oifname "${ips.netInt}" masquerade comment "WireGuard"
|
2024-08-24 22:16:51 -04:00
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|