github.com/Asutorufa/yuhaiin@v0.3.6-0.20240502055049-7984da7023a0/scripts/tproxy/openwrt (about)

     1  #! /bin/sh
     2   	
     3  LAN_IPS=${LAN_IPS:-"192.168.2.145 192.168.122.27"}
     4  
     5  ip rule add fwmark 1 table 100
     6  ip route add local 0.0.0.0/0 dev lo table 100
     7  
     8  
     9  iptables -t mangle -N YUHAAIN_TPROXY
    10  iptables -t mangle -A YUHAAIN_TPROXY -d 224.0.0.0/4 -j RETURN
    11  iptables -t mangle -A YUHAAIN_TPROXY -d 255.255.255.255/32 -j RETURN
    12  iptables -t mangle -A YUHAAIN_TPROXY -d 172.16.0.0/16 -j RETURN
    13  iptables -t mangle -A YUHAAIN_TPROXY -d 127.0.0.1/32 -j RETURN
    14  for addr in ${LAN_IPS}; do
    15      logger "add lan $addr"
    16      iptables -t mangle -A YUHAAIN_TPROXY -p tcp -s ${addr} -j TPROXY --on-ip 127.0.0.1 --on-port 8083 --tproxy-mark 1
    17      iptables -t mangle -A YUHAAIN_TPROXY -p udp -s ${addr} -j TPROXY --on-ip 127.0.0.1 --on-port 8083 --tproxy-mark 1
    18  done
    19  
    20  iptables -t mangle -A PREROUTING -j YUHAAIN_TPROXY