• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1904
  • Last Modified:

Map network drive to different port


I'm running a samba server on one of my linux machines and I'd like to connect to it using the windows 'map network drive' interface. However, I've decided that I want to run this samba server on a port besides 139.  How can I tell windows to connect to this port instead, I've tried doing something like


and it doesnt processes the : to indicate an alterernate port as it would in a typical url

I've been told that this is 'impossible', suggestions for a clever work around would be more than welcome.

1 Solution
I would imagine that port 139 is hard coded in to Windows and can't be changed, though someone might know a hack or work around.

You could run a port redirector on the samba box that listens on 139 then forwards the requests to the correct port, but in essence you'd be running the samba box listening on 139 after doing that...it'd just be listening on your alternate port as well.  I can't see much reason for doing that unless a lot of other nix machines are already set up to use your alternate port and you can't warrant the time to change them back to 139.

Another thought would be to run a port redirector locally on the doze boxes...although that would break any sharing to other doze boxes.  If all shares were on the samba box then that should work...also bear in mind that port 445 is used for "simple file sharing", and I believe you'd need TCP and UDP packets forwarded in either case.

A simple command line redirector for windows is at http://www.kmint21.com/free/
A simple one for 'nix is at http://www.boutell.com/rinetd/ (actually there is a windows version as well)

Or, on the linux box you could do the redirecting via iptables like:
iptables -t nat -A PREROUTING -p tcp --dport 445 -i eth0 -j REDIRECT --to-port 4450
iptables -t nat -A PREROUTING -p udp --dport 445 -i eth0 -j REDIRECT --to-port 4450
iptables -t nat -A PREROUTING -p tcp --dport 139 -i eth0 -j REDIRECT --to-port 1390
iptables -t nat -A PREROUTING -p udp --dport 139 -i eth0 -j REDIRECT --to-port 1390
Another idea would be to tunnel SMB through SSH (instructions at http://www.cs.duke.edu/csl/faqs/share_faq.php#[4])

You could set the tunnel on the doze boxes to go from local 139 to remote <whatever your samba is using>

SMB through SSH can be quirky sometimes tho.  Good luck!

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

i_is_mikeAuthor Commented:
Thanks for the responses

The problem is essentially that my ISPs is now blocking 139 in for some ridiculous reason. (my machines are seperated by the internet)

Essentially I need to route to another port without disabling local file sharing. Otherwise it would just be a matter of turning off local file sharing then the port would be free and I could write my own forwarding utility in its place.

My best idea is to somehow create a new address locally. Bind a forwarding service to it on port 139 which routes everything to my linux box on a port of my choosing. Then just map network drive to that new address. But I wouldn't even know where to begin with that.

thoughts appreciated

In that case, 2 options:  

SMB tunneled through SSH as mentioned before, or set up a VPN and then the shares will work through the VPN tunnel.

Openvpn.org has simple open source client/server software for doze and 'nix, or of course you could use any other VPN solution you have access to.  I'm somewhat partial to SSH tunnels in general (running all my work www traffic through one right now to a web proxy on my home network) since they can be used for just about everything, but an OpenVPN setup may be the simplest to get your filesharing working accross the internet.

It is pretty common these days for residential ISP accounts to have 139 blocked...as well as 137, 445, and even 25 to smtp servers not on the ISP's network...thanks to mydoom, blaster, etc & spam zombie boxes.
i agree with fixnix about either the ssh or VPN.  Setting up a VPN is standard practisc for allowing remote users to connect to a server or shared drive.  FYI there is a very good reason your ISP is blocking 139. Security.  You shouln't have this port open at all on your firewall either.  This is a huge secuirty risk.  Set up a VPN or SSH instead.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now