Skip to content

Instantly share code, notes, and snippets.

@bilxio
Created October 18, 2018 05:06
Show Gist options
  • Select an option

  • Save bilxio/f1dc41d4ee322fb038433df0664800e2 to your computer and use it in GitHub Desktop.

Select an option

Save bilxio/f1dc41d4ee322fb038433df0664800e2 to your computer and use it in GitHub Desktop.
TCP traffics forwarding via iptables-nat
# 将 12XXX 端口转发至 100.XX.XX.XX:2XXX
iptables -t nat -A PREROUTING -p tcp --dport 12XXX -j DNAT --to-destination 100.XX.XX.XX:2XXX
# 将 100.XX.XX.XX:2XXX 回复的数据包源地址修改为 139.XX.XX.XX
# 注意:如果是 ECS 等网卡不是公网地址的,请设置为网卡实际地址
iptables -t nat -A POSTROUTING -p tcp -d 100.XX.XX.XX --dport 2XXX -j SNAT --to-source 139.XX.XX.XX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment