Skip to content

Instantly share code, notes, and snippets.

@FallenDawn
FallenDawn / iptable port
Created November 10, 2022 05:18
iptable port forward
#!/bin/bash
pro='tcp'
NAT_Host='192.168.2.2'
NAT_Port=8777
Dst_Host='192.168.2.111'
Dst_Port=443
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