Showing posts with label ssh port forwarding for vnc. Show all posts
Showing posts with label ssh port forwarding for vnc. Show all posts

Tuesday, February 1, 2011

Connecting to VNC on a guest without X on it.

Scenario :


Hostname

Host OS -host1
Host1 has 2 IPs 10.xx.xx.xx  and 192.xx.xx.xx

eth0:  10.222.22.2  can connect from my windows desktop
eth1:  192.168.5.2 is used to connect to Guest os

Guest OS - Guest1 
Guest has IP address 192.168.2.1

SSH Port fowarding is one one way to connect :

On host os do fowarding to Guest OS.
Flush Rules First
#iptables -t nat -F


Port forwarding from Host1:6001(host os) to 192.168.2.1:6001 (guest os)

#/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

#iptables -t nat -A PREROUTING -p tcp -s 0.0.0.0/0  -d 10.222.22.2 --dport 6001 -j DNAT --to-destination 192168.2.1:6001


WAY 2

Export display of guest to host where you have X running:

on Guest  OS if you dont have X running and want to use a X of different server.
#export DISPLAY=host_where_x_is_running:1.0
#vncpasswd (set password)

#xterm &

From windows desktop vnc connect to  guest it will forward its display to [ host_where_x_is_running ]