Redirecting tcp / udp ports with socat

From: Redirecting tcp / udp ports with socat

Socat is a command line based utility that establishes two bidirectional byte streams and transfers data between them. It has lots of feauters you can see on it’s man page.

Here we discuss a general problem: You just changed your ISP and your website has new ip address. But, some requests still comes to old ip due to the DNS cache issues. So, you want to forward all traffic which comes to old ip to new ip transparently for a few days like port forwarding in a gateway:
socat TCP-LISTEN:80,fork TCP:NEW_IP:80

In this example, socat waits for a connection to port 80 on old ip server and accepts new connections, forks and transparently relays to new host’s port 80.

Socat can forward UDP sockets too. Indeed, it is even possible to listen UNIX domain socket with socat and forward it to a remote TCP socket. Thanks for this great utility.



在下方填入你的資料或按右方圖示以社群網站登入: Logo

您的留言將使用 帳號。 登出 / 變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 / 變更 )


您的留言將使用 Facebook 帳號。 登出 / 變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 / 變更 )

連結到 %s