<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Port on Simon Žekar — unix, communications, stupidities</title><link>https://simon.zekar.com/tags/port/</link><description>Recent content in Port on Simon Žekar — unix, communications, stupidities</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sat, 07 Feb 2009 22:15:08 +0000</lastBuildDate><atom:link href="https://simon.zekar.com/tags/port/index.xml" rel="self" type="application/rss+xml"/><item><title>FreeBSD massive port forwarding</title><link>https://simon.zekar.com/2009/02/07/freebsd-massive-port-forwarding/</link><pubDate>Sat, 07 Feb 2009 22:15:08 +0000</pubDate><guid>https://simon.zekar.com/2009/02/07/freebsd-massive-port-forwarding/</guid><description>&lt;p>&lt;a href="http://portfwd.sourceforge.net/">Portfwd&lt;/a> was the choice of software when I ever needed to forward a port from the server to another server – multiple hops away (not NAT port mapping).&lt;/p>
&lt;p>It uses configuration like this (193.2.1.66 is the local ip, 193.2.1.80 is destination server IP):&lt;/p>
&lt;pre tabindex="0">&lt;code>bind-address 193.2.1.66
tcp { 55443 { =&amp;gt; 193.2.1.80:443 } }
tcp { 55022 { =&amp;gt; 193.2.1.80:22 } }
&lt;/code>&lt;/pre>&lt;p>But it fails doing its job right when you use this on a really busy port/service (500 or more simultaneous established TCP connections).&lt;/p>
&lt;p>&lt;a href="http://www.openbsd.org/faq/pf/">pf&lt;/a> does the forwarding well even over 1000 TCP connections. Example:&lt;/p>
&lt;pre tabindex="0">&lt;code>rdr on em0 proto tcp from any to 193.2.1.66 port 55443 -&amp;gt; 193.2.1.80 port 443
rdr on em0 proto tcp from any to 193.2.1.66 port 55022 -&amp;gt; 193.2.1.80 port 22
nat on em0 from any to 193.2.1.80 -&amp;gt; 193.2.1.66
&lt;/code>&lt;/pre>&lt;p>– the em0 is the name of the outside interface. Without the nat rule, destination server would see a packet with source ip of the client so it would send a packet back directly to the client which causes asymmetric routing and very possible problems. The nat rule changes the source IP to the port forwarders one.&lt;/p>
&lt;p>Happy forwarding,&lt;br>
S.&lt;/p></description></item></channel></rss>