Skip to content

Instantly share code, notes, and snippets.

@juniorctl
Forked from Marko-M/iptables-port-forward.sh
Last active April 27, 2016 19:10
Show Gist options
  • Select an option

  • Save juniorctl/0cfe809ec663ef2f05464cb22f977416 to your computer and use it in GitHub Desktop.

Select an option

Save juniorctl/0cfe809ec663ef2f05464cb22f977416 to your computer and use it in GitHub Desktop.
Forward Vagrant forwarded ports to standard ports using iptables
#!/bin/bash
# Forward relevant Vagrant forwarded ports to standard ports using iptables (adjust 8080, 8443).
# To make persistent install and use "iptables-persistent" package. Just do a
# "sudo service iptables-persistent save" and service will reload saved rules on each boot.
sudo iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 8080
sudo iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 443 -j REDIRECT --to-ports 8443
sudo iptables -L -n -t nat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment