2

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)

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

Something like this. :)

2
  • iptables v1.4.7: unknown option --dport' Try iptables -h' or 'iptables --help' for more information. Mar 25 '11 at 14:37
  • @afriza I updated the answer. You need to specify protocol using -p option Jul 2 '14 at 10:53
0

sudo iptables -t nat -I PREROUTING -p tcp -i eth0 --dport 8000 -j DNAT --to-destination 127.0.0.1:80

the above command succeeds but both /proc/sys/net/ipv4/conf/eth0/forwarding and /proc/sys/net/ipv4/ip_forward contains 0 and are not writable even after using sudo.

1
  • check /etc/sysctl.conf. There you should add something like this net.ipv4.ip_forward = 1 for ../net/ipv4/ip_forward this should help
    – MealstroM
    Mar 28 '11 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.