3 ms·
For Windows 10: Install "Microsoft KM-TEST Loopback Adapter" using Device Manager (Action -> Add Legacy Hardware, Install from a list, network adapter) From C
by Dwedit 3y ago
For Windows 10:
Install "Microsoft KM-TEST Loopback Adapter" using Device Manager (Action -> Add Legacy Hardware, Install from a list, network adapter)
From Control Panel -> Network and Sharing Settings, go to Change Adapter Settings
Rename your Loopback network connection to something else (such as LOOPBACK) so you can tell what it is.
Go to Properties
Uncheck everything except for IPV4.
Go to Properties for IPV4, and assign an IP address. You used to be able to assign something beginning with 127 there, but windows doesn't let you do that anymore. It appears that 192.0.2.1 is a reserved private IP address.
Hit "Advanced...", go to WINS page, disable NetBIOS for that connection.
Now you have a custom localhost-only IP address that has no SMB server bound to it!
You can also use this special loopback device with an SSH client. If you forwarding all the local SMB ports on the IP, it will make it looks like 192.0.2.1 is a computer on your network that's sharing files. Hopefully Windows Firewall isn't interfering.
- marwis 3y agoAlso I think your solution is insufficient because Windows SMB server always binds on wildcard address. You have to disable SMB service or arrange that your server starts before system SMB server. There are some guides online about it.
- deleted 3y ago[deleted]
- marwis 3y agoNot needed anymore. Latest version of Windows 11 finally allows mounting SMB on arbitrary port! NET USE F: \\localhost\foo /TCPPORT:1234 It also supports QUIC and RDMA. I wonder if it would be possible to achieve zero copy with RDMA.
- Dwedit 3y agoInteresting, how does the path canonicalize if you do that? A traditional UNC path becomes "\??\Device\MUP\ComputerName\ShareName" as an NT Object Namespace path (Or "\\?\GLOBALROOT\Device\MUP\ComputerName\ShareName" as a file path) If you change the port number or protocol, is that encoded somewhere in the native path? Fun thing to do, you can use "7-Zip File Manager" to explore unusual styles of file paths. A path like "\\?\GLOBALROOT\Device\MUP\ComputerName\ShareName\" will work fine in 7-zip file manager, even though Windows Explorer (and File Dialogs) will reject such a path.
- marwis 3y agoIt probably doesn't change at all. Blog mentions a way to assign ports to hostnames so I think ports are supplied out of band to SMB client and not included in UNC.
- atesti 3y agoAny more info on this? I found the announcement, but not how it works internally: https://techcommunity.microsoft.com/t5/storage-at-microsoft/smb-alternative-ports-now-supported-in-windows-insiders/ba-p/3974509 https://techcommunity.microsoft.com/t5/storage-at-microsoft/...
- yrro 3y agoHow do you do this without needing to map a drive like it's 1990?
- marwis 3y agoMS blogs say that a way to associate ports to hosts is coming. Unfortunately it doesn't look like they are planning to support ports directly in UNC paths.
- king_geedorah 3y agoDoes Windows not alias all 127.0.0.x to loopback by default? I needed multiple distinct IP addresses for loopback at my last job and while I had to manually alias them with ifconfig on MacOS, I found Fedora had them all aliased by default. Assuming all you need is a distinct IP that goes back to your machine I believe you should be fine without any 3rd party software, but I never set it up on Windows so I could certainly be mistaken.
- marwis 3y agoIt's aliased so you can't bind two different services on the same port on different 127.0.0.x addresses. Windows has built-in SMB server. PS. Loopback driver is not 3rd party.
- king_geedorah 3y agoI see. I appreciate the information.
- o11c 3y ago192.0.2.0/24 is TEST-NET-1, per [1] I suspect that 127.0.0.0/8 breakage is related to IPv6's existence, since only in IPv4 is the whole class A network usable as loopback - at least, it's broken on Linux (you can't do `ping ::ffff:127.1.2.3` ... actually, now that I try it, it fails even for non-loopback addresses? I thought I tested that before) ... I haven't tried explicitly bind()ing the local socket before connect()ing though (most often, you only bind before listen, and let it autobind when you connect). Related, `gethostent` enumeration is completely broken for IPv6 under GLIBC at least. and while I'm ranting about networking, the latest Debian on my laptop "permanently" clobbers the default route (see `ip r`) when the rfkill button is pressed (thus leading to the weird situation where you can access the LAN but not anything beyond it) - to fix, `systemctl restart networking.service` [1]: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml https://www.iana.org/assignments/iana-ipv4-special-registry/... ... huh, that's missing the multicast reservations though ... those are admittedly weird.