Home > other >  Questions about the DISPLAY env variable
Questions about the DISPLAY env variable

Time:12-08

Recently, I experienced how to run GUI on WSL2. The key part is to install an X11 server on the host and define an env variable DISPLAY in the WSL2 shell like export DISPLAY=172.19.224.1:0.0. Here, the IP 172.19.224.1 is my host's IP in WSL2. And this approach also works in the shell of a VM Linux server.

My Questions are below:

Why the :0.0? I feel after colon should be an integer for a port, such as 172.19.224.1:3306 for MySQL. What does :0.0 mean?

If I use the DISPLAY env variable in the shell of the remote server and the remote server saw my X11 server through a NAT router and port forwarding is in use. What port to forward? (I am trying to use GUI for a remote server, but I find there is a NAT router between and port forwarding is neeeded.)

I do not know the name of the topic and the key words to search. Could someone give me some clues?

CodePudding user response:

The DISPLAY variable does not contain a port number. The first number is the display number and the second number is the screen number. So :0.0 means display number 0 and screen number 0. See the Unix site for more information.

CodePudding user response:

Why the :0.0?

The format is generally <ip>:<display number>.<screen number>.

What port to forward?

VNC uses 5900 display number.

X11 uses 6000 display number.

  • Related