Wednesday, March 16, 2011

VNC Port Forwarding using IPtables

Scenario (Example :)

Xen Host(Hypervisor) :10.228.1.19 Series
VM(Guest) :- 192.168.10.19 series (runs VNC server on 5901 port)
Windows Desktop :- 10.x.x.x

I am able to connect to Hypervisor (Xen Host) , but I need to VNC to Guest os which is on 192.x.x.x
series network which i am not able to connect,

Since  I am able to reach hypervisor from desktop I want to port forward connections of port 9001
for Hypervisor(10 Series) to Vnc Server(192 Series) on port 5901, So I am able to connect from Desktop.

Using Iptables to Port forward on Hypervisor(Xen Host)

Host@10.228.1.19#iptables -t nat -A PREROUTING -p tcp -s 0.0.0.0/0 -d 10.228.1.19 --dport 9001 -j DNAT --to-destination 192.168.10.19:5901

Now you can connect to 10.228.1.19 on port 9001 for vnc connection on host 192.168.10.19

My Linux Desktop

sriram@pc2:~$ vncviewer 10.228.1.19:9001

VNC Viewer Free Edition 4.1.1 for X - built Apr  9 2010 15:52:37
Copyright (C) 2002-2005 RealVNC Ltd.
See http://www.realvnc.com for information on VNC.

Wed Mar 16 20:52:26 2011
 CConn:       connected to host 10.228.1.19 port 9001

Wed Mar 16 20:52:27 2011
 CConnection: Server supports RFB protocol version 3.8
 CConnection: Using RFB protocol version 3.8
Password:
Wed Mar 16 20:52:32 2011







No comments:

Post a Comment