How to make Linux VNC server listen on local IP instead of just loopback

centos5vnc

I know how to specify a listening port of VNC server under Linux, but what puzzles me is that I can not find a way to specify a VNC listening IP.

When started VNC server under CentOS 5.6, I found its process "Xvnc" is listening on 127.0.0.1:5901. Maybe this is why I always failed to get in when I use any XNC client. I do not know why it listened on "lo" network interface but not on "eth0".

Best Answer

It sounds like your vncserver is started with localhost parameter:

# vncserver -h

usage: vncserver [:<number>] [-nohttpd] [-name <desktop-name>] [-depth <depth>]
                 [-geometry <width>x<height>]
                 [-pixelformat rgbNNN|bgrNNN]
                 <Xvnc-options>...

# Xvnc -h
Unrecognized option: -h
...
Global Parameters:
  localhost      - Only allow connections from localhost (default=0)

You should probably check the /etc/sysconfig/vncservers and the init script /etc/init.d/vncserver.

If you want to bind to specific IP, do it with iptables or take a look at this.

Related Topic