37 lines
1.1 KiB
Bash
37 lines
1.1 KiB
Bash
#!/bin/sh
|
|
set -eu
|
|
#cat /root/rc.local-with | grep -v block > /etc/rc.local
|
|
|
|
grep -qi "block" /etc/rc.local && sed -i '\|^/root/startblock\.sh$|d' /etc/rc.local
|
|
|
|
LAN_IF="br-lan"
|
|
LAN_NET="192.168.2.0/24"
|
|
|
|
# -------------------------
|
|
# FILTER: remove CAPTIVE_BLOCK hook + chain
|
|
# -------------------------
|
|
|
|
# Remove any FORWARD jumps that match our hook exactly
|
|
while iptables -C FORWARD -i "$LAN_IF" -s "$LAN_NET" -j CAPTIVE_BLOCK 2>/dev/null; do
|
|
iptables -D FORWARD -i "$LAN_IF" -s "$LAN_NET" -j CAPTIVE_BLOCK
|
|
done
|
|
|
|
# Flush/delete CAPTIVE_BLOCK chain if present
|
|
iptables -F CAPTIVE_BLOCK 2>/dev/null || true
|
|
iptables -X CAPTIVE_BLOCK 2>/dev/null || true
|
|
|
|
# -------------------------
|
|
# NAT: remove CAPTIVE hook + chain
|
|
# -------------------------
|
|
|
|
# Remove any PREROUTING jumps that match our hook exactly
|
|
while iptables -t nat -C PREROUTING -i "$LAN_IF" -s "$LAN_NET" -j CAPTIVE 2>/dev/null; do
|
|
iptables -t nat -D PREROUTING -i "$LAN_IF" -s "$LAN_NET" -j CAPTIVE
|
|
done
|
|
|
|
# Flush/delete CAPTIVE chain if present
|
|
iptables -t nat -F CAPTIVE 2>/dev/null || true
|
|
iptables -t nat -X CAPTIVE 2>/dev/null || true
|
|
|
|
echo "OK: filter rules removed"
|