port forwarding to internal web-server using iptables
Greetings to all!
We are re-configuring our network. We want to route all external traffic through a dual-NIC gateway machine which will be running squid along with iptables. The clients are currently directly connected to the internet ie on each of them, the ISP's router is set as the gateway. We want the clients to connect to the internet through the gateway machine. The gateway machine would, in turn, connect to the ISP's router.
I'm now halfway into the migration process. The squid machine is up and running and all the clients (now with internal IPs) can connect to the net. However,the problem is that, we also have two web-servers running on internal machines plus a DNS server on another machine which need to be accessible from outside. Before the re-configuration, all these machines had public IPs and hence were accessible from outside, but now, after their conversion to local addresses, this is no longer the case.
I want to use iptables to set up port forwarding at the gateway so that any TCP or DNS request automatically gets forwarded to the relevant machines.
Two questions are plaguing me however:
1)will it be necessary to actually set the (external)IPs of the web and dns servers on the gateway machine or will iptables trap the packets by simply observingthe IP adds of the packets when they are routed to the gateway machine from the ISP end?
2)what will be the NATting rules like? will it be something like:
#iptables -t nat -I PREROUTING -p tcp -i eth0 --dport 80 -j DNAT --to-dest\
Any help will be gratefully accepted.
Thanks in advance!