rhodess@RT-AC3200-4200:/tmp/home/root# cd /jffs/scripts/x3mRouting
rhodess@RT-AC3200-4200:/jffs/scripts/x3mRouting# sh -x x3mRouting.sh ALL 3 BBC asnum=AS2818,AS31459
+ [ ALL = help ]
+ [ ALL = -h ]
+ basename x3mRouting.sh
+ sed s/.sh//
+ SCR_NAME=x3mRouting
+ exec
+ flock 9
+ trap rm -f /tmp/${SCR_NAME}.lock EXIT
+ basename x3mRouting.sh
+ logger -st (x3mRouting.sh) 32240 Starting Script Execution ALL 3 BBC asnum=AS2818,AS31459
(x3mRouting.sh): 32240 Starting Script Execution ALL 3 BBC asnum=AS2818,AS31459
+ NAT_START=/jffs/scripts/nat-start
+ echo ALL 3 BBC asnum=AS2818,AS31459
+ grep -c dir=
+ [ 0 -gt 0 ]
+ DIR=/opt/tmp
+ echo ALL 3 BBC asnum=AS2818,AS31459
+ grep -c server=
+ [ 0 -gt 0 ]
+ echo ALL 3 BBC asnum=AS2818,AS31459
+ grep -c ipset_name=
+ [ 0 -gt 0 ]
+ SRC_IFACE=ALL
+ [ -n 3 ]
+ DST_IFACE=3
+ [ ALL = ALL ]
+ [ ALL = 1 ]
+ [ ALL = 2 ]
+ [ ALL = 3 ]
+ [ ALL = 4 ]
+ [ ALL = 5 ]
+ Set_Fwmark_Parms
+ FWMARK_WAN=0x8000/0x8000
+ FWMARK_OVPNC1=0x1000/0x1000
+ FWMARK_OVPNC2=0x2000/0x2000
+ FWMARK_OVPNC3=0x4000/0x4000
+ FWMARK_OVPNC4=0x7000/0x7000
+ FWMARK_OVPNC5=0x3000/0x3000
+ [ -n BBC ]
+ IPSET_NAME=BBC
+ TAG_MARK=0x4000/0x4000
+ TARGET_DESC=VPN Client 3
+ Set_IP_Rule 3
+ VPN_ID=3
+ ip rule del fwmark 0x4000/0x4000
+ ip rule add from 0/0 fwmark 0x4000/0x4000 table 113 prio 9993
+ ip route flush cache
+ echo ALL 3 BBC asnum=AS2818,AS31459
+ grep -cw del
+ [ 0 -gt 0 ]
+ echo ALL 3 BBC asnum=AS2818,AS31459
+ grep -c src=
+ [ 0 -gt 0 ]
+ echo ALL 3 BBC asnum=AS2818,AS31459
+ grep -c src_range=
+ [ 0 -gt 0 ]
+ echo ALL 3 BBC asnum=AS2818,AS31459
+ grep -c dnsmasq=
+ [ 0 -gt 0 ]
+ echo ALL 3 BBC asnum=AS2818,AS31459
+ grep -c autoscan
+ [ 0 -gt 0 ]
+ echo ALL 3 BBC asnum=AS2818,AS31459
+ grep -c asnum=
+ [ 1 -gt 0 ]
+ ASNUM_Parm ALL 3 BBC asnum=AS2818,AS31459
+ echo ALL 3 BBC asnum=AS2818,AS31459
+ sed -n s/^.*asnum=//p
+ awk {print $1}
+ tr , \n
+ ASN=AS2818
AS31459
+ true
+ awk -v A=AS2818 BEGIN {print A}
+ read -r ASN
+ printf %-.2s AS2818
+ PREFIX=AS
+ echo AS2818
+ sed s/^AS//
+ NUMBER=2818
+ [ AS = AS ]
+ echo 2818
+ grep -oE ^\-?[0-9]+$
+ A=2818
+ [ -z 2818 ]
+ Create_Ipset_List BBC ASN
+ IPSET_NAME=BBC
+ METHOD=ASN
+ Chk_Entware 120
+ READY=1
+ ENTWARE_UTILITY=
+ MAX_TRIES=30
+ [ -n ]
+ [ -z ]
+ [ 120 -eq 120 ]
+ MAX_TRIES=120
+ [ -n 120 ]
+ [ 120 -eq 120 ]
+ TRIES=0
+ [ 0 -lt 120 ]
+ [ -f /opt/bin/opkg ]
+ [ -n ]
+ READY=0
+ break
+ return 0
+ [ 0 -eq 1 ]
+ ipset list -n BBC
+ [ BBC != BBC ]
+ Download_ASN_Ipset_List BBC AS2818 2818 /opt/tmp
+ IPSET_NAME=BBC
+ ASN=AS2818
+ NUMBER=2818
+ DIR=/opt/tmp
+ [ ! -s /opt/tmp/BBC ]
+ curl --retry 3 -sL -o /opt/tmp/BBC_tmp -w %{http_code} https://ipinfo.io/AS2818
+ STATUS=400
+ [ 400 -eq 200 ]
+ curl --retry 3 -sL -o /opt/tmp/BBC_tmp -w %{http_code} https://api.hackertarget.com/aslookup/?q=AS2818
+ STATUS=200
+ [ 200 -eq 200 ]
+ awk { print $1 } /opt/tmp/BBC_tmp
+ grep -v 2818
+ sort -gt / -k 1 /opt/tmp/BBC
+ sort -ut . -k 1,1n -k 2,2n -k 3,3n -k 4,4n
+ mv /opt/tmp/BBC_tmp /opt/tmp/BBC
+ ipset restore -!
+ awk {print "add BBC " $1} /opt/tmp/BBC
ipset v6.32: Error in line 1: Syntax error: cannot parse error:: resolving to IPv4 address failed
+ read -r ASN
+ awk -v A=AS31459 BEGIN {print A}
+ read -r ASN
+ printf %-.2s AS2818
+ PREFIX=AS
+ sed s/^AS//
+ echo AS2818
+ NUMBER=2818
+ [ AS = AS ]
+ echo 2818
+ grep -oE ^\-?[0-9]+$
+ A=2818
+ [ -z 2818 ]
+ Create_Ipset_List BBC ASN
+ IPSET_NAME=BBC
+ METHOD=ASN
+ Chk_Entware 120
+ READY=1
+ ENTWARE_UTILITY=
+ MAX_TRIES=30
+ [ -n ]
+ [ -z ]
+ [ 120 -eq 120 ]
+ MAX_TRIES=120
+ [ -n 120 ]
+ [ 120 -eq 120 ]
+ TRIES=0
+ [ 0 -lt 120 ]
+ [ -f /opt/bin/opkg ]
+ [ -n ]
+ READY=0
+ break
+ return 0
+ [ 0 -eq 1 ]
+ ipset list -n BBC
+ [ BBC != BBC ]
+ Download_ASN_Ipset_List BBC AS2818 2818 /opt/tmp
+ IPSET_NAME=BBC
+ ASN=AS2818
+ NUMBER=2818
+ DIR=/opt/tmp
+ [ ! -s /opt/tmp/BBC ]
+ curl --retry 3 -sL -o /opt/tmp/BBC_tmp -w %{http_code} https://ipinfo.io/AS2818
+ STATUS=400
+ [ 400 -eq 200 ]
+ curl --retry 3 -sL -o /opt/tmp/BBC_tmp -w %{http_code} https://api.hackertarget.com/aslookup/?q=AS2818
+ STATUS=200
+ [ 200 -eq 200 ]
+ awk { print $1 } /opt/tmp/BBC_tmp
+ grep -v 2818
+ sort -gt / -k 1 /opt/tmp/BBC
+ sort -ut . -k 1,1n -k 2,2n -k 3,3n -k 4,4n
+ mv /opt/tmp/BBC_tmp /opt/tmp/BBC
+ awk {print "add BBC " $1} /opt/tmp/BBC
+ ipset restore -!
ipset v6.32: Error in line 1: Syntax error: cannot parse error:: resolving to IPv4 address failed
+ read -r ASN
+ printf %-.2s AS31459
+ PREFIX=AS
+ echo AS31459
+ sed s/^AS//
+ NUMBER=31459
+ [ AS = AS ]
+ grep -oE ^\-?[0-9]+$
+ echo 31459
+ A=31459
+ [ -z 31459 ]
+ Create_Ipset_List BBC ASN
+ IPSET_NAME=BBC
+ METHOD=ASN
+ Chk_Entware 120
+ READY=1
+ ENTWARE_UTILITY=
+ MAX_TRIES=30
+ [ -n ]
+ [ -z ]
+ [ 120 -eq 120 ]
+ MAX_TRIES=120
+ [ -n 120 ]
+ [ 120 -eq 120 ]
+ TRIES=0
+ [ 0 -lt 120 ]
+ [ -f /opt/bin/opkg ]
+ [ -n ]
+ READY=0
+ break
+ return 0
+ [ 0 -eq 1 ]
+ ipset list -n BBC
+ [ BBC != BBC ]
+ Download_ASN_Ipset_List BBC AS31459 31459 /opt/tmp
+ IPSET_NAME=BBC
+ ASN=AS31459
+ NUMBER=31459
+ DIR=/opt/tmp
+ [ ! -s /opt/tmp/BBC ]
+ curl --retry 3 -sL -o /opt/tmp/BBC_tmp -w %{http_code} https://ipinfo.io/AS31459
+ STATUS=400
+ [ 400 -eq 200 ]
+ curl --retry 3 -sL -o /opt/tmp/BBC_tmp -w %{http_code} https://api.hackertarget.com/aslookup/?q=AS31459
+ STATUS=200
+ [ 200 -eq 200 ]
+ awk { print $1 } /opt/tmp/BBC_tmp
+ grep -v 31459
+ sort -ut . -k 1,1n -k 2,2n -k 3,3n -k 4,4n
+ sort -gt / -k 1 /opt/tmp/BBC
+ mv /opt/tmp/BBC_tmp /opt/tmp/BBC
+ awk {print "add BBC " $1} /opt/tmp/BBC
+ ipset restore -!
ipset v6.32: Error in line 1: Syntax error: cannot parse error:: resolving to IPv4 address failed
+ read -r ASN
+ rm /opt/tmp/x3mRouting
+ Create_Routing_Rules BBC
+ IPSET_NAME=BBC
+ iptables -t mangle -D PREROUTING -i br0 -m set --match-set BBC dst -j MARK --set-mark 0x4000/0x4000
+ basename x3mRouting.sh
+ logger -st (x3mRouting.sh) 32240 Selective Routing Rule via VPN Client 3 deleted for BBC fwmark 0x4000/0x4000
(x3mRouting.sh): 32240 Selective Routing Rule via VPN Client 3 deleted for BBC fwmark 0x4000/0x4000
+ iptables -t mangle -A PREROUTING -i br0 -m set --match-set BBC dst -j MARK --set-mark 0x4000/0x4000
+ basename x3mRouting.sh
+ logger -st (x3mRouting.sh) 32240 Selective Routing Rule via VPN Client 3 created for BBC fwmark 0x4000/0x4000
(x3mRouting.sh): 32240 Selective Routing Rule via VPN Client 3 created for BBC fwmark 0x4000/0x4000
+ awk {print $1}
+ sed -n s/^.*asnum=//p
+ echo ALL 3 BBC asnum=AS2818,AS31459
+ ASN=AS2818,AS31459
+ Check_Files_For_Entries ALL 3 BBC asnum=AS2818,AS31459 /opt/tmp
+ SRC_IFACE=ALL
+ DST_IFACE=3
+ IPSET_NAME=BBC
+ OPT1=asnum=AS2818,AS31459
+ DIR=/opt/tmp
+ grep -c Manual
+ echo asnum=AS2818,AS31459
+ [ 0 -ge 1 ]
+ SCRIPT_ENTRY=sh /jffs/scripts/x3mRouting/x3mRouting.sh ALL 3 BBC asnum=AS2818,AS31459
+ [ /opt/tmp != /opt/tmp ]
+ [ ALL = ALL ]
+ VPNID=3
+ IPTABLES_DEL_ENTRY=iptables -t mangle -D PREROUTING -i br0 -m set --match-set BBC dst -j MARK --set-mark 0x4000/0x4000 2>/dev/null
+ IPTABLES_ADD_ENTRY=iptables -t mangle -A PREROUTING -i br0 -m set --match-set BBC dst -j MARK --set-mark 0x4000/0x4000
+ VPNC_UP_FILE=/jffs/scripts/x3mRouting/vpnclient3-route-up
+ VPNC_DOWN_FILE=/jffs/scripts/x3mRouting/vpnclient3-route-pre-down
+ [ -s /jffs/scripts/x3mRouting/vpnclient3-route-up ]
+ grep -c iptables -t mangle -D PREROUTING -i br0 -m set --match-set BBC dst -j MARK --set-mark 0x4000/0x4000 2>/dev/null /jffs/scripts/x3mRouting/vpnclient3-route-up
+ [ 1 -eq 0 ]
+ [ -s /jffs/scripts/x3mRouting/vpnclient3-route-up ]
+ grep -c iptables -t mangle -A PREROUTING -i br0 -m set --match-set BBC dst -j MARK --set-mark 0x4000/0x4000 /jffs/scripts/x3mRouting/vpnclient3-route-up
+ [ 1 -eq 0 ]
+ [ -s /jffs/scripts/x3mRouting/vpnclient3-route-pre-down ]
+ grep -c iptables -t mangle -D PREROUTING -i br0 -m set --match-set BBC dst -j MARK --set-mark 0x4000/0x4000 2>/dev/null /jffs/scripts/x3mRouting/vpnclient3-route-pre-down
+ [ 1 -eq 0 ]
+ [ -s /jffs/scripts/nat-start ]
+ grep -c sh /jffs/scripts/x3mRouting/x3mRouting.sh ALL 3 BBC asnum=AS2818,AS31459 /jffs/scripts/nat-start
+ [ 1 -eq 0 ]
+ [ -s /jffs/scripts/x3mRouting/vpnclient3-route-up ]
+ chmod 755 /jffs/scripts/x3mRouting/vpnclient3-route-up
+ [ -s /jffs/scripts/x3mRouting/vpnclient3-route-pre-down ]
+ chmod 755 /jffs/scripts/x3mRouting/vpnclient3-route-pre-down
+ [ -s /jffs/scripts/nat-start ]
+ chmod 755 /jffs/scripts/nat-start
+ Exit_Routine
+ basename x3mRouting.sh
+ logger -st (x3mRouting.sh) 32240 Completed Script Execution
(x3mRouting.sh): 32240 Completed Script Execution
+ exit 0
+ rm -f /tmp/x3mRouting.lock
rhodess@RT-AC3200-4200:/jffs/scripts/x3mRouting# liststats
BBC - 0
BBC_WEB6 - 81