15.3.2. Connecting to a VNC Server
Procedure 15.6. Connecting to a VNC Server Using a GUI
- Enter the
vncviewercommand with no arguments, the VNC Viewer: Connection Details utility appears. It prompts for a VNC server to connect to. - If required, to prevent disconnecting any existing VNC connections to the same display, select the option to allow sharing of the desktop as follows:
- Select the button.
- Select the Misc. tab.
- Select the button.
- Press OK to return to the main menu.
- Enter an address and display number to connect to:
address:display_number
- Press Connect to connect to the VNC server display.
- You will be prompted to enter the VNC password. This will be the VNC password for the user corresponding to the display number unless a global default VNC password was set.A window appears showing the VNC server desktop. Note that this is not the desktop the normal user sees, it is an Xvnc desktop.
Procedure 15.7. Connecting to a VNC Server Using the CLI
- Enter the
viewercommand with the address and display number as arguments:vncviewer address:display_number
Where address is anIPaddress or host name. - Authenticate yourself by entering the VNC password. This will be the VNC password for the user corresponding to the display number unless a global default VNC password was set.
- A window appears showing the VNC server desktop. Note that this is not the desktop the normal user sees, it is the Xvnc desktop.
15.3.2.1. Configuring the Firewall for VNC
TCP packets. If required, open a port for the TCP protocol as described below. When using the -via option, traffic is redirected over SSH which is enabled by default.
Note
Procedure 15.8. Opening a Port Using lokkit
lokkit command provides a way to quickly enable a port using the command line.
- To enable a specific port, for example port
5902forTCP, issue the following command asroot:~]#
Note that this will restart the firewall as long as it has not been disabled with thelokkit --port=5902:tcp --update--disabledoption. Active connections will be terminated and time out on the initiating machine. - Verify whether the chosen port is open. As
root, enter:~]#
iptables -L -n | grep 'tcp.*59'ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:5902 - If you are unsure of the port numbers in use for VNC, as
root, enter:~]#
Ports startingnetstat -tnlptcp 0 0 0.0.0.0:6003 0.0.0.0:* LISTEN 4290/Xvnc tcp 0 0 0.0.0.0:5900 0.0.0.0:* LISTEN 7013/x0vncserver tcp 0 0 0.0.0.0:5902 0.0.0.0:* LISTEN 4189/Xvnc tcp 0 0 0.0.0.0:5903 0.0.0.0:* LISTEN 4290/Xvnc tcp 0 0 0.0.0.0:6002 0.0.0.0:* LISTEN 4189/Xvnc59XXare for the VNCRFBprotocol. Ports starting60XXare for the X windows protocol.To list the ports and the Xvnc session's associated user, asroot, enter:~]#
lsof -i -P | grep vncXvnc 4189 jane 0u IPv6 27972 0t0 TCP *:6002 (LISTEN) Xvnc 4189 jane 1u IPv4 27973 0t0 TCP *:6002 (LISTEN) Xvnc 4189 jane 6u IPv4 27979 0t0 TCP *:5902 (LISTEN) Xvnc 4290 joe 0u IPv6 28231 0t0 TCP *:6003 (LISTEN) Xvnc 4290 joe 1u IPv4 28232 0t0 TCP *:6003 (LISTEN) Xvnc 4290 joe 6u IPv4 28244 0t0 TCP *:5903 (LISTEN) x0vncserv 7013 joe 4u IPv4 47578 0t0 TCP *:5900 (LISTEN)
Procedure 15.9. Configuring the Firewall Using an Editor
/etc/sysconfig/system-config-firewall file thoroughly after editing.
- To check what the firewall is configured to allow, issue the following command as
rootto view the firewall configuration file:~]#
In this example taken from a default installation, the firewall is enabled but VNC ports have not been configured to pass through.less /etc/sysconfig/system-config-firewall# Configuration file for system-config-firewall --enabled --service=ssh - Open
/etc/sysconfig/system-config-firewallfor editing asrootand add lines in the following format to the firewall configuration file:--port=port_number:tcp
For example, to add port5902:~]#
vi /etc/sysconfig/system-config-firewall# Configuration file for system-config-firewall --enabled --service=ssh --port=5902:tcp - Note that these changes will not take effect even if the firewall is reloaded or the system rebooted. To apply the settings in
/etc/sysconfig/system-config-firewall, issue the following command asroot:~]#
lokkit --update

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.