How to set up working X11 forwarding on WSL2

前端 未结 14 2046
灰色年华
灰色年华 2020-12-12 12:09

When moving from WSL1 to WSL2 many things change; apparently this applies to X11 forwarding as well.
What steps do I need to make in order to use X11 forwarding with WSL

相关标签:
14条回答
  • 2020-12-12 12:43

    I'm not sure why but none of the above answers worked for me. I'm running on an ROG Zephyrus with AMD and Nvidia graphics which I'm sure caused issues.

    The firewall settings described by whme are important, but the linux environment variables did not work for me. I had several entries in the config file labeled as nameserver, non of which allowed connections.

    I ended up setting them to:

    export DISPLAY=$HOSTNAME:0.0
    export LIBGL_ALWAYS_INDIRECT=
    

    I'm using VcXsrv as the X-server. I had to also set the parameters to -nowgl

    0 讨论(0)
  • 2020-12-12 12:44

    I don't know if that's specific to my configuration but these solutions don't work on my computer. They return the address 192.168.0.254 which is my gateway and not my host computer.

    To make it work I had to use the following on my Ubuntu/WSL2 :

    export DISPLAY="`ip -4 address | grep -A1 eth0 | grep inet | cut -d' ' -f6 | cut -d/ -f1`:0"
    
    0 讨论(0)
提交回复
热议问题