PDA

View Full Version : DNAT an ip via the gateway


pyutor
2006-06-13, 02:55 AM CDT
Hi.

I've been provided with severeal IP's from my ISP and I currently have 1 IP assigned to my gateway.

I wish to put a monitoring server behind my gateway that's accessable with another IP than the one that's assigned to my gateway.

By googling i've understood that I need to use PREROUTING/POSTROUTING and DNAT/SNAT to accomplish this. Though I think that I need 2 rules for doing this.

I've began some but I'm not sure that I'm going the right way.

iptables -t nat -A PREROUTING -i eth1 -s <external_ip> -j DNAT --to-destination <internal_ip>
iptables -t nat -A POSTROUTING -o eth0 -s <internal_ip> -j SNAT --to-source <external_ip>

Please advise.