zapret/init.d/openwrt/firewall.user.tpws_ipset

22 lines
795 B
Plaintext
Raw Normal View History

2019-05-05 23:35:10 +03:00
TPPORT_HTTP=1188
2019-05-03 12:44:43 +03:00
TPWS_USER=daemon
2019-05-05 23:35:10 +03:00
IPT_FILTER_HTTP="-p tcp --dport 80 -m set --match-set zapret dst"
2019-05-03 12:44:43 +03:00
. /lib/functions/network.sh
network_find_wan wan_iface
for ext_iface in $wan_iface; do
network_get_device DEVICE $ext_iface
# DNAT for local traffic
2019-05-05 23:35:10 +03:00
iptables -t nat -C OUTPUT -o $DEVICE -m owner ! --uid-owner $TPWS_USER $IPT_FILTER_HTTP -j DNAT --to 127.0.0.1:$TPPORT_HTTP ||
iptables -t nat -I OUTPUT -o $DEVICE -m owner ! --uid-owner $TPWS_USER $IPT_FILTER_HTTP -j DNAT --to 127.0.0.1:$TPPORT_HTTP
2019-05-03 12:44:43 +03:00
done
network_get_device DEVICE lan
sysctl -w net.ipv4.conf.$DEVICE.route_localnet=1
2019-05-05 23:35:10 +03:00
iptables -t nat -C prerouting_lan_rule $IPT_FILTER_HTTP -j DNAT --to 127.0.0.1:$TPPORT_HTTP ||
iptables -t nat -I prerouting_lan_rule $IPT_FILTER_HTTP -j DNAT --to 127.0.0.1:$TPPORT_HTTP