diff --git a/service.sh b/service.sh index f76d105..c16982f 100644 --- a/service.sh +++ b/service.sh @@ -17,6 +17,21 @@ resetprop -v tether_offload_disabled 1 resetprop -v net.tethering.noprovisioning true resetprop -v tether_entitlement_check_state 0 +# Don't apply iptables rules until Android has fully booted. +until [ $(getprop sys.boot_completed) -eq 1 ]; do + sleep 1 +done + +# Bypass TTL/HL detections for only Tether device (server) -> Tethered To devices (client). +# WARNING: Routers (as the client) require their own TTL/HL increment script. +# Tethering interfaces -> rndis0: USB, wlan1: Wi-Fi, bt-pan: Bluetooth. +# -A: last rule in chain, -I: "head"/first rule (by default) in chain. +for INTERFACE in "rndis0" "wlan1" "bt-pan"; do + iptables -t mangle -A PREROUTING -i $INTERFACE -j TTL --ttl-inc 1 + iptables -t mangle -I POSTROUTING -o $INTERFACE -j TTL --ttl-inc 1 + ip6tables -t mangle -A PREROUTING ! -p icmpv6 -i $INTERFACE -j HL --hl-inc 1 + ip6tables -t mangle -I POSTROUTING ! -p icmpv6 -o $INTERFACE -j HL --hl-inc 1 +done # == Network optimizations == @@ -47,21 +62,4 @@ write /proc/sys/net/ipv4/tcp_fastopen 3 # == END == - -# Don't apply iptables rules until Android has fully booted. -until [ $(getprop sys.boot_completed) -eq 1 ]; do - sleep 1 -done - -# Bypass TTL/HL detections for only Tether device (server) -> Tethered To devices (client). -# WARNING: Routers (as the client) require their own TTL/HL increment script. -# Tethering interfaces -> rndis0: USB, wlan1: Wi-Fi, bt-pan: Bluetooth. -# -A: last rule in chain, -I: "head"/first rule (by default) in chain. -for INTERFACE in "rndis0" "wlan1" "bt-pan"; do - iptables -t mangle -A PREROUTING -i $INTERFACE -j TTL --ttl-inc 1 - iptables -t mangle -I POSTROUTING -o $INTERFACE -j TTL --ttl-inc 1 - ip6tables -t mangle -A PREROUTING ! -p icmpv6 -i $INTERFACE -j HL --hl-inc 1 - ip6tables -t mangle -I POSTROUTING ! -p icmpv6 -o $INTERFACE -j HL --hl-inc 1 -done - exit 0