0

I've recently got a VPS running CentOS 6.X, I installed Gnome and configured VNC. vncserver is running fine, but I can't connect to it. I checked the ports from outside and noticed that port 5901 is closed. I edited the iptables and restarted the iptables service but nothing happens. I even stopped the iptables service but the port seems closed. What's going on?

Thanks in advance.

[EDIT] OK, to be honest, I'm not sure if the vncserver is running right or not. It doesn't give any errors, but there are some gnome related errors in its logs. But could this have anything to do with the port being closed?

[EDIT] These are 2 vnc configs (xstartup) that I tried:

#!/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 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
xterm -geometry 1024x768 -ls -name "$VNCDESKTOP Desktop" &
twm &
~            

and this one:

#!/bin/sh

( while true; do xterm; done ) &

# 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 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
xterm -geometry 1024x768 -ls -name "$VNCDESKTOP Desktop" &
gnome-session &
~            
Auxiliary
  • 163
  • 2
  • 7
  • 1
    Stopping the iptables service doesn't necessarily mean that you're allowing all traffic. It just means that you're falling back to the set policy which could be ACCEPT or DROP, depending. – pboin Dec 26 '11 at 19:25

2 Answers2

1

Start the VNC server then try telneting using:

telnet localhost [port number]

Where [port number] is whatever port you configured. If the server is actually running you should see something like "RFB 003.003" as the output. If you get connection refused, then likely the server is not running.

[Edit]

I'm with @pboin on this. I think your iptables is still blocking.

Edit /etc/sysconfig/iptables file:

# vi /etc/sysconfig/iptables

Add

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport [port number]  -j ACCEPT

Where [port number] is the port you're using. Then restart iptables using:

# service iptables restart

Then try the remote connect again.

jackhamm
  • 141
  • 8
  • 1
    Also, you can check using `netstat -an | grep [port number]` and `ps aux | grep vnc` to make sure the server is up. – jackhamm Dec 26 '11 at 19:22
  • I got RFB 003.008. So is it running? Would the port be shown as closed, if the server is not run on that port? (Yeh, I've checked it with netstat before, it seems up.) – Auxiliary Dec 26 '11 at 19:23
  • @Auxiliary If you can telnet in that way then the server is at least listening on `localhost`. So what happens if you remotely attempt to telnet to the port (using the public IP)? Do you get that same output or do you get a connection refused? – jackhamm Dec 26 '11 at 19:40
  • I just checked the vnc log after the telnet and it says it's had an accepted connection from 127.0.0.1 but remotely I get connection timed out. – Auxiliary Dec 26 '11 at 19:40
1

first verify your vnc servers is actually running :

ps -ef | grep -i vnc

then make sure it is listening

netstat -nlptu

if that does not work, look for errors in your log, and also try disabling selinue

setenforce 0

also posting your vnc config would help.

Moti
  • 51
  • 2
  • I edited the question (added the vnc configs) – Auxiliary Dec 26 '11 at 19:37
  • 1
    resolved - Thanks for mentioning the vnc config file. At first I thought you meant the xstartup file. I checked the config file and found this line: VNCSERVERARGS[1]="-geometry 800x600 -nolisten tcp -nohttpd -localhost" which refused connection. – Auxiliary Dec 26 '11 at 20:08