View Full Version : [Solved] Port redirection on outgoing connections
January 17th, 2011, 16:51
I have a remote server that I SSH into, which uses a nonstandard port. Is it possible to redirect outgoing connections directly to that port?
Me -> connect to server1 port 22 -> PF rewrite port 22 to port XXX -> connect to server on port XXX.
January 17th, 2011, 19:43
rdr pass on $ext_if inet proto tcp from $somehost to $someserver port 22 -> $someserver port 22332
or you can try the rdr statement on the $int_if if it doesn't work. You may also need additional pass rules depending on what and how you are already filtering. Make sure you check your pflog0 with tcpdump.
January 17th, 2011, 22:58
While that's doable, wouldn't it be simpler/cleaner to just add a host entry into your ~/.ssh/config file to set the port in there? Then you can just SSH to it via ssh someserver.org and OpenSSH will handle setting the port correctly.
I'm guessing the impetus for this thread is the OP doesn't like adding -P 12345 everytime they connect.
January 18th, 2011, 00:36
Or you can just write a simple connect script ('go_server') that makes the ssh connection to the desired port.
There's always more than one way ..
January 25th, 2011, 06:51
Heh, I forgot I posted this. Glad I remembered.
The following worked:
rdr on $int_if inet proto tcp from any to $srv port 22 tag SOMETAG -> $srv port xxx
I prefer this method because it saves reconfiguring every client machine for the change.
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.