CentosVNC configuration and connection

Source: Internet
Author: User
Centos6.2 (mini version) is now widely used in Linux, and many server systems and applications are moving to the Linux layer. At present, we will learn about Linux customization and scalability by installing Centos, with a lot of content. Now, we start to install the ISO file In the virtual machine. the following interface is displayed: (Installorupgradeanexistingsystem) In

Install Centos6.2 (mini)

Nowadays, Linux is widely used, and many server systems and applications are moving to Linux. At present, we will learn about Linux customization and scalability by installing Centos, with a lot of content.

Now, we start to install the ISO file into the virtual machine, and see the following interface:

Select the first item: (Install or upgrade an existing system)

Install or upgrade an existing system Install or upgrade the existing system

Install system with basic video driver

Rescue installed system enters system repair mode

Boot from local drive exit installation start from hard disk

Select the first option, install or upgrade the existing system, and press enter.

If you have a question about whether to test the CD media, select "Skip" to Skip the test.

The installation is based on your own requirements. I will not explain it carefully here (Baidu will understand it ).

Nic configuration

After installation, you can directly start the tool to the text interface. enter the root user and password ***** to go to the interface. First, check the Nic configuration and whether to enable it:



In general, the NIC is not configured. we need to configure it as follows: (the configuration file quotation marks "" may be unavailable)


DEVICE = eth0 // specify the DEVICE name

BOOTPROTO = static // Start type dhcp, dcph or static automatic and manual

BROADCAST = // Gateway

HWADDR = 00: 06: 5B: FE: DF: 7C // hardware Mac address

IPADDR = // IP address

NETMASK = // subnet mask

NETWORK = // NETWORK address

ONBOOT = yes // whether to start the application

TYPE = Ethernet // network TYPE

After the configuration is complete (the green color shown here is my configuration, and the black part does not exist, depending on your personal preferences), restart the Nic service:

Service network restart

Now the Nic configuration is complete.


The NIC information is displayed:

Eth0 Link encap: Ethernet HWaddr 00: 0C: 29: 95: 96: A2

Inet addr: Bcast: Mask:

Inet6 addr: fe80: 20c: 29ff: fe95: 96a2/64 Scope: Link

Up broadcast running multicast mtu: 1500 Metric: 1

RX packets: 1233 errors: 0 dropped: 0 overruns: 0 frame: 0

TX packets: 216 errors: 0 dropped: 0 overruns: 0 carrier: 0

Collisions: 0 fig: 1000

RX bytes: 107257 (104.7 KiB) TX bytes: 30342 (29.6 KiB)

Lo Link encap: Local Loopback

Inet addr: Mask:

Inet6 addr: 1/128 Scope: Host

Up loopback running mtu: 16436 Metric: 1

RX packets: 0 errors: 0 dropped: 0 overruns: 0 frame: 0

TX packets: 0 errors: 0 dropped: 0 overruns: 0 carrier: 0

Collisions: 0 txqueuelen: 0

RX bytes: 0 (0.0 B) TX bytes: 0 (0.0 B)

YUM source configuration

This is because many of our services are not installed and are not configured. you can check which services are installed:

Yum list installed // list installed software packages

Rpm-q ****** // check whether the required service is installed

In this case, if you want to use the yum source method to install the services you need (because it is more convenient to use the yum source, it will automatically detect the association between services and automatically install them, it is much more convenient to install with rpm). here we will talk about the yum source configuration.

1. attach the disc first,

Mount/dev/cdrom/mnt // mount the optical drive (remember to mount the full version of Centos)

Ls/mnt // view the content on the Mount

If you can see the content, the Mount is successful.

2. here we need to know one thing: CentOS has three yum sources, they have two files under/etc/yum. repos. d/: CentOS-Base.repo, CentOS-Debuginfo.repo and CentOS-Media.repo. Where the CentOS-Media.repo and CentOS-Base.repo two sources are not used at the same time, the default use of the Internet upgrade of the CentOS-Base.repo source (this file is the URL, you can look at it ), unless we manually modify the system to use the Media source, and the media source is the local source of the computer, it contains the mounted CD.

Cd/etc/yum. repos. d


CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo

Then first rename the CentOS-Base.repo file, so that the system can not find the file, so that the yum installation can not use the internet update method:

Mv CentOS-Base.repo CentOS-Base.repo.bak

Then edit the CentOS-Media.repo:

Vi CentOS-Media.repo

In the configuration file:

Baseurl = file: // media/CentOS/changed to baseurl = file: // mnt/(or: ftp: // configuration requires a little trouble, I will introduce ftp configuration in detail later)

File: // media/cdrom/delete or comment out the # sign before the statement

File: // media/cdrecorder/delete or comment out the # sign before the statement

Then, find the enabled = 0 attribute and change the value to 1, so that the enable switch of the local source file is enabled.

Enabled = 0 to enabled = 1

Now, Save the file. Yum, keep it fast. of course, the premise is that you have to attach the disk to close the disk.

Configure VNC service

Here I need to configure a VNC service, and take the vnc service configuration as an example:

Check whether the vnc service is installed:

Yum list installed // list installed software packages

Yum-y install tigervnc-server // use yum to install the vncserver package

1. run the vncserver command,


The following content is displayed:

You will require a password to access your tops.

Password: 12345 // vnc connection Password

