[CentOS] route question

Jerry Geis geisj at pagestation.com
Sat May 15 14:34:20 UTC 2010


>
> This sounds more like a destination NAT issue then a routing issue.
>
> If I'm correct you have a server behind eth0 that handles traffic
> forwarded to it from either eth1 or eth2. So if someone types in the
> IP address of eth2 (or eth1) in their browser they'll get your server
> behind eth0. Am I correct?
>
> If so, what you want to look at is something called "destination NAT"
> or "port forwarding."
>
> -- 
> Drew
>   
Drew,

I have a script that runs that sets all that up.

MYIP="74.223.8.179"
GWIP="192.168.1.1"

/sbin/modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward

# setup port 22
iptables -t nat -A PREROUTING -p tcp -d $MYIP --dport 22 -j DNAT --to 
192.168.1.58:22
iptables -t nat -A POSTROUTING -d 192.168.1.58 -j SNAT --to $GWIP
# Setup the port for sendmail
iptables -t nat -A PREROUTING -p tcp -d $MYIP --dport 25 -j DNAT --to 
192.168.1.58:25
iptables -t nat -A POSTROUTING -d 192.168.1.58 -j SNAT --to $GWIP

Again - i have the same kind of thing for the 24.X network and it works 
fine.

I searched for "Destination nat" just to make sure I did not miss 
something and it looks like what I have above.

Thanks,

jerry



More information about the CentOS mailing list