Comments (17)
@mviereck I can confirm that to be acceptable. The output when calling ipconfig is the same on MSYS2, Cygwin or WSL.
FTR, that is what I used before I dropped by own script in favour of x11docker/runx: eine/hwd-ide@b716acc#diff-e5e5b287edfbf94abd53c6c6376f53f8972af68e8cfe7ea3cd3a5c2d62632ffbL4. There used to be some Docker NAT which started with 10.*
. That seems not to be the case now.
from runx.
Thank you for pointing on the related ticket. I've removed the DockerNAT
check now.
I assume I can close here now.
from runx.
Thank you for the bug report and for digging that far into the root cause!
I currently don't have a working Windows VM. It would be nice if you could help me with some information and checks.
Can you show me the output of ipconfig.exe
?
In the output is there a hint which Virtual Switch(es) might work?
Maybe the Host Name
entry of ipconfig.exe /all
would work.
Replacing the IP check code with this hostname check is worth a try:
Hostip="$(ipconfig.exe | rmcr | grep 'Host Name' | rev | awk '{print $1}' | rev)"
Current runx
IP check:
Hostip="$(ipconfig.exe | rmcr | grep -A6 'DockerNAT' | grep 'IPv4' | rev | cut -d' ' -f1 | rev)"
[ "$Hostip" ] || Hostip="$(ipconfig.exe | rmcr | grep 'IPv4' | grep -o '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' | grep "^10\.0\.*" )"
[ "$Hostip" ] || Hostip="$(ipconfig.exe | rmcr | grep 'IPv4' | head -n1 | rev | cut -d' ' -f1 | rev)"
from runx.
C:\Users\ak>ipconfig
Windows IP Configuration
Ethernet adapter Ethernet:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Unknown adapter OpenVPN Wintun:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Ethernet adapter vEthernet (Default Switch):
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::e125:9adb:c8e5:b352%32
IPv4 Address. . . . . . . . . . . : 172.21.224.1
Subnet Mask . . . . . . . . . . . : 255.255.240.0
Default Gateway . . . . . . . . . :
Ethernet adapter vEthernet (Bridge):
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Unknown adapter OpenVPN TAP-Windows6:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Wireless LAN adapter Local Area Connection* 3:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Wireless LAN adapter Local Area Connection* 4:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Wireless LAN adapter Wi-Fi:
Connection-specific DNS Suffix . : IGD_Rostelecom
Link-local IPv6 Address . . . . . : fe80::356f:74c:4a23:530d%17
IPv4 Address. . . . . . . . . . . : 192.168.1.113
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
Ethernet adapter Bluetooth Network Connection:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Mobile Broadband adapter Cellular:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Ethernet adapter vEthernet (WSL):
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::300c:10fa:8b93:ab97%80
IPv4 Address. . . . . . . . . . . : 172.21.0.1
Subnet Mask . . . . . . . . . . . : 255.255.240.0
Default Gateway . . . . . . . . . :
from runx.
Thank you!
I wonder which adapter might be a good choice.
- Maybe
Ethernet adapter vEthernet (Default Switch):
? x11docker could parse forDefault Switch
. - Even better sounds
Ethernet adapter vEthernet (WSL):
. x11docker could parse forWSL
.
Which one did work for you after disabling additional Virtual Switches in your first research?
from runx.
I am going to investigate now.
But I think it may be better to adapt powershell
approach as described here.
Another approach (for WSL) is to use
Hostip="$(awk ' /nameserver/{ print $2 } ' < /etc/resolv.conf)"
from runx.
Thank you for the investigation!
Points to consider:
- The final solution should work on MSYS2, Cygwin, WSL1 and WSL2 as well.
- I'd say it should work on Windows 7, too, because I believe it is still often in use.
For the powershell solution I doubt that it will fulfill this. Though, I am not sure. Wikipedia says that Poweshell 2.0 is included in Win7. Furthermore, the stackoverflow comments suggest that calling it is very slow.
The attempt with resolv.conf
fails on my Linux system. It gives the IP of my DSL modem, not of the host system.
The command hostname -I
might work on all noted systems. Could you check that, at least for WSL2?
Hostip="$(hostname -I | cut -d' ' -f1)"
@eine Could you please have a look at this, too?
from runx.
On MSYS2 (MINGW64):
# Hostip="$(hostname -I | cut -d' ' -f1)"
hostname: unknown option -- I
Try 'hostname --help' for more information.
from runx.
On Cygwin, it works and Hostip contains the public IP (which does not match any of IPv4 addresses of the adapters).
$ Hostip="$(hostname -I | cut -d' ' -f1)"
$ echo $Hostip
158.x.x.x
$ ipconfig
Windows IP Configuration
Ethernet adapter Ethernet 2:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Ethernet adapter Ethernet:
Connection-specific DNS Suffix . : Home
Link-local IPv6 Address . . . . . : fe80::a464:f05b:a69c:7cff%11
IPv4 Address. . . . . . . . . . . : 192.x.x.x
Subnet Mask . . . . . . . . . . . : 255.x.x.x
Default Gateway . . . . . . . . . : 192.x.x.x
Wireless LAN adapter Local Area Connection* 2:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Wireless LAN adapter Local Area Connection* 3:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Wireless LAN adapter WiFi 5:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . : Home
Ethernet adapter vEthernet (Default Switch):
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::45be:1119:d090:5b00%57
IPv4 Address. . . . . . . . . . . : 172.x.x.x
Subnet Mask . . . . . . . . . . . : 255.x.x.0
Default Gateway . . . . . . . . . :
from runx.
On Debian (dunno if this is WSL1 or WSL2), it works and Hostip contains the local IPv4 of one of the adapters:
$ Hostip="$(hostname -I | cut -d' ' -f1)"
$ echo $Hostip
172.x.x.x
from runx.
@eine Thank you!
Would have been to easy have a general solution immediately ...
hostname: unknown option -- I
On MSYS2 (and also the others?) maybe this attempt works:
Hostname=$(hostname)
nslookup "$Hostname"
On Cygwin, it works and Hostip contains the public IP (which does not match any of IPv4 addresses of the adapters).
I wonder if this IP works; it might also cause yet another firewall issue.
On debian I get valid ipv4 adresses combining hostname
and nslookup
(except the first one that points to the DNS server on the DSL modem):
$ Hostname=$(hostname)
$ nslookup "$Hostname" | grep Address
Address: 192.168.178.1#53
Address: 192.168.178.46
Address: fd[...]
Maybe this gives useable results in MSYS2 and Cygwin?
Edit: I've added an experimental option --ip
to specify an IP address. This allows to easily check if an estimated IP is valid. (Especially it has to be checked if it works for docker container applications, too.) Example:
runx --ip=192.168.178.46 -- x11docker/check
from runx.
On MSYS2 (and also the others?) maybe this attempt works:
Hostname=$(hostname) nslookup "$Hostname"
Unfortunately, it does not:
# Hostname=$(hostname)
# nslookup "$Hostname"
Server: UnKnown
Address: 212.x.x.x
*** UnKnown can't find DESKTOP: Non-existent domain
I wonder if this IP works; it might also cause yet another firewall issue.
Even if it worked in some setups, I don't think it's desirable to use it. IMHO, the most local IP should be used.
Edit: I've added an experimental option
--ip
to specify an IP address. This allows to easily check if an estimated IP is valid. (Especially it has to be checked if it works for docker container applications, too.) Example:runx --ip=192.168.178.46 -- x11docker/check
I guess that users with conflictive setups might want to setup RUNX_IP_ADDR
envvar, which runx might pick automatically?
from runx.
What is the output of hostname
in MSYS2? Maybe it works to set --ip=$(hostname)
. Though, using a name instead of an IP address could cause delays due to DNS resolving.
Does /etc/resolv.conf
contain anything useful? On debian it only contains the IP of my DSL modem.
Even if it worked in some setups, I don't think it's desirable to use it. IMHO, the most local IP should be used.
I agree.
I guess that users with conflictive setups might want to setup RUNX_IP_ADDR envvar, which runx might pick automatically?
Why would you prefer an envvar over an option? However, I'd prefer an automatic solution that does not need either.
from runx.
What is the output of
hostname
in MSYS2? Maybe it works to set--ip=$(hostname)
. Though, using a name instead of an IP address could cause delays due to DNS resolving.
hostname
is DESKTOP-XXXXXXX
, which is the "Device name" in the 'About' page of the PC properties. That's the name that shows when browsing 'Network' in the file explorer.
Does
/etc/resolv.conf
contain anything useful? On debian it only contains the IP of my DSL modem.
/etc/resolv.conf
does not exist.
Why would you prefer an envvar over an option? However, I'd prefer an automatic solution that does not need either.
The envvar can be set in ~/.bashrc
, so that specifying --ip
each time is not required. It's the closest to an automatic solution, with a minimal initial setup. I don't think it needs to be envvar or option, both can be supported.
from runx.
I found that ipconfig.exe
likely always shows a valid local network IP starting with 192.168.*.*
This check should work on all of MSYS2/Cygwin/WSL/WSL2:
ipconfig.exe | grep 'IPv4' | grep -o '192\.168\.[0-9]*\.[0-9]*' | head -n1
@CptnGreen @eine Could you please check if this gives an IP adress everywhere and also works with runx
?
from runx.
@eine Thank you very much! I'll set this as default now.
There used to be some Docker NAT which started with 10.*. That seems not to be the case now.
I am surprised. Is there no obvious Docker interface anymore? My intention was to prefer DockerNAT
over 192.168.*
if available because it is "more" local.
from runx.
It seems there is no obvious interface anymore. See docker/for-win#5538.
I agree with you it would be more desirable, tho.
from runx.
Related Issues (12)
- Cygwin install instructions are invalid HOT 1
- Smaller (performance) issues
- Prefer WSL2 internal IP to external IP
- Options are parsed after check_host called - so the "verbose" option is not detected in time to be used in check_host
- When sourced, runx -h outputs help and then a load of error messages
- runx does not detect WSL2 HOT 26
- Copyright notice HOT 3
- Is there a way to re-use an existing launched runx session? HOT 3
- Doesn't detect VcXsrv installed into C:\Program Files (x86)\VcXsrv HOT 3
- Drop xauth dependency / custom cookie creation HOT 21
- reuse $DISPLAY variable HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from runx.