alias port / port forwarding to another local port

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

Something like this. :)

Share:
5,269

Related videos on Youtube

Afriza N. Arief
Author by

Afriza N. Arief

I was Born in Java.

Updated on September 17, 2022

Comments

  • Afriza N. Arief
    Afriza N. Arief over 1 year

    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)

  • Afriza N. Arief
    Afriza N. Arief about 13 years
    iptables v1.4.7: unknown option --dport' Try iptables -h' or 'iptables --help' for more information.
  • bonsoy
    bonsoy about 13 years
    check /etc/sysctl.conf. There you should add something like this net.ipv4.ip_forward = 1 for ../net/ipv4/ip_forward this should help
  • Andrey Kuznetsov
    Andrey Kuznetsov almost 10 years
    @afriza I updated the answer. You need to specify protocol using -p option