forked from Kyrie1965/unblock_keenetic
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path100-redirect.sh
executable file
·22 lines (17 loc) · 943 Bytes
/
100-redirect.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/opt/bin/env bash
[ "$type" == "ip6tables" ] && exit 0
[ "$table" != "nat" ] && exit 0
if [ -z "$(iptables-save 2>/dev/null | grep unblock)" ]; then
ipset create unblock hash:net -exist
iptables -w -t nat -A PREROUTING -i br0 -p tcp -m set --match-set unblock dst -j REDIRECT --to-port 9141
iptables -w -t nat -A PREROUTING -i br1 -p tcp -m set --match-set unblock dst -j REDIRECT --to-port 9141
fi
if [ -z "$(iptables-save 2>/dev/null | grep "udp \-\-dport 53 \-j DNAT")" ]; then
iptables -w -t nat -I PREROUTING -i br0 -p udp --dport 53 -j DNAT --to 192.168.1.1
iptables -w -t nat -I PREROUTING -i br1 -p udp --dport 53 -j DNAT --to 192.168.1.1
fi
if [ -z "$(iptables-save 2>/dev/null | grep "tcp \-\-dport 53 \-j DNAT")" ]; then
iptables -w -t nat -I PREROUTING -i br0 -p tcp --dport 53 -j DNAT --to 192.168.1.1
iptables -w -t nat -I PREROUTING -i br1 -p tcp --dport 53 -j DNAT --to 192.168.1.1
fi
exit 0