Saturday, February 18, 2012

How to set up remote logins via VNC for Debian, Solaris and Red Hat Clients

Debian Linux (6)

       1. Run the following commands respectively.

root# apt-get update

root# apt-get upgrade

root# apt-get dist-upgrade

       2. Reboot the OS.

root# reboot

       3. Install the GNOME desktop.

root# apt-get install gnome-desktop-environment

**  if "apt-get install gnome-desktop-environment" says the packages are missing ensure "deb squeeze main contrib non-free" is added to the sources.list file.

 **********adding the link to sources.list************************************************************************

                         I.  root# vi /etc/apt/sources.list

                       II.  Paste "deb squeeze main contrib non-free" without quotes.

                      III.  Restart the process from step 1.


            4. Install some (required) fonts for the VNC server GNOME session.

  root# apt-get install xfonts-100dpi
  root# apt-get install xfonts-100dpi-transcoded
  root# apt-get install xfonts-75dpi
  root# apt-get install xfonts-75dpi-transcoded
       root# apt-get install xfonts-base

       5. Install VNC.

                     root# apt-get install vnc4server

       6. Run VNCserver manually and set up a password.

   root# vncserver

       7. Making VNCserver start at system start up. 

*        Run the following command to create the vncserver file.

root# vi /etc/init.d/vncserver

*        Copy the following script, paste and save.

 8. Replace “my-vnc-server” with the hostname and keep with quotes. (Optional)

#-----Beginning of the script----------------------------------------------------------------------------------------

#!/bin/sh -e
# Provides:          vncserver
# Required-Start:    networking
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6


# The Username:Group that will run VNC
export USER="root"

# The display that VNC will use

# Color depth (between 8 and 32)

# The Desktop geometry to use.

# The name that the VNC Desktop will have.

OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"

. /lib/lsb/init-functions

case "$1" in
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"

log_action_begin_msg "Stopping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"

$0 stop
$0 start

exit 0

#-----End of the script-----------------------------------------------------------------------------------------------

       9. Grant permissions for everyone to execute the file.

     root# chmod +x /etc/init.d/vncserver

      10. Register the VNCServer service to run at startup.

     root# update-rc.d vncserver defaults

       *  If VNC login shows a gray screen

     root# chmod 755 /etc/X11/xinit/xinitrc

Solaris (10)

1. Download the latest VNC package for Solaris from

       2. Go to the download location of the file in the terminal and run the following commands.

root# gunzip vnc-4_1_3-sparc_solaris.pkg.gz

root# pkgadd –d vnc-4_1_3-sparc_solaris.pkg

   Solaris 10 is shipped with a basic VNC service mostly configured. This is the procedure to enable it.

       3. Find VNC service.

root# svcs -a | grep -i vnc
disabled 13:47:12 svc:/application/x11/xvnc-inetd:default 

       4. Enable VNC service.

root# svcadm enable svc:/application/x11/xvnc-inetd:default 

       5. Note that VNC is broken by default, some changes will be required.

root# svcs svc:/application/x11/xvnc-inetd:default
maintenance 14:22:41 svc:/application/x11/xvnc-inetd:default

      6. Append VNC to the /etc/services.

root# echo "vnc-root\t5900/tcp\t\t\t# Xvnc" >>/etc/services

       7. Check /etc/services.

root# tail /etc/services
snmpd 161/udp snmp # SMA snmp daemon
vnc-root 5900/tcp # Xvnc

        8. Note, the GNU display manager is not customized yet, and needs correction.

root# ls -al /etc/X11/gdm/custom.conf
/etc/X11/gdm/custom.conf: No such file or directory

        9. Enable and configure GNU display manager for VNC.

root# cat >/etc/X11/gdm/custom.conf <<!

       10. Check the customization configuration file.

root# ls -al /etc/X11/gdm/custom.conf
-rw-r--r-- 1 root root 85 Dec 19 14:43 /etc/X11/gdm/custom.conf

       11. Disable and re-enable, and validate the VNC service.