Verify: 12345

Xauth: creating new authority file/root/. Xauthority

New 'localhost: 1 (yfx) 'desktop is localhost: 1

Creating default startup script/root/. vnc/xstartup

Starting applications specified in/root/. vnc/xstartup

Log file is/root/. vnc/localhost: 1.log


2. when creating. vnc/xstartup, the specified Window manager is twm, which is a very small Window manager and has twm on almost every X Window System machine. Twm does not have most of the fancy functions of the complete "Desktop Manager" (such as KDE, GNOME, or WindowMaker). In this case, you need to edit the vncserver configuration file:

Cd. vnc


Display the xstartup file in. vnc and edit it:

Vi xstartup

The displayed content is as follows:

#! /Bin/sh

# Uncomment the following two lines for normal desktop:
# Exec/etc/X11/xinit/xinitrc

[-X/etc/vnc/xstartup] & exec/etc/vnc/xstartup
[-R $ HOME/. Xresources] & xrdb $ HOME/. Xresources
Xsetroot-solid gray
Vncconfig-iconic &
# Xterm-geometry 80x24 + 10 + 10-ls-title "$ VNCDESKTOP Desktop" & // comment out the content of this line, and add # in front
# Twm & // comment out the content of this line and add the # sign in front of it
Gnome-session & // add this sentence


3. edit the/etc/sysconfig/vncservers command as follows:


The displayed content includes:

VNCSERVERS = "2: mynames"

VNCSERVERARGS [2] = "-geometry 800x600, *****" (* content omitted)

Modify the preceding content:

VNCSERVERS = "1: root" // The number is the desktop number, which corresponds to the port

VNCSERVERARGS [1] = "-geometry 1024x768-alwaysshared-depth 24"
// The resolution size depends on your preferences.-alwaysshared indicates that multiple users are allowed to log on at the same time.-depth indicates the color. the parameters are 8, 16, 24, and 32.


4. start advanced vnc configuration:

Run the chkconfig command to enable vncserver when the system is started.

Chkconfig -- level 2345 vncserver on

Run the following command to check the vncserver startup status:

Chkconfig -- list vncserver

5. relationship between the port number used by the VNC service and the desktop number

The port number used by the VNC service is related to the desktop number. The VNC uses the TCP port starting from 5900. the corresponding relationship is as follows:

Desktop number is "1" ---- port number is 5901

Desktop number "2" ---- port number is 5902

Desktop number "3" ---- port number is 5903


The TCP port of the Java-based VNC client Web service starts from 5800 and is also related to the desktop number. the corresponding relationship is as follows:

Desktop number is "1" ---- port number is 5801

Desktop number "2" ---- port number is 5802

Desktop number "3" ---- port number is 5803

Based on the above introduction, if the firewall function is enabled in Linux, you need to manually enable the corresponding Port. for example, to enable the corresponding port with the desktop number "1", the command is as follows:

[Root @ testdb ~] # Iptables-I INPUT-p tcp -- dport 5901-j ACCEPT

[Root @ testdb ~] # Iptables-I INPUT-p tcp -- dport 5801-j ACCEPT


The configuration of vnc and the self-starting service are all over. to log on to vnc, you must install the centos Desktop function X Window System and Desktop.



Install the desktop function and disable the firewall

Because we are using a virtual machine for the experiment, it is very troublesome to switch the interface repeatedly. Here we recommend the SSH link tool SecureCRT used in windows, the specific tool can be downloaded in many places, so this is not detailed here.

1. here we will look at the garbled characters displayed in the SecureCRT tool. here we need to modify/etc/sysconfig/i18n, as shown below:


If the content is as follows:

LANG = "zh_US.UTF-8"


LANG = "en_US.UTF-8"

SUPPORTER = "en_US.UTF-8: en_US: zh"

SYSFONT = "latarcyrheb-sun16"


2. then install the installation package of the desktop component. here, we will first check which packages are included in the CD:

Yum grouplist

Then install the Desktop package:

Yum-y groupinstall "Desktop"

Yum-y groupinstall "X Window System"


3. in this case, the desktop-related packages are installed. however, to access centos from vnc, you must disable the centos firewall (from centos6, the firewall is automatically enabled, and you need to set the/etc/selinux/config configuration file ):

Chkconfig -- level 0123456 iptables off

Chkconfig -- level 0123456 ip6tables off


Display the following content:

# This file controls the state of SELinux on the system.

# SELINUX = can take one of these three values:

# Enforcing-SELinux security policy is enforced.

# Permissive-SELinux prints warnings instead of enforcing.

# Disabled-No SELinux policy is loaded.

SELINUX = enforcing

# SELINUXTYPE = can take one of these two values:

# Targeted-Targeted processes are protected,

# Mls-Multi Level Security protection.

SELINUXTYPE = targeted

Change the green part:

SELINUX = disabled

After modification, exit and restart reboot.


4. now all preparations for connecting to the vnc desktop are complete. install RealVNC. Enterprise software in windows and click the vnc viewer to enable vnc,

, Enter ip: 5901, select let vnc server choose, Click connect, enter the password, and click OK. the desktop is displayed, but it may be garbled or displayed in four boxes, to install the language support package, run the following command:

Yum-y groupinstall "Chinese Support"

Then, log on to the vnc viewer again, and all the configurations and links of the vnc are complete.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.