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.

發表迴響

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

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s