Hi!
I started fiddling with NFT on Qubes OS 4.2 and the official documentation is quite bad in this area. Let's gather material here so we could enhance the documentation once we have enough content.
I got port forwarding to work, that wasn't easy as the default ruleset didn't have a chain for the nat rules. I made a simple script where you just have to fill the port and the destination.
Typically, you would do:
sys-net
using sys-firewall
IP as a destinationsys-firewall
using the qube IP as a destinationThis is an example for a TCP redirection, for UDP you would have to replace tcp
by udp
.
#!/bin/sh
PORT=8000
DESTINATION=10.138.0.52
if ! nft -nn list table ip qubes | grep "chain nat {" ; then
nft add chain qubes nat { type nat hook prerouting priority dstnat\; }
fi
nft add rule qubes custom-input tcp dport "${PORT}" accept
nft add rule qubes custom-forward tcp dport "${PORT}" accept
nft add rule qubes nat iifname != "vif*" tcp dport "${PORT}" dnat "${DESTINATION}"
#!/bin/sh
PORT=8000
nft add rule qubes custom-input tcp dport "${PORT}" accept