Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1303248
  • 博文数量: 416
  • 博客积分: 10495
  • 博客等级: 上将
  • 技术积分: 4258
  • 用 户 组: 普通用户
  • 注册时间: 2005-04-23 22:13
文章分类

全部博文(416)

文章存档

2015年(7)

2014年(42)

2013年(35)

2012年(14)

2011年(17)

2010年(10)

2009年(18)

2008年(127)

2007年(72)

2006年(23)

2005年(51)

分类: LINUX

2013-11-08 16:37:51

[root@rhel5 ~]# vncserver
New ‘shpx:1 (root)’ desktop is shpx:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/shpx:1.log
只要能出现上面的提示,说明服务正常启动了。

windows端可以连接到linux上了,(要是有防火墙的话要更改下哦,)连上之后会出现灰灰的,看不到桌面。呵,还是说下更改方法吧,iptables(防火墙)的更改方法,如果执行了二次vncserver的话,会产生5902这个端口。需要在iptables中新增一个规则。
[root@rhel5 ~]# iptables -I INPUT 1 -s 192.168.1.1/24 -p tcp –dport 5901 -j ACCEPT
[root@rhel5 ~]# vim /etc/sysconfig/iptables

# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
: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 224.0.0.251 -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 22 -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
COMMIT

添加一行(有颜色部分)增加一个端口,不然windows下的电脑是无法连接的。
保存并退出后,重启iptables。

[root@shpx ~]# service iptables restart
清除防火墙规则:                                           [确定]
把 chains 设置为 ACCEPT 策略:filter                       [确定]
正在卸载 Iiptables 模块:                                  [确定]
应用 iptables 防火墙规则:                                 [确定]
载入额外 iptables 模块:ip_conntrack_netbios_ns            [确定]
此时连接是没有问题。

灰色的屏幕解决方法:
打开家目录下启动脚本
[root@shpx ~]# vi .vnc/xstartup
#!/bin/sh

# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &
gnome-session &

unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
的注释去掉。


twm &
改成
gnome-session &
保存并退出,并

启动/重启vncserver服务即可出现久违的桌面了。

[root@shpx ~]# /sbin/service vncserver restart
登录之后执行下who可以看到二个用户了。
[root@shpx ~]# who
root     pts/1        2008-01-18 14:40 (:0.0)
root     pts/2        2008-01-18 16:42 (:1.0)


by:http://blog.sina.com.cn/s/blog_4a24ee3e0100zzdi.html
阅读(3766) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~