ubuntu

Redirect requests to port 80 using iptables on Ubuntu 13

On an Ubuntu server, the following command will create a rule in iptables that redirects any requests from port 80 to port 4567.

$ sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 4567

To make this rule persist across system reboots, open up the rc.local file

$ sudo vi /etc/rc.local

and add the following line

iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 4567

more Ubuntu posts