Multiple IP Address with port forwarding

I am using SME Server 7.1 (2.6.9 Kernel) as a gateway, and I have set up multiple IP addresses on one external facing network card, and I have one internal facing network card.  I would like to forward ports on to various servers on my network, i.e. X.X.X.17:80 goes to, X.X.X.18:80 goes to  

In my /etc/rc.d/init.d/masq file, I have the following entries:
    /sbin/iptables --table nat --new-chain PortForwarding_$$
    /sbin/iptables --table nat --append PortForwarding_$$ --protocol tcp -d X.X.X.18/32 --destination-port 80 -j DNAT --to-destination
    adjust_tcp_in 80 ACCEPT ForwardedTCP_$$

From what I understand, this should forward all incomming requests to X.X.X.18:80 to, but when I try to access this web site, it times out.

Can anyone explain what I am doing wrong, or how to go about doing this?

Many Thanks in advance.
Who is Participating?
NopiusConnect With a Mentor Commented:
Standard table 'nat' has only 3 chains PREROUTING, OUTPUT and POSTROUTING. You have added 1 new chain and didn't referenced to it from any standard chain. Try to add a reference in a PREROUTING chain:
iptables --table nat -A PREROUTING -j  PortForwarding_$$
rtwildeAuthor Commented:
OK, this is what I found that works, this issue seemed to be exactly what Nopius desribed.
This forwards incomming http requests from external address X.X.X.17 to, and from X.X.X.18 to

iptables -I PREROUTING -t nat -p tcp --dport 80 -d X.X.X.17 -j DNAT --to
iptables -I FORWARD -p tcp -d --dport 80 -i eth1 -o eth0 -j ACCEPT
iptables -A POSTROUTING -t nat -o eth1 -p tcp -s -j SNAT --to-source X.X.X.17
iptables -I PREROUTING -t nat -p tcp --dport 80 -d X.X.X.18 -j DNAT --to
iptables -I FORWARD -p tcp -d --dport 80 -i eth1 -o eth0 -j ACCEPT
iptables -A POSTROUTING -t nat -o eth1 -p tcp -s -j SNAT --to-source X.X.X.18
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.