vncserver creating display as :<Displaynumber> instead of hostname:<Displaynumber>

298 Views Asked by At

When I run vncserver command it will create session with display as :1 ,and in the terminal when we check the display variable, it is set as DISPLAY=:1, Is it possible to create a vnc session with display variable set as DISPLAY=hostname:1, I know to change the display variable by using export or setenv command depending on the shell, But if I change the display variable manually to hostname:1 , xhost command doesn't work as the vnc session is originally created for :1 only,

Am not sure why this behavior or is this the default behavior?

Am using Solaris 11.4 OS

1

There are 1 best solutions below

0
On

You're misunderstanding how X Windows DISPLAY environment variables work.

Per the X.org documentation (bolding mine):

From the user's perspective, every X server has a display name of the form:

hostname:displaynumber.screennumber

This information is used by the application to determine how it should connect to the server and which screen it should use by default (on displays with multiple monitors):

hostname

The hostname specifies the name of the machine to which the display is physically connected. If the hostname is not given, the most efficient way of communicating to a server on the same machine will be used.

displaynumber

The phrase "display" is usually used to refer to collection of monitors that share a common keyboard and pointer (mouse, tablet, etc.). Most workstations tend to only have one keyboard, and therefore, only one display. Larger, multi-user systems, however, frequently have several displays so that more than one person can be doing graphics work at once. To avoid confusion, each display on a machine is assigned a display number (beginning at 0) when the X server for that display is started. The display number must always be given in a display name.

screennumber

Some displays share a single keyboard and pointer among two or more monitors. Since each monitor has its own set of windows, each screen is assigned a screen number (beginning at 0) when the X server for that display is started. If the screen number is not given, screen 0 will be used.

On POSIX systems, the default display name is stored in your DISPLAY environment variable. This variable is set automatically by the xterm terminal emulator. However, when you log into another machine on a network, you will need to set DISPLAY by hand to point to your display. For example, ...

From the X server process, there is no hostname part of a display name - the server is running on the system it's running on.

So setting an X server to run on hostname:1 is no different than setting it to run on :1.

For X Windows client programs, though, the hostname part of a DISPLAY environment variable denotes the system where the display they need to connect to is running. In other words, the connect becomes a network connection.

When your xterm process is started locally, it connects to the local X server process by default, denoted with :1 (or :0 or :0.0 or :2.0...). Setting DISPLAY=hostname:1 means the X client process will try to perform a network connection to the :1 display, running on the hostname system. And if the X server process isn't configured to listen for network connections in addition to local connections, or if there's a firewall in the way, that client process will fail to connect to hostname:1.

So just using the xhost command to enable remote access won't work if the X server isn't configure to allow such access.

For the :1 display, if your X server is configured to allow remote access, running netstat -an | grep 6001 will produce output something like this:

*:6001       *      *     0     0 256000     * LISTEN

If you do not see any process with LISTEN on port 6001, the X server for your :1 display is not configured to accept remote connections.