Created
March 10, 2015 01:30
-
-
Save diablowu/4a6761e231a551f44d63 to your computer and use it in GitHub Desktop.
add a nat rule of iptables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
pro='tcp' | |
cntip=$1 | |
cntport=$2 | |
hostip=$3 | |
hostport=$4 | |
sudo iptables -t nat -A PREROUTING -m $pro -p $pro --dport $hostport -j DNAT --to-destination $cntip:$cntport | |
sudo iptables -t nat -A POSTROUTING -m $pro -p $pro --dport $cntport -d $cntip -j SNAT --to-source $hostip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment