Portfwd is a small C++ utility which forwards incoming TCP connections and/or UDP packets to remote hosts. It's available under GNU GPL.
Download AreaTake a look at how a configuration file looks:
/* portfwd1.cfg */ tcp /* TCP connections */ { /* * Connections on port 12000 from subnet localhost/24 and * ports in the range 0-5000 are forwarded to 127.0.0.1:23. * Anything else goes to 127.0.0.1:80. */ 12000 { localhost/24:+5000 => 127.0.0.1:23; /* anything else */ => 127.0.0.1:80 }; /* * On port 11000, connections from address localhost, any port, * are forwarded to 127.0.0.1:23. */ 11000 { localhost => 127.0.0.1:23 } } udp /* UDP packets */ { /* * All packets on port 10000 are forwarded to 127.0.0.1:11000. */ 10000 { => 127.0.0.1:11000 } }