root@OpenWrt:~# cd /etc/config/ root@OpenWrt:/etc/config# mkdir rezerv root@OpenWrt:/etc/config# cd ./rezerv
root@OpenWrt:/etc/config/rezerv# cat > _
root@OpenWrt:/etc/config/rezerv# ls -l -rwxrwxrwx 1 root root 190 Feb 19 20:49 3g_on -rwxrwxrwx 1 root root 186 Feb 19 21:14 t5t -rwxrwxrwx 1 root root 1136 Feb 20 13:44 test_sh -rw-r--r-- 1 root root 0 Feb 20 13:44 wan -rwxrwxrwx 1 root root 100 Feb 20 12:13 wan_on
root@OpenWrt:/etc/config/rezerv# chmod 777
/etc/config/rezerv/test_sh; sleep 8; /etc/config/rezerv/test_sh; sleep 8; /etc/config/rezerv/test_sh; sleep 8; /etc/config/rezerv/test_sh; sleep 8; /etc/config/rezerv/test_sh; sleep 8;
#wan /sbin/ifconfig 3g-3g down #ifconfig eth0 up /sbin/route add default gw 10.112.28.253 metric 0
#3g - vklu4aem 3g /sbin/ifconfig eth0 down /sbin/ifconfig 3g-3g up /sbin/route add default gw 10.64.64.64 metric 0 /sbin/ifconfig eth0 up /sbin/route add default gw 10.112.28.253 metric 20
test_sh root@OpenWrt:/etc/config/rezerv# cat test_sh #!/bin/sh #blok1 DIR=/etc/config/rezerv/ #DIR=/home/calc/rezerv/ ROUTE=/sbin/route GREP=/bin/grep RM=/bin/rm TOUCH=/bin/touch #blok2 #tested address www.ru #WWW_RU=194.87.0.50 WWW_RU=alltimeallivehost.lan #blok3 #flags F3G=3g FWAN=wan FCUR=$FWAN #blok4 #on ON_3G=3g_on ON_WAN=wan_on ON_DEF=$ON_WAN #blok5 #def routines R_WAN=10.112.28.253 R_3G=10.64.64.64 R_CUR=$R_WAN #blok6 #proverka flagov if [ ! -f $DIR$F3G ]; then if [ ! -f $DIR$FWAN ]; then echo "no one file exist, use default iface" echo $DIR$ON_DEF else R_CUR=$R_WAN FCUR=$FWAN fi else R_CUR=$R_3G FCUR=$F3G fi #blok7 #proverka tekushego marshruta if [ "$ROUTE | $GREP default | $GREP $R_CUR | wc -l" != "0" ]; then echo "$FCUR route exist" else echo "add $FCUR route" $ROUTE add default gw $R_CUR metric 0 fi #blok8 #toggle if not work ##PING www.ru if ping -w3 -c2 -I eth0 $WWW_RU > /dev/null 2>&1; then echo "MAIN working"; if [ -f $DIR$F3G ]; then echo "3g used, wan_on" $DIR$ON_WAN $RM $DIR$F3G $TOUCH $DIR$FWAN fi else echo "MAIN not working"; #if [ -f $DIR$FWAN ]; then echo "wan used, 3g_on" $DIR$ON_3G $RM $DIR$FWAN $TOUCH $DIR$F3G #fi fi
root@OpenWrt:/etc/config/rezerv# cat /etc/rc.local # Put your custom commands here that should be executed once # the system init finished. By default this file does nothing. echo $((10*1024*1024)) > /sys/block/zram0/disksize mkswap /dev/zram0 swapon /dev/zram0 #udalaem flagi rm /etc/config/rezerv/wan rm /erc/config/rezerv/3g exit 0
dhcp-option=lan,6,10.112.1.1,10.112.2.1,8.8.8.8
C:\Users\calc>ipconfig /all Ethernet adapter : DNS- . . . . . : lan . . . . . . . . . . . . . : Atheros AR8161/8165 PCI-E Gigabit Etherne t Controller (NDIS 6.20) . . . . . . . . . : 10-BF-48-22-58-64 DHCP . . . . . . . . . . . : . . . . . . : IPv6- . . . : fe80::d1de:d8aa:f5c4:667b%13() IPv4-. . . . . . . . . . . . : 192.168.1.112() . . . . . . . . . . : 255.255.255.0 . . . . . . . . . . : 20 2013 . 12:11:43 . . . . . . . . . . : 21 2013 . 0:36:25 . . . . . . . . . : 192.168.1.1 DHCP-. . . . . . . . . . . : 192.168.1.1 IAID DHCPv6 . . . . . . . . . . . : 353419080 DUID DHCPv6 . . . . . . . : 00-01-00-01-17-6E-9B-C2-10-BF-48-22-58-64 DNS-. . . . . . . . . . . : 10.112.1.1 10.112.2.1 8.8.8.8 NetBios TCP/IP. . . . . . . . :
C:\Users\calc>ping www.ru -t www.ru [194.87.0.50] 32 : 194.87.0.50: =32 =2 TTL=57 194.87.0.50: =32 =2 TTL=57 194.87.0.50: =32 =2 TTL=57 # . . . . . . . 194.87.0.50: =32 =1946 TTL=47 194.87.0.50: =32 =78 TTL=47 194.87.0.50: =32 =56 TTL=47 194.87.0.50: =32 =55 TTL=47 194.87.0.50: =32 =64 TTL=47 194.87.0.50: =32 =53 TTL=47 194.87.0.50: =32 =52 TTL=47 194.87.0.50: =32 =61 TTL=47 194.87.0.50: =32 =60 TTL=47 194.87.0.50: =32 =59 TTL=47 194.87.0.50: =32 =57 TTL=47 194.87.0.50: =32 =57 TTL=47 194.87.0.50: =32 =55 TTL=47 194.87.0.50: =32 =54 TTL=47 # 194.87.0.50: =32 =62 TTL=47 194.87.0.50: =32 =61 TTL=47 194.87.0.50: =32 =60 TTL=47 194.87.0.50: =32 =59 TTL=47 194.87.0.50: =32 =58 TTL=47 # wan 194.87.0.50: =32 =2 TTL=57 194.87.0.50: =32 =2 TTL=57 194.87.0.50: =32 =2 TTL=57 Ping 194.87.0.50: : = 32, = 25, = 7 (21% ) - : = 2, = 1946 , = 120 Control-C ^C C:\Users\calc>
Source: https://habr.com/ru/post/170169/
All Articles