Samba communication using a port different than 445
Asked Answered
J

1

6

Due to several circumstances, I need to configure my windows client to be able to receive through another port than 445 or 139 with Samba communication. The idea is to avoid as much as possible having to install any additional program in windows 10, or if necessary, that it could be configured through code in c++. For my tests, the samba server is running on a Linux machine.

First of all, I’ve tried the samba communication without changing the port and it works perfectly, executing in windows (Start→Run): \\[Ip_Server]\

To change the port in the server, I've added the line smb ports = 2000(this port number is just for the example) in the "/etc/samba/smb.conf" file and checked the change with: netstat -an| grep -iE ":2000". After that, in the client I've tried the following steps:

  • To disable Samba 1.0
  • To delay the startup of the lanmanserver driver: sc config lanmanserver start= delayed-auto
  • To check if the IpHlpSvc driver is running: sc config iphlpsvc start= auto
  • To add a portproxy rule to reroute TCP port 445 to the port 2000 (of course, rebooting after that)

netsh interface portproxy add v4tov4 listenaddress=[Ip_client] listenport=445 connectaddress=[Ip_client] connectport=2000

(I've tried this step with both IPs, client’s and server’s, and changing the order of the ports). After that, I try again the samba connection, and I'm not able to connect with the server.

If anyone knows what the problem might be and has a solution, it would be helpful.

Jeaninejeanlouis answered 14/6, 2021 at 7:47 Comment(0)
O
0

To force iphlpsvc to start before lanmanserver, this guide suggests making iphlpsvc a dependency of lanmanserver, using the following command:

sc config lanmanserver depend= samss/srv2/iphlpsvc

This should allow the port proxy to bind to 445, before lanmanserver binds 445 on all interfaces.

Onomatology answered 17/10, 2024 at 0:50 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.