No Router — SMB not working over WAN My home iMac is connected directly to my modem via ethernet. File Sharing is turned on.

If I turn on Internet Sharing and connect my Macbook to the resulting wifi network, I can access files on my iMac via Finder → Go → Connect to Server → smb://&lt;my iMac's internal IP&gt;

Since my iMac is connected directly to my modem, I should be able to use the same process to connect from work. I open Finder and type smb://&lt;my home's external IP&gt; Unfortunately, this leads to an error message ("There was a problem connecting to the server.")

Interestingly, my iMac also has screen sharing enabled. Unlike SMB, this works properly from both home and work.

How can I make SMB work over WAN?

Edit: Despite some security concerns that were raised in the comments, I would still like to know how to do this! I'm actively researching possible risks, but haven't found anything specific, and it's out of scope on this site. I want this to work natively in Finder.
As suspected by @klanomath in the comments (thank you!), the problem was that my ISP, Time Warner Cable, blocks port 445.

The solution was to change macOS's SMB listening port, which can be adjusted by editing /etc/services. Open the file and scroll down until you find two lines that read:

microsoft-ds    445/udp     # Microsoft-DS
microsoft-ds    445/tcp     # Microsoft-DS


On both lines, change 445 to a different, unused port. Save and reboot your computer†. From now on, you will need to append :port-number to the end of your IP address whenever you connect to your Mac via SMB.

Potential security issues aside, this solution feels very "clean" and allows me connect to my iMac via Finder, whereas a protocol such as sftp would require 3rd party software. While my own research has not turned up any concrete security risks affecting the latest version of macOS, anyone opening SMB to WAN should be sure to set a very strong password on their user account.



Credit to this answer on Superuser for pointing me in the right direction.

†If you opened the file in TextEdit or a similar graphical program, you may get a permissions error when you try to save. Either save in a different location and copy to /etc/ manually, or use sudo nano to avoid the problem.