If you want to use port forwarding, you'll need to know that for every MathLink connection, two different ports are used. The full syntax for TCPIP link names looks like this:
LinkCreate["[email protected],[email protected]", LinkProtocol -> "TCPIP"]
8000 and 8001 are the port numbers while 1.2.3.4
is your IP address. You can pass only a single port number to LinkCreate
as the link name: in this case it will return a LinkObject
containing the full name and the other port will be automatically selected.
However, if you want to use SSH port forwarding, I strongly recommend using the Remote Kernel Strategies package. It will save you a lot of trouble. For example, it will automatically forward ports for all three links that Mathematica needs for Front End - Kernel communication.
Please see the presentation I linked to for more information on how the connection is made and why three links are needed.