Forward Multiple Remote SMB Servers on Windows
- Disable Windows LanmanServer (Server) Service
- Add Loopback Adapter
- Configure the newly added loopback adapter
- Forward remote SMB servers
- References
First of all, there are some limitations on Windows we need to be aware of:
- Port of target SMB server must be 445;
- For SMB server, the only loopback address Windows connects to is 127.0.0.1. Other loopback addresses 127.x.x.x won't work.
With these limitations in mind, we have a solution of following steps:
Disable Windows LanmanServer (Server) Service
Windows has a service named LanmanServer (Dispaly name: Server) running by default which binds to 0.0.0.0:445
. We have to disable it first so that we can bind our forwarded SMB server on port 445.
sc.exe config LanmanServer start= disabled
sc.exe stop LanmanServer
If the commands above failed, you will need to disable the following dependent services and then try again.
-
If SMB 1.0/CIFS File Sharing Support is enabled on your system, disable Browser service first and then try again.
sc.exe config Browser start= disabled sc.exe stop Browser
-
If you are using Docker Desktop on Windows, you will need to stop the application, and stop Docker Desktop Service and then try again.
sc.exe config com.docker.service start= demand sc.exe stop com.docker.service
A restart is requried to release the port 445.
Add Loopback Adapter
To generate more loopback addresses, we can add loopback adapters:
- Run
hdwwiz.exe
(Add Hardware Wizard); - Choose "Install the hardware that I manually select from a list (Advanced)";
- Choose "Network adapters" from the list;
- Select Manufacturer "Microsoft" and Model "Microsoft KM-TEST Loopback Adapter";
- Finish.
You can now find the newly created network adapter in ncpa.cpl
(Network Connections of Control Panel).
Configure the newly added loopback adapter
- Right click the adapter, choose Properties;
- Remove all the items except Internet Protocol Version 4 (TCP/IPv4) and the IPv6 one if you need it;
- Configure to use a IP of your choice with subnet mask 255.255.255.255.
Forward remote SMB servers
Now you can forward multiple remote SMB servers to your local machine. One for each adapter you added as above using the configured IP, and one more for 127.0.0.1
.
You may use ssh -L
command, Bitvise SSH Client, putty, or any application of your choice to the actual forward.
Check your listening ports with resmon.exe
(Resource Monitor):