Skip to content

Instantly share code, notes, and snippets.

@ZiTAL
Last active February 23, 2024 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZiTAL/7513509c64541549b4ab291fcb7b485f to your computer and use it in GitHub Desktop.
Save ZiTAL/7513509c64541549b4ab291fcb7b485f to your computer and use it in GitHub Desktop.
debian gnu/linux: redirect ports to work locally
#!/bin/bash
# reset iptables rules
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
# redirect ports
iptables -t nat -I OUTPUT --src 0/0 --dst 127.0.0.1 -p tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -I OUTPUT --src 0/0 --dst 127.0.0.1 -p tcp --dport 443 -j REDIRECT --to-ports 8083
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment