【Network】端口转发(Port Forward)

Posted by 西维蜀黍 on 2024-05-06, Last Modified on 2024-05-07

Forward A Local Port to A Local/External Port


Refer to https://swsmile.info/post/linux-ssh-usage/


Refer to https://swsmile.info/post/linux-socat/


Refer to https://swsmile.info/post/linux-iptables/


Refer to https://swsmile.info/post/freebsd-pfctl/

Forward An External Port to An External Port

My scenarios is:

  1. The IP of is xx.rwlb.singapore.rds.aliyuncs.com
  2. My local development env is not able to directly access due to security concerns
  3. My DBA sets a jump server ( as a proxy to allow my local development env to indirectly access
  4. However, all middleware addresses are hard coded in my code repo, i.e.,
  5. I wanna not modify the code and am still able to connect to all middleware

Idea: map to on kernel level, so that connecting actually is forwarded to As a result, my code doesn’t need any changes.


Refer to https://swsmile.info/post/linux-iptables/


// TODO didn’t figure out how exactly