#!/bin/sh

zt0="$(ifconfig | grep 'zt' | awk '{print $1}')"
[ -z "${zt0}" ] && zt0="$(cat "/tmp/zt.nif")"

for i in ${zt0}
do
	ip_segment=""
	iptables -D FORWARD -i "$i" -j ACCEPT 2>/dev/null
	iptables -D FORWARD -o "$i" -j ACCEPT 2>/dev/null
	iptables -t nat -D POSTROUTING -o "$i" -j MASQUERADE 2>/dev/null
	ip_segment="$(ip route | grep "dev $i proto" | awk '{print $1}')"
	iptables -t nat -D POSTROUTING -s "${ip_segment}" -j MASQUERADE 2>/dev/null
	echo "zt interface $i is stopped!"
done
