Advertisement
odcold

010-bypass.sh

Jan 8th, 2025
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.17 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. [ "$type" = "ip6tables" ] && exit
  4. [ "$table" != "mangle" ] && exit
  5.  
  6. ipset_lists="bypass bypass2"
  7. SOURCE_IP="192.168.1.0/24,172.16.5.0/24"
  8. INTERFACE="br0"
  9.  
  10. for bypass_desc in $ipset_lists; do
  11.  
  12.     if ! ipset --quiet list "$bypass_desc" >/dev/null 2>&1; then
  13.         continue
  14.     fi
  15.  
  16.     mark_id=$(curl -kfsS http://localhost:79/rci/show/ip/policy | jq -r ".[] | select(.description == \"$bypass_desc\") | .mark")
  17.     if [ -z "$mark_id" ]; then
  18.         continue
  19.     fi
  20.  
  21.     if ! iptables-save | grep -qw "$bypass_desc"; then
  22.  
  23.         iptables -w -t mangle -A PREROUTING -s "$SOURCE_IP" -m conntrack --ctstate NEW -m set --match-set "$bypass_desc" dst -j CONNMARK --set-mark 0x$mark_id
  24.         iptables -w -t mangle -A PREROUTING -s "$SOURCE_IP" -m set --match-set "$bypass_desc" dst -j CONNMARK --restore-mark
  25.  
  26.         for iface in $INTERFACE; do
  27.             iptables -w -t mangle -A PREROUTING -i "$iface" -m conntrack --ctstate NEW -m set --match-set "$bypass_desc" dst -j CONNMARK --set-mark 0x$mark_id
  28.             iptables -w -t mangle -A PREROUTING -i "$iface" -m set --match-set "$bypass_desc" dst -j CONNMARK --restore-mark
  29.         done
  30.     fi
  31. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement