IT Consulting in Richmond, BC, Canada
Minek Systems Inc. - IT Consulting Vancouver, Canada, Linux Consulting
email fax 305-356-7141
250-2639 Viking Way, Richmond, BC, V6V 1N3, Canada

TCP/IP Port Redirection (SAMBA example)

Imagine you want to map a directory residing on your Linux/UNIX server (or remote Windows machine) to local drive (e.g. L:\) on your Windows desktop.
Netbios protocol used by Microsoft and SAMBA to access and map remote filesystems, uses port 139.
This port is typically not routable over the Internet, most of ISPs are blocking it for security reasons, that's why we can't simply map drive to something like this: \\\myshare.

Also, no other port can be used, as there is no way to force Windows to use some other port other than 139.

Here is simple solution:
Rinetd, (compiled Windows version can be downloaded here) does very simple Port Redirection.
Example: Let's assume that you run SAMBA on your Linux server on port 8844 (instead of 139, for security reasons). All that needs to be done to access SAMBA server shares on your local Windows desktop, is to somehow redirect all TCP/IP traffic that goes to port 139 on your local IP, to
Now, port 139 on your desktop's local IP is already in use by Windows OS. We need a new virtual local IP (e.g. with port 139 not used.
One of the ways to create new IP, is to install Microsoft Loopback adapter.

The Microsoft Loopback adapter is a testing tool for a virtual network environment where network access is not available. Also, you must use the Loopback adapter if there are conflicts with a network adapter or with a network adapter driver. You can bind network clients, protocols, and other network configuration items to the Loopback adapter, and you can install the network adapter driver or network adapter later while retaining the network configuration information.

  1. Click Start, and then click Control Panel.
  2. If you are in Classic view, click Switch to Category View under Control Panel in the left pane.
  3. Double-click Printers and Other Hardware, and then click Next.
  4. Under See Also in the left pane, click Add Hardware,and then click Next.
  5. Click Yes, I have already connected the hardware, and then click Next.
  6. At the bottom of the list, click Add a new hardware device, and then click Next.
  7. Click Install the hardware that I manually select from a list, and then click Next.
  8. Click Network adapters, and then click Next.
  9. In the Manufacturer box, click Microsoft.
  10. In the Network Adapter box, click Microsoft Loopback Adapter, and then click Next.
  11. Click Finish.
  12. Edit Properties of the new network connection, and uncheck all protocols except TCP/IP (remove Client for Microsoft Networks and File and Printer Sharing)
  13. In the TCP/IP properties, "Use the following IP address":, and in Advanced TCP/IP Settings, Disable NetBIOS over TCP/IP (under WINS tab).

At this point we should have a local IP address with port 139 available for TCP/IP traffic redirection.
We can run rinetd and redirect the port. All TCP/IP traffic coming to should be redirected to
We need to create a small config file c:\bin\rinetd\rinetd.conf that will contain only one line of text: 139 8844
Run rinetd:
c:\bin\rinetd\rinetd.exe -c c:\bin\rinetd\rinetd.conf
and try to map a network drive. Example:
net use L: \\\myshare mypassword /USER:username /PERSISTENT:YES
Of course myshare, mypassword and username should be replaced by actual values.

Please note, that if you need to map SAMBA shares from more than one SAMBA server, you will need more virtual IP addresses (e.g., etc...) and additional port redirection with Rinetd for each of the SAMBA servers.

Rinetd does not encrypt or compress the data, so if you require secure connection, you will need to use SSH Tunnel instead. It will run slightly slower than rinetd. We've been often using this and other similar solutions in our IT Consulting services for years.

Our Last Five Customers

  • WCB, Richmond

Technical Guides

Other Links