I have a dedicated server from serverloft.eu, but due to some network security I cannot use bridge networking on my server. So I have setup all my IPs to the main eth0, and used NAT to forward trafic from the main eth0 to the internal network. But I have encounted a problem, services on my virtual servers cannot connect to itself using the public ip, ie. telnet 192.168.122.3 80 works fine, but telnet pub.lic.ip.xx 80 times out. (When entered on the virual machine with ip 192.168.122.3)
My iptables script looks like this:
#!bin/sh
iptables -F
iptables -t nat -F
iptables -P FORWARD ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PORTS="22 25 110 143 587 993 995"
for port in $PORTS;
do
iptables -t nat -A PREROUTING -p tcp -d xx.xx.xx.189 --dport $port -j DNAT --to 192.168.122.2:$port
done
PORTS="22 80 443"
for port in $PORTS;
do
iptables -t nat -A PREROUTING -p tcp -d xx.xx.xx.173 --dport $port -j DNAT --to 192.168.122.3:$port
done
PORTS="22 3306 5432"
for port in $PORTS;
do
iptables -t nat -A PREROUTING -p tcp -d xx.xx.xx.174 --dport $port -j DNAT --to 192.168.122.4:$port
iptables -t nat -A PREROUTING -p udp -d xx.xx.xx.174 --dport $port -j DNAT --to 192.168.122.4:$port
done
What am I missing?