3

I came across this question here:

Mounting network drive in Windows 10 bash?

Where mounting network share directories between Windows 10 and WSL is supported in Windows 10 Creator's Update (1703). Here in this question, the proposed solution is to mount the directory like so:

sudo mount -t drvfs '\\192.168.xxx.xxx\folder' /mnt/new_folder

I'm going to be focusing on the IP address, the '\\192.168.xxx.xxx' part.

I wanted to know the correct process and procedures required to figure how to find this IP address for WSL and Windows 10 to use. Here are a few questions I have:

  1. How to lookup for this IP Address, especially for LAN/WLAN, and LANs joined by a hub/router?
  2. How do you make changes to the IP Address, so you know exactly how to map the first xxx and the second xxx? Are they related to one another when you're doing the above mentioned lookup?
  3. When a network configuration change occurs, such as needing to reinstall WSL because of accidents (i.e., worst-case scenario like someone running a rm -rf /* in WSL), is the same procedures for finding said IP Address the same as the procedures mentioned/answered for Question 1?

I'm learning as I go, and hopefully the procedures aren't too much of a hassle. If there are duplicate questions, please let me know, because I am pretty sure there are similar questions being asked, but:

  • Superuser's suggested questions didn't come up with what I wanted to know about.
  • Most of the Google search results I find are about mapping directories locally and remotely to different hosts/OSes, but there aren't a whole lot of information for WSL (possibly due to how recent WSL is).

Thanks.

tom_mai78101
  • 177
  • 1
  • 8

1 Answers1

1

First: The answer you've found has 192.168.xxx.xxx only because the question has it. The author of the answer only corrected the surrounding options – usage of -t cifs to -t drvfs, the kind of slashes used, and so on. The rest was just copied from the question and is not authoritative.

But nowhere does it say that you must use an IP address. If you know the computer name, I would expect \\the_computer_name\folder to also work, the same way it already works on "native" Windows. You don't need to resolve it manually if Windows can do the same automatically.

If you usually access the shares via Network explorer, just copy the full path from the explorer's address bar (and add the quotes).

For example, mount -t drvfs '\\desktop-abcdef\Music' /mnt/music.


Second: If you know the computer name and Windows is already able to resolve it, but you still want to look it up manually:

  • From WSL, getent ahosts the_computer_name should work.
  • From standard Windows: ping or nslookup or nbtstat -a the computer name.

(I shouldn't be suggesting ping, as it has a different purpose and the addresses it shows are not always quite correct. But I don't know of a more suitable tool – for example, nslookup is good for DNS but doesn't do NetBIOS or LLMNR at all. There's nbtstat for NetBIOS, but not for LLMNR.)

If it's a situation where you know the computer name but Windows cannot automatically reach it, that requires a bit more details and is out of scope for this thread.


Third: A lot of what you're asking about "filling in the xxx" falls under the basics of IP networking, and I won't go far into detail about how IP addresses, networks and subnets work – it's out of scope for this thread.

But to avoid further confusion, it should be noted that 192.168.xxx.xxx is just an example (of a common address format), but not a form to fill the blanks in. The entire address depends on where you are and how your LAN is configured.

(There are a few address ranges reserved for private LANs, and 192.168.0.0/16 is one of them. Most home/consumer routers come preconfigured with a smaller range such as 192.168.1.0/24, but that's not guaranteed to be the case.)

In any case, when you resolve a name to IP address, you get the whole address at once and there is no need to map any individual components to anything.

grawity
  • 501,077