Geeks With Blogs
The Blug A forum that just screams "meh"...

Setting up the server

In Fedora Core or Red Hat based distros in general, all we have to do is define the VNC server instances in /etc/sysconfig/vncservers. These will be started by the vncserver initscript. As root, add the following lines to the file:
VNCSERVERARGS[2]="-geometry 1024×768 -depth 16"

Each VNC server instance listens on port 5900 plus the display number on which the server runs.
Root's vnc server is now listening on port 5902.

For multiple vnc instances /etc/sysconfig/vncservers would look like this:

VNCSERVERS="1:tiger 2:albatros 3:leopard"
VNCSERVERARGS[1]="-geometry 1024×768 -depth 16"
VNCSERVERARGS[2]="-geometry 800×600 -depth 8"
VNCSERVERARGS[3]="-geometry 1024×768 -depth 16"

These would listen on ports 5901, 5902, 5903 respectively.

User Configuration

Now set the password with the command

# vncpasswd

Enter and confirm the password, which will be saved in ~/.vnc/passwd.

Start the VNC server

After the initial configuration is done we restart the vnc service. As root:

# service vncserver restart

To make VNC server to start on boot:

# chkconfig vncserver on

Next, within the file /home/username/.vnc/xstartup (or just ~/.vnc/xstartup) uncomment the 2 lines:

exec /etc/X11/xinit/xinitrc

Editing the iptables manually to opens ports

Add the line in bold to the file /etc/sysconfig/iptables while logged in as root:

# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited

Now we need to restart the iptables service to reload the changes.

# service iptables restart
Flushing firewall rules:                                   [  OK  ]
Setting chains to policy ACCEPT: filter                    [  OK  ]
Unloading iptables modules:                                [  OK  ]
Applying iptables firewall rules:                          [  OK  ]
Loading additional iptables modules: ip_conntrack_netbios_n[  OK  ]

Finally, restart your vncserver session

# service vncserver restart

You should now be able to connect to your  vncserver with a normal desktop on display 2 (port 5902) Posted on Wednesday, May 28, 2008 8:53 AM IT type pile | Back to top

Comments on this post: Setup vncserver in Fedora/RedHat

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © cleggenator | Powered by: | Join free