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)

Afriza N. Arief
  • 121
  • 1
  • 4

2 Answers2

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

Something like this. :)

Andrey Kuznetsov
  • 169
  • 3
  • 12
MealstroM
  • 1,517
  • 1
  • 17
  • 32
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.

Afriza N. Arief
  • 121
  • 1
  • 4
  • 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 07:44