An SSH tunnel will serve the purpose here, assuming that you configure a gazillion LocalForward ports.
Place these contents into your
Port [SSH port] # (if using port 22, omit this line)
LocalForward 1 0.0.0.0:1 # Replace all these
LocalForward 2 0.0.0.0:2 # port numbers with
LocalForward 3 0.0.0.0:3 # the actual ports
LocalForward 4 0.0.0.0:4 # that you need.
LocalForward 5 0.0.0.0:5 #
LocalForward 6 0.0.0.0:6 # Format is like this:
LocalForward 7 0.0.0.0:7 # LocalForward [port] 0.0.0.0:[port]
LocalForward 8 0.0.0.0:8 #
LocalForward 9 0.0.0.0:9
LocalForward 10 0.0.0.0:10
... and so on for whatever ports you want.
This will set up listening ports on the Mac, and will forward the traffic on those ports to
[hostname] over an SSH connection to
[username] on port
[SSH port] whenever you run this Terminal command:
Keep in mind that
[hostname] must be running an SSH server, and you will get a shell on the remote host in Terminal. It's possible to configure a port-forward-only SSH server, but that is beyond the scope of this answer. If you don't want a shell on the remote server, run this command instead:
ssh [hostname] sleep 3600
You will instead get a 1 hour connection, and no shell. Don't close the Terminal window. If you want, you can set it up such that you can close Terminal by running this:
nohup ssh [hostname] sleep 3600 &
3600 with the number of seconds you want the connection to last.