Skip to contentSkip to conversation

Iptables Forwarding Vnc Connection

DISCUSSION Nathanael Morrison 2 participants 2 messages Feb 14, 2003 – Feb 17, 2003

lore
Share & tools
lore
#0 lore raw

Hi,

I currently have several computers behind a linux gateway, one of which is my personal computer. I often want to access my desktop from campus using KDE's remote desktop feature. At the moment I forward any connections to port 5900 to my pc. This works but then I thought, wouldn't it be nice if I could to this securely with an ssh tunnel Correct me if I'm wrong but, I think the connection gets tunneled through ssh, and a connection is made locally (on the gateway) to port 5900. Using iptables, is there a way to forward a locally generated connection to another computer?

Your help would be greatly appreciated,

Nathanael Morrison

#1 lore raw
Quoted 12 lines · Nathanael Morrison

Hi,

I currently have several computers behind a linux gateway, one of which is my personal computer. I often want to access my desktop from campus using KDE's remote desktop feature. At the moment I forward any connections to port 5900 to my pc. This works but then I thought, wouldn't it be nice if I could to this securely with an ssh tunnel Correct me if I'm wrong but, I think the connection gets tunneled through ssh, and a connection is made locally (on the gateway) to port 5900. Using iptables, is there a way to forward a locally generated connection to another computer?

Yes, you use PREROUTING and DNAT.

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 22 -s 192.168.0.1 -j DNAT --to 192.168.0.100:5900

Replace ips and ports as needed ...

You possibly need a FORWARD rule to forward the traffic once the destination ip has changed.

Quoted 4 lines

Your help would be greatly appreciated,

Nathanael Morrison

Signature · 19 lines
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(  Raymond Leach                       )
 ) Knowledge Factory                  (
(                                      )
 ) Tel: +27 11 445 8100               (
(  Fax: +27 11 445 8101                )
 )                                    (
(  http://www.knowledgefactory.co.za/  )
 ) http://www.saptg.co.za/            (
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   o                                o
    o                              o
        .--.                  .--.
       | o_o|                |o_o |
       | \_:|                |:_/ |
      / /   \\              //   \ \
     ( |     |)            (|     | )
     /`\_   _/'\          /'\_   _/`\
     \___)=(___/          \___)=(___/