Redhat下VNC SERVER的配置
1、启动VNC SERVER
输入vncserver,第一次启动会要求输入验证密码,完成后,VNC SERVER就启动了
[root@localhost ~]# vncserver
You will require a password to access your desktops.
Password: //输入密码
Verify: //再次输入密码
xauth: creating new authority file /root/.XauthorityNew ‘localhost.localdomain:1 (root)’ desktop is localhost.localdomain:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log[root@localhost ~]#
2、编辑.vnc/xstartup
使用VI打开xstartup文件,如下:
[root@localhost /]# cd /root/.vnc
[root@localhost .vnc]# vi xstartup
删除全部内容,然后添加如下内容:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
3、重启动VNC SERVER
[root@localhost ~]# vncserver -kill :1
Killing Xvnc process ID 21198[root@localhost ~]# vncserver
New ‘localhost.localdomain:1 (root)’ desktop is localhost.localdomain:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log[root@localhost ~]#
4、查看VNC的监听端口
如下,VNC用到了三个端口:5801、5901、6001。
[root@localhost /]# netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:2208 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:5801 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:724 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:2207 0.0.0.0:* LISTEN
tcp 0 0 172.200.102.3:5901 181.181.181.51:1669 ESTABLISHED
tcp 0 0 :::6001 :::* LISTEN
tcp 0 0 :::22 :::* LISTEN
tcp 0 1364 ::ffff:172.200.102.3:22 ::ffff:181.181.181.51:1599 ESTABLISHED
[root@localhost /]#
5、在防火墙上打开VNC用到的上面三个端口
[root@localhost /]# cd /etc/sysconfig
[root@localhost sysconfig]# vi iptables
添加如下三行:
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 5801 -j ACCEPT
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 5901 -j ACCEPT
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 6001 -j ACCEPT
重记动IPTABLES
[root@localhost sysconfig]# /etc/rc.d/init.d/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_ns ip_conntrack_ftp [ OK ]
[root@localhost sysconfig]#
6、使用VNC VIEW连接VNC SERVER
下载VNC VIEW,运行,然后输入IP:端口号,输入刚才设定的密码,进入REDHAT桌面。