11

I have samba server already running on standard ports(445 and 139). This samba server is integrated in Alfresco application. I need to setup new samba server but now I have problem with ports. Ok, so in my smb.conf I put this option

smb ports = 450 140

Restart samba

/etc/init.d/samba restart

I have

root@ubuntu:/etc/samba# netstat -na |grep 450
tcp        0      0 0.0.0.0:450             0.0.0.0:*               LISTEN

but how to connect to samba share folder from windows machine on port different then standard samba port?

4 Answers 4

9

This can't be done. Windows does not support TCP ports other than 445/139. Here is one reference.

1
3

use NAT

this can be done by applying some rule on your router/gateway

[windows]--139-->[dst-nat 139 to x.x.x.x:1139 router ]-->1139-->[samba-server listen on :1139]

1

I have tried different approach, and finally got the solution. Here's the approach:

  1. You need to close the local samba server first.
  • sc config lanmanserver start=disabled
  • sc stop lanmanserver
  • Reboot
  1. Use netsh interface command create a new port proxy for this ip. If your server ip is ipv6, you should use v4tov6, otherwise v4tov4. Here my example, assuming your service's port is 1139:

    netsh interface portproxy add v4tov6 listenport=445 connectaddress=[blah:blah:blah:blah] connectport=1139
    
  2. You are now able to connect to your samba server via \\127.0.0.1

Wish you enjoy the solution!

1
  • I don't know why but after copying around 20 gb of data my pc is completely unresponsive Commented Apr 2, 2022 at 22:05
1

@Arjo's answer is useful if you have admin access to an external network, and @linzuojian's is useful if you don't host a samba share already on windows; but you can combine the two using a loopback device to have your cake and eat it too (interestingly @Rahul says it cannot be done, but then links to a really old tutorial on how this was accomplished on XP..)

On Windows 10 admin PowerShell:

iwr `
    'https://gist.githubusercontent.com/Hashbrown777/081e57ff9673a1f457e1c3a71b55cfaf/raw/28dcd74be1281812e2ef17b1bd36c6b5db216ca3/attachsmb.ps1' `
    -OutFile attachsmb.ps1
Install-Module -Name LoopbackAdapter -MinimumVersion 1.2.0.0
. './attachsmb.ps1'
Create-Host -Name ubuntusmb -Ip 10.254.0.1 -Dest <#ubuntu's IP#> -Port 450
<#REBOOT#>
explorer \\ubuntusmb

This allows you to maintain a native SMB share locally AND connect to another on a non-standard port (local or external) only configuring your local machine.

Basically you give your machine another IP with your new fake network interface, on this new IP you can host on port 445 forwarding to the non-standard server, and finally you can assign this IP any hostname you like with your hosts file.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.