0

We have an EC2 server with 400 domains / vhosts on amazon's ec2. We use just one single public IP (1.1.1.1). Because of NAT we use the internal IP (10.1.2.0) in apaches config. So far so good.

Some cronscripts need to access the hosted domains but these cronjobs are also hosted on the same machine. Because of the NAT it's not possible to reach any of the hosted domains by hostname from the localhost. I've been trying to figure it out with iptables, but no luck

Looks like this is not working:

iptables -t nat -A PREROUTING -p tcp -d 1.1.1.1 -j DNAT --to 10.1.2.0

Any thoughts? Of course i can add al 400+ domains to /etc/hosts, but then i have to keep track of all the domains and it isnt very flexible. Ofcourse we can also change the way the cronjobs are working, but we need a 'quick' fix right now. Is this possible with iptables?

4

1 回答 1

0

如果我理解正确,您希望重定向来自同一台机器的流量。在这种情况下,您应该使用 OUTPUT 链。来自本地进程的数据包不通过 POSTROUTING 链。

于 2013-03-04T15:18:49.857 回答