[CentOS] DNAT Internet gate problem on centos

Andreas Benzler andreas at benzlerweb.de
Sun Apr 2 19:39:52 UTC 2017


Now i know why you wait, when I ask. Depends on time I will find a (my)
way. :-)

#!/bin/sh
IPTBLV4=/usr/sbin/iptables

if [ $# -eq 0 ]
  then
    echo "No arguments supplied"
   GATE=XX.XX.XX.XX
  else
   GATE=$1
fi

nslookup $GATE

echo "1" > /proc/sys/net/ipv4/ip_forward

$IPTBLV4 -F -t nat

$IPTBLV4 -t nat -A PREROUTING -p tcp --dport PORT1 -j DNAT
--to-destination $GATE:PORT1
$IPTBLV4 -t nat -A PREROUTING -p tcp --dport PORT2 -j DNAT
--to-destination $GATE:PORT2

.
.
.
.

#global 
$IPTBLV4 -t nat -A POSTROUTING -j MASQUERADE

$IPTBLV4 -L -t nat -v

/usr/sbin/service iptables save 

This works on the vserver to the gate -> transparent to local gate ->
transparent to network again -> local machines.

Why? I don't like my provider, but he's the fastest and cheapest in
town. 

The people of today are just too curious.

Sincerely

Andy




More information about the CentOS mailing list