Skip to content

Instantly share code, notes, and snippets.

@diablowu
Created March 10, 2015 01:31
Show Gist options
  • Select an option

  • Save diablowu/10e9f33125a294adf93e to your computer and use it in GitHub Desktop.

Select an option

Save diablowu/10e9f33125a294adf93e to your computer and use it in GitHub Desktop.
remove a nat rule
#!/bin/bash
cntip=$1
cntport=$2
prerulenum=`sudo iptables -t nat --list PREROUTING --line-number|grep "${cntip}:${cntport}"|awk '{print $1}'`
sudo iptables -t nat -D PREROUTING $prerulenum
postrulenum=`sudo iptables -t nat --list POSTROUTING --line-number -n|grep "$cntip"|grep "$cntport"|awk '{print $1}'`
sudo iptables -t nat -D POSTROUTING $postrulenum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment