dnsmasq: cleanup IPv6 DNS redirect rule when stop running
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org> (cherry picked from commit b1b7452f333b409932fc179f44abab034cb30838)
This commit is contained in:
parent
c8b98241ee
commit
7c6b26e4b2
@ -1119,7 +1119,7 @@ dnsmasq_start()
|
||||
config_get dns_port "$cfg" port 53
|
||||
if [ "$dns_redirect" = 1 ]; then
|
||||
iptables -t nat -A PREROUTING -m comment --comment "DNSMASQ" -p udp --dport 53 -j REDIRECT --to-ports $dns_port
|
||||
[ -n "$(command -v ip6tables)" ] && ip6tables -t nat -A PREROUTING -m comment --comment "DNSMASQ" -p udp --dport 53 -j REDIRECT --to-ports $dnsport
|
||||
[ -n "$(command -v ip6tables)" ] && ip6tables -t nat -A PREROUTING -m comment --comment "DNSMASQ" -p udp --dport 53 -j REDIRECT --to-ports $dns_port
|
||||
fi
|
||||
}
|
||||
|
||||
@ -1140,19 +1140,9 @@ dnsmasq_stop()
|
||||
|
||||
iptables_clear()
|
||||
{
|
||||
nums=$(iptables -t nat -n -L PREROUTING 2>/dev/null | grep -c "DNSMASQ")
|
||||
if [ -n "$nums" ]; then
|
||||
until [ "$nums" = 0 ]
|
||||
do
|
||||
rules=$(iptables -t nat -n -L PREROUTING --line-num 2>/dev/null | grep "DNSMASQ" | awk '{print $1}')
|
||||
for rule in $rules
|
||||
do
|
||||
iptables -t nat -D PREROUTING $rule 2> /dev/null
|
||||
break
|
||||
done
|
||||
nums=$(expr $nums - 1)
|
||||
done
|
||||
fi
|
||||
config_get dns_port "$cfg" port 53
|
||||
iptables -t nat -D PREROUTING -m comment --comment "DNSMASQ" -p udp --dport 53 -j REDIRECT --to-ports $dns_port 2>"/dev/null"
|
||||
[ -n "$(command -v ip6tables)" ] && ip6tables -t nat -D PREROUTING -m comment --comment "DNSMASQ" -p udp --dport 53 -j REDIRECT --to-ports $dns_port 2>"/dev/null"
|
||||
}
|
||||
|
||||
add_interface_trigger()
|
||||
|
Loading…
x
Reference in New Issue
Block a user