root# svcadm disable svc:/application/x11/xvnc-inetd:default
disabled 14:46:29 svc:/application/x11/xvnc-inetd:default

root# svcadm enable svc:/application/x11/xvnc-inetd:default

root# svcs svc:/application/x11/xvnc-inetd:default
online 14:46:43 svc:/application/x11/xvnc-inetd:default 

       12. Edit /etc/default/login and comment out the following line. 
             (This permits to log on as Root.)

                     * Force-save using wq! as it is read-only.

                             # CONSOLE=/dev/console

RHEL (Red Hat Enterprise Linux) 

If the RHEL installation is licensed then this is not difficult at all. You just need to run

# yum install tigervnc-server -y

at a terminal. However this gets complicated when the installation of RHEL is not licensed.

After a considerable number of disappointing hours of searching, testing, and some research I finally found a solution to this. Here I am going to use TigerVNC as the VNC server and RealVNC viewer as the client (you can use any VNC viewer you prefer).

1. Navigate to the TigerVNC downloads which at the moment of this blog post is hosted as a SourceForge project here  and download the latest build corresponding to the bit version of your linux installation.

2. Extract the contents into a suitable location.

3. Within the extracted contents a folder named bin exists and it contains all the binaries required for the sound operation of VNC server (except the one which as they say is obsolete now). Locate this folder and copy the contents of it to /bin directory in linux. The following files need to be copied.
  • vncconfig
  • vncpasswd
  • vncserver
  • Xvnc

4. Execute the command vncsever at a terminal.

# vncserver

  • This will require you to set a password for logging in via VNC remotely.
  • This will also create the necessary files required to start a xsession for a particular user when logging in via VNC.
5. Usually after the above step you are good to go but in some cases you might end up with an error Connection timed out(1006) at the VNC viewer when you try to log in. This is because the host in which the VNC server runs is blocking the VNC communication, i.e. it's blocking the VNC port-5900. Here you have to allow the port 5900 at the firewall as a trusted port or if security is not a big issue with the Red Hat host then you can simply disable it.

Friday, February 17, 2012

How to enable DDNS (Dynamic DNS) in DHCP Clients

     Debian Linux (6) 

       1. Configuring the OS to obtain an address from DHCP.

*        Edit the “interfaces” file.

 root# vi /etc/network/interfaces 

*        Copy and paste the following in it.

auto eth0
iface eth0 inet dhcp

        2. Configuring the OS to register with the DNS

*        Edit the “dhclient.conf” file.

root# vi /etc/dhcp/dhclient.conf

*        Uncomment the following line by removing the ‘#’. If the line is not present enter it to the file.

# send host-name "hostname";

*        Replace the hostname with the real hostname and keep with quotes.

 Solaris (10)

 1. Log into the terminal as root and proceed with the following steps.

        2. Change the FQDN of the host.

*        Enter the FQDN of the host and save the file.

 root# vi /etc/nodename 

*   This command will edit the file nodename file if it exists. If not it will create the file.

        3. Configure the OS to update the DNS.

*        Enter the following line in the file hostname.network_interface and save. 

*        Replace the network_interface with the network interface’s name.

         inet hostname

*        Replace the hostname with the actual hostname.

root# vi /etc/hostname.network_interface
*   This command will edit the hostname.network_interface file.

RHEL / Fedora / CentOS Linux

 1. Open the configuration file for the network interface.
# vi /etc/sysconfig/network-scripts/ifcfg-eth0

   * Here it is done for the interface eth0.
2. Append the following line to it.

3. Save and close the file. Restart the network service.

# service network restart

  ** Please refer to dhclient.conf man page for more information.

$ man dhclient.conf

     Windows (if somehow the default configurations aren’t working)


         * Validate whether the ‘Register this connection’s address in DNS is checked.

*        Start -> Run -> ncpa.cpl -> right click on the relevant connection -> properties -> double click on TCP/IP -> Advanced -> DNS