Friday, January 23, 2009

VNC server setup on Linux

Setting up VNC on linux is very straight forward provided we follow ALL steps.

Here are the steps to setup VNC on Redhat Linux:
1) Edit /etc/services to add VNC related information/ports
2) Edit /etc/xinetd.d/vncserver to specify which user and which ports to use to run VNC
3) Check the status of vncserver, if disabled then enable it for run level 3/4/5.
4) Invoke "gdmconfig" and enable XDMCP protocol.
5) Restart "xinetd" service. Viola! You are done setting up VNC.
6) Use any VNC viewer to connect the server on ports mentioned in /etc/xinetd.d/vncserver (in this case, it is port 5972 or 5972/ or simply port 72 or 73 for a VNC viewer).



# cat /etc/services
:
:
:
# Local services
#
# VNC Servers
#
vnc-640x480x8 5950/tcp
vnc-800x600x8 5951/tcp
vnc-1024x768x8 5952/tcp
vnc-1280x1024x8 5953/tcp
vnc-1600x1200x8 5954/tcp

vnc-640x480x16 5960/tcp
vnc-800x600x16 5961/tcp
vnc-1024x768x16 5962/tcp
vnc-1280x1024x16 5963/tcp
vnc-1600x1200x16 5964/tcp

vnc-640x480x24 5970/tcp
vnc-800x600x24 5971/tcp
vnc-1024x768x24 5972/tcp
vnc-1280x1024x24 5973/tcp
vnc-1600x1200x24 5974/tcp

vnc-640x480x32 5980/tcp
vnc-800x600x32 5981/tcp
vnc-1024x768x32 5982/tcp
vnc-1280x1024x32 5983/tcp
vnc-1600x1200x32 5984/tcp

# cat /etc/xinetd.d/vncserver
# description: This vnc server serves vnc-1024x768x24 VNC sessions
service vnc-1024x768x24
{
disable = no
socket_type = stream
protocol = tcp
port = 5972
wait = no
user = demo
server = /usr/bin/Xvnc
server_args = -inetd -query localhost -once -geometry 1024x768 -depth 24 -SecurityTypes=None
}
# end
# description: This vnc server serves vnc-1024x768x24 VNC sessions
service vnc-1280x1024x24
{
disable = no
socket_type = stream
protocol = tcp
port = 5973
wait = no
user = demo
server = /usr/bin/Xvnc
server_args = -inetd -query localhost -once -geometry 1280x1024 -depth 24 -SecurityTypes=None
}
# end


# chkconfig --list vncserver
vncserver 0:off1:off2:off3:on4:on5:on6:off

# /sbin/service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]

# /usr/sbin/gdmconfig





# echo "With gdmconfig.... enabled XDMCP (from the last tab)"
With gdmconfig.... enabled XDMCP (from the last tab)

# /sbin/service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
#

OPTIONAL:
Important tip:
Following section is applicable ONLY when gdmsetup gui is not available/disabled for any reason.
In this case, first take the backup of /etc/X11/gdm/gdm.conf file so that it can be restored if needed. Then edit this file for XDMCP section to look like below:

Originally, it will look like below:

[xdmcp]
Enable=false


For VNC, it should look like below (need to modify manually if gdmsetup gui is not available):
[xdmcp]
Enable=true
HonorIndirect=true
MaxPending=4
MaxPendingIndirect=4
MaxSessions=16
MaxWait=15
MaxWaitIndirect=15
DisplaysPerHost=2
PingInterval=1
Port=177
Willing=/etc/X11/gdm/Xwilling



After this change is done, restart the xinetd service as mentioned above. VNC should work now.

No comments: