Skip to content

Instantly share code, notes, and snippets.

@nfhipona
Forked from siddhuwarrier/ubuntu_port_forwarding
Last active June 9, 2020 06:27
Show Gist options
  • Save nfhipona/529639a6bbdac82ec003d16e04916e0d to your computer and use it in GitHub Desktop.
Save nfhipona/529639a6bbdac82ec003d16e04916e0d to your computer and use it in GitHub Desktop.
Port forward from port 9000 to port 80 on an Ubuntu machine using IPtables (exposing Sonar on port 80)

Setting up port for re-routing requests: ex. req to port: 8080 -> port 9000

  • iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 9000
  • iptables-save

Example:

sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 4776
sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 4776
sudo iptables-save

list the current firewall rules

  • iptables --table nat --list
or using the options short form
  • iptables -t nat -L

copy file to path using ssh

  • scp -i security.pem /path-to-file instance.route.amazonaws.com:~/home-folder

checking active connections

  • netstat -t -u -c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment