Understanding X Windows DISPLAY environment variable when tunnelling

Solution 1:

Part of the answer can actually be found here: https://stackoverflow.com/questions/746119/how-do-you-use-display-specifications

DISPLAY variable is basically 3 components:

<host>:<display>[.<screen>]

As far as localhost aka 127.0.0.1 vs. 0.0.0.0 aka 0 is concerned you can take a look at this post:

https://serverfault.com/questions/78048/whats-the-difference-between-ip-address-0-0-0-0-and-127-0-0-1

Which explains the difference.

In your particular case 0.0.0.0:10.0 and localhost:10.0 would have the same effect but basically mean:

  1. connect on any interface that have the display 10 set up
  2. connect on lo0 to the listener of display 10.

Practically there would be no difference since in the first case the scan of all interfaces would start with lo0, which normally is the first interface in the list.