Skip to content

Instantly share code, notes, and snippets.

@FallenDawn
Created November 10, 2022 05:18
Show Gist options
  • Select an option

  • Save FallenDawn/b1f85f2980cb9b5596c991343609bf6e to your computer and use it in GitHub Desktop.

Select an option

Save FallenDawn/b1f85f2980cb9b5596c991343609bf6e to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment