Skip to content

Instantly share code, notes, and snippets.

@JeremyJaydan
Created September 27, 2023 12:25
Show Gist options
  • Save JeremyJaydan/62136baa68b7818b2b7ab58e69775719 to your computer and use it in GitHub Desktop.
Save JeremyJaydan/62136baa68b7818b2b7ab58e69775719 to your computer and use it in GitHub Desktop.
forward_port_80_to(){
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port $1
sudo iptables -t nat -S PREROUTING | grep 'dport 80' | grep -v $1 | sed s/-A/-D/ | while read -r delete_rule; do
sudo iptables -t nat $delete_rule
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment