Linux – alias port / port forwarding to another local port

amazon ec2amazon-web-servicesiptableslinuxport-forwarding

I am using Amazon Linux AMI in EC2.

Previously they allow me to enter different external port from internal port in the AWS web console (in the security groups). Now they only allow the same port for both internal and external port.

I need to have the same daemon to be visible from both port 80 and 8000. The daemon is now running on port 80.

How do I "port-forward" port 8000 to 80 in the same instance?

I am using the free usage tier (micro instance with Amazon Linux AMI)

Best Answer

iptables -t nat -A PREROUTING -p tcp --dport 8000 -j REDIRECT --to-port 80

Something like this. :)