Refactor add_nat_rule into add_iptables_rule that is more general

This commit is contained in:
Bryan Boreham committed 2014-09-30 15:23:23 +01:00
1 parent 393b5cd459
commit a31d8c4d80
1 file changed
+10 -3
+10 -3
View File
@@ -82,13 +82,20 @@ run_iptables() {
iptables $IPTABLES_W "$@"
}
add_nat_rule() {
if ! run_iptables -t nat -C "$@" >/dev/null 2>&1
# Add a rule to iptables, if it doesn't exist already
add_iptables_rule() {
IPTABLES_TABLE="$1"
shift 1
if ! run_iptables -t $IPTABLES_TABLE -C "$@" >/dev/null 2>&1
then
run_iptables -t nat -A "$@" >/dev/null
run_iptables -t $IPTABLES_TABLE -A "$@" >/dev/null
fi
}
add_nat_rule() {
add_iptables_rule nat $@
}
setup_masquerading() {
run_iptables -t nat -N WEAVE >/dev/null 2>&1 || true
add_nat_rule POSTROUTING -j WEAVE