DNAT Internet Gate Problem On CentOS

Home » CentOS » DNAT Internet Gate Problem On CentOS
CentOS 2 Comments

Hello Guys,

I got trouble to get vserver work as gate:

GATE=XX.XX.XX.XX

YY_PORT=YY

echo “1” > /proc/sys/net/ipv4/ip_forward

iptables -F -t nat

iptables -t nat -A PREROUTING -p tcp -i venet0:0 –dport $YY_PORT \
-j DNAT –to-destination $GATE:$YY_PORT

iptables -t nat -A POSTROUTING -p tcp –dport $YY_PORT \
-j MASQUERADE

iptables -L -t nat

Any suggestion? I got it in the past, but now I’m completely confused.

Thanks for help.

Sincerely

Andy

2 thoughts on - DNAT Internet Gate Problem On CentOS

  • 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