💾 Archived View for sdf.org › blippy › iptables.gmi captured on 2024-07-08 at 23:47:53. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2024-03-21)
-=-=-=-=-=-=-
Created 2022-06-12. Updated 2023-12-05
sudo apt install iptables iptables-persistent
The rules are stored in /etc/iptables/rules.v4 and .v6 .
Save rules using iptables-save.
Redirect port 70 to 7000:
sudo iptables -t nat -I PREROUTING --src 0/0 -p tcp --dport 70 -j REDIRECT --to-ports 7000 sudo iptables -t nat -I OUTPUT --src 0/0 -p tcp --dport 70 -j REDIRECT --to-ports 7000
Redirect port 300 to port 3000.:
sudo iptables -t nat -I PREROUTING --src 0/0 --dst 127.0.0.1 -p tcp --dport 300 -j REDIRECT --to-ports 3000 sudo iptables -t nat -I OUTPUT --src 0/0 --dst 127.0.0.1 -p tcp --dport 300 -j REDIRECT --to-ports 3000
It might have some snags, though.
The above won't survive reboot.