Use socat as tcp forwarder on Windows and restrict a few hosts to connect to it

Jephe Wu -

: on the company LAN, only one Windows server is able to connect to smtp server, some other servers need to connect to smtp server as well
Environment: Windows 2000 server A with one NIC, another Windows 2000 server B will be connecting to A at port 25 to reach company smtp server


1. download and setup socat for Windows on server A

download 2 files below from and

Create c:\socat directory and extract both zip files under it

How to test it?
cd socat
2010/10/06 10:59:02 socat[15822] E exactly 2 addresses required (there are 0); use option "-h" for help

Note: once you see above output, that means socat is installed successfully.

2. run socat command with options to do tcp port forwarder
on Windows server A:
cd socat
socat -d -d -lf socat.txt tcp4-listen:25,reuseaddr,fork,tcpwrap=socat,allow-table=socat-allow,deny-table=socat-deny

the following are the content inside socat-allow and socat-deny files:
For socat-allow:

For socat-deny:

on Windows server B:

You can use server A as smtp server which will be forwarded by socat to

note: you can use range option to restrict the source ip such as if that's better for your situation.

a. You can use plugdaemon ( on Linux or iptables(snat/dnat, even for single NIC with kernel parameter net.ipv4.ip_forward enabled) to achive port forwarding function also.
b. socat website is at