#!/bin/bash
pro='tcp'
NAT_Host='Host_A'
NAT_Port=8080
Dst_Host='Host_B'
Dst_Port=80
iptables -t nat -A PREROUTING -m $pro -p $pro --dport $NAT_Port -j DNAT --to-destination $Dst_Host:$Dst_Port
iptables -t nat -A POSTROUTING -m $pro -p $pro --dport $Dst_Port -d $Dst_Host -j SNAT --to-source $NAT_Host
另存到linux上,修改对应的参数执行一次即可.