Yes,it is the same, iptables-wise to do it with two machines in the same LAN or with remote machines. You just have to know the address of the other machine.
In #1 run as root:
Code:
iptables -t nat -A PREROUTING -p tcp --dport 55242 -j DNAT --to <ip address of #2>:35000
iptables -A FORWARD -d <ip address of #2> -p tcp --dport 35000 -j ACCEPT
sysctl net.ipv4.ip_forward=1
the first line puts a iptables rule to change the destination address and port for traffic directed to #1:55242 , setting them to #2:35000.
the second line allows this redirected traffic to be forwarded
the third line enables traffic forwarding in the kernel.
For most setups this is all that you need. If you have problems let me now. Have in account this is for tcp traffic, if you want to redirect udp traffic just copy lines 1 and 2 and change "tcp" with "udp".