{"id":6350,"date":"2024-03-07T15:55:32","date_gmt":"2024-03-07T13:55:32","guid":{"rendered":"https:\/\/skeletor.org.ua\/?p=6350"},"modified":"2024-03-07T15:55:32","modified_gmt":"2024-03-07T13:55:32","slug":"%d1%80%d0%b5%d0%b7%d0%b5%d1%80%d0%b2%d0%bd%d0%b8%d0%b9-%d0%ba%d0%b0%d0%bd%d0%b0%d0%bb-%d1%87%d0%b5%d1%80%d0%b5%d0%b7-%d0%bc%d0%be%d0%b4%d0%b5%d0%bc","status":"publish","type":"post","link":"https:\/\/skeletor.org.ua\/?p=6350","title":{"rendered":"\u0420\u0435\u0437\u0435\u0440\u0432\u043d\u0438\u0439 \u043a\u0430\u043d\u0430\u043b \u0447\u0435\u0440\u0435\u0437 \u043c\u043e\u0434\u0435\u043c"},"content":{"rendered":"\n<p>\u041f\u043e\u0441\u0442\u0430\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u0456\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u0438\u0441\u044f \u0447\u0435\u0440\u0435\u0437 <strong>3G<\/strong>-\u043c\u043e\u0434\u0435\u043c. \u0412 \u0434\u0430\u043d\u043e\u043c\u0443 \u0432\u0438\u043f\u0430\u0434\u043a\u0443 \u0446\u0435 <strong>Huawei e3372<\/strong>.<\/p>\n\n\n\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u043f\u0456\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044f <strong>\/opt\/scripts\/usb_modem.sh<\/strong>:<\/p>\n\n\n<p><!--more--><\/p>\n<div class=\"wp-block-group\">\n<pre><span style=\"color: #993366;\">#!\/bin\/sh<br \/><\/span><br \/><span style=\"color: #993366;\">#e3372 huawei<\/span><br \/><span style=\"color: #993366;\">vid=\"12d1\"<\/span><br \/><span style=\"color: #993366;\">pid=\"14db\"<\/span><br \/><span style=\"color: #993366;\">ip_addr=\"192.168.222.22\/24\"<\/span><br \/><span style=\"color: #993366;\">base=\"\/etc\/firewall\"<\/span><br \/><span style=\"color: #993366;\">path_dev=\"\/sys\/bus\/usb\/drivers\/usb\"<\/span><br \/><span style=\"color: #993366;\"><br \/>MODESWITCH=\/usr\/sbin\/usb_modeswitch<\/span><br \/><span style=\"color: #993366;\">MODPROBE=\/sbin\/modprobe<\/span><br \/><span style=\"color: #993366;\">AWK=\/usr\/bin\/awk<\/span><br \/><span style=\"color: #993366;\">SED=\/bin\/sed<\/span><br \/><span style=\"color: #993366;\">IP=\/bin\/ip<\/span><br \/><span style=\"color: #993366;\">LSUSB=\/usr\/bin\/lsusb<\/span><br \/><span style=\"color: #993366;\">IPTABLES=\/usr\/sbin\/iptables<\/span><br \/><span style=\"color: #993366;\">IPSET=\/usr\/sbin\/ipset<\/span><br \/><span style=\"color: #993366;\">GREP=\/bin\/grep<\/span><br \/><span style=\"color: #993366;\">XARGS=\/usr\/bin\/xargs<\/span><br \/><span style=\"color: #993366;\">TR=\/usr\/bin\/tr<\/span><br \/><span style=\"color: #993366;\">FIND=\/usr\/bin\/find<\/span><br \/><span style=\"color: #993366;\">SLEEP=\/bin\/sleep<\/span><br \/><span style=\"color: #993366;\"><br \/>$MODESWITCH -v $vid -p $pid -V $vid -P $pid<\/span><br \/><span style=\"color: #993366;\">$MODPROBE usbserial vendor=${vid} product=${pid}<\/span><br \/><span style=\"color: #993366;\"><br \/>$SLEEP 3<\/span><br \/><span style=\"color: #993366;\"><br \/>bus=`$LSUSB | $GREP \"${vid}:${pid}\" | $AWK '{print $2}' | $TR -d '0'`<\/span><br \/><span style=\"color: #993366;\">path_usb=`$FIND ${path_dev} -name ${bus}-*`<\/span><br \/><span style=\"color: #993366;\"><br \/>echo \"-1\" &gt; ${path_usb}\/power\/autosuspend_delay_ms<\/span><br \/><span style=\"color: #993366;\">echo \"on\" &gt; ${path_usb}\/power\/control<\/span><br \/><span style=\"color: #993366;\"><br \/>mac=`$LSUSB -d ${vid}:${pid} -v 2&gt;\/dev\/null | $SED -n 's\/.*\\(iMacAddress.*\\)\/\\1\/p' | $AWK '{print $3}' | $SED -e 's\/\\(.*\\)\/\\L\\1\/'`<\/span><br \/><span style=\"color: #993366;\">eth_if=\"enx${mac}\"<\/span><br \/><span style=\"color: #993366;\"><br \/>$IP address add $ip_addr dev $eth_if<\/span><br \/><span style=\"color: #993366;\">$IP link set $eth_if up<\/span><br \/><span style=\"color: #993366;\"><br \/>\/etc\/firewall\/rc.firewall<\/span><br \/><span style=\"color: #993366;\"><br \/>$IPTABLES -t nat -A POSTROUTING -o $eth_if -j MASQUERADE<\/span><br \/><span style=\"color: #993366;\">$IPTABLES -I FORWARD -p TCP -o $eth_if --dport smtp -j DROP<\/span><\/pre>\n<\/div>\n\n\n<p>\u0412 \u0434\u0430\u043d\u043e\u043c\u0443 \u0441\u043a\u0440\u0438\u043f\u0442\u0456 \u0432\u0456\u0434\u043a\u043b\u044e\u0447\u0430\u0454\u0442\u044c\u0441\u044f \u0430\u0432\u0442\u043e\u0437\u0430\u0441\u0438\u043f\u0430\u043d\u043d\u044f \u043c\u043e\u0434\u0435\u043c\u0443 \u0430 \u0442\u0430\u043a\u043e\u0436 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044f \u0439\u043e\u0433\u043e \u0432 \u0440\u0435\u0436\u0438\u043c &#8220;\u043c\u043e\u0434\u0435\u043c&#8221;, \u0431\u043e \u0456\u043d\u043a\u043e\u043b\u0438 \u0432\u0456\u043d \u0431\u0443\u0432\u0430\u0454 \u0432 \u0440\u0435\u0436\u0438\u043c\u0456 \u0434\u0438\u0441\u043a\u0443.<\/p>\n\n\n\n<p>\u041d\u0430\u0441\u0442\u0443\u043f\u043d\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u0435\u0440\u0435\u0432\u0456\u0440\u044f\u0454 \u0447\u0438 \u0436\u0438\u0432\u0438\u0439 \u043c\u043e\u0434\u0435\u043c \u0456 \u044f\u043a\u0449\u043e \u043d\u0456 &#8211; \u0432\u0438\u043c\u0438\u043a\u0430\u0454 \u0456 \u0432\u043c\u0438\u043a\u0430\u0454 <strong>USB<\/strong>-\u043f\u043e\u0440\u0442:<\/p>\n\n\n<pre><span style=\"color: #993366;\">#!\/bin\/sh<\/span><br \/><br \/><span style=\"color: #993366;\">ip_addr=\"192.168.222.22\/24\"<\/span><br \/><span style=\"color: #993366;\">gw=\"192.168.222.1\"<\/span><br \/><span style=\"color: #993366;\">path_dev=\"\/sys\/bus\/usb\/drivers\/usb\"<\/span><br \/><span style=\"color: #993366;\">vid=\"12d1\"<\/span><br \/><span style=\"color: #993366;\">pid=\"14db\"<\/span><br \/><span style=\"color: #993366;\">sleep_time=3<\/span><br \/><span style=\"color: #993366;\">IP=\/bin\/ip<\/span><br \/><span style=\"color: #993366;\">GREP=\/bin\/grep<\/span><br \/><span style=\"color: #993366;\">CURL=\/usr\/bin\/curl<\/span><br \/><span style=\"color: #993366;\">TR=\/usr\/bin\/tr<\/span><br \/><span style=\"color: #993366;\">LSUSB=\/usr\/bin\/lsusb<\/span><br \/><span style=\"color: #993366;\">AWK=\/usr\/bin\/awk<\/span><br \/><span style=\"color: #993366;\">FIND=\/usr\/bin\/find<\/span><br \/><span style=\"color: #993366;\">SED=\/bin\/sed<\/span><br \/><span style=\"color: #993366;\">SLEEP=\/bin\/sleep<\/span><br \/><br \/><span style=\"color: #993366;\">($IP addr | $GREP $ip_addr) &amp;&amp; ($CURL -s -m 7 --connect-timeout 5 http:\/\/${gw}\/html\/index.html | $GREP hilinkapp_string) &amp;&amp; exit 0<\/span><br \/><br \/><span style=\"color: #993366;\">bus=`$LSUSB | $GREP \"${vid}:${pid}\" | $AWK '{print $2}' | $TR -d '0'`<\/span><br \/><span style=\"color: #993366;\">cd $path_dev || exit 1<\/span><br \/><span style=\"color: #993366;\">usb_number=`$FIND . -name ${bus}-* | $SED 's\/^.\\\/\/\/'`<\/span><br \/><span style=\"color: #993366;\"><br \/>echo \"$usb_number\" &gt; unbind<br \/>$SLEEP $sleep_time<br \/>echo \"$usb_number\" &gt; bind<\/span><br \/><span style=\"color: #993366;\">$SLEEP $sleep_time<\/span><br \/><br \/><span style=\"color: #993366;\">\/opt\/scripts\/usb_modem.sh<\/span><\/pre>","protected":false},"excerpt":{"rendered":"<p>\u041f\u043e\u0441\u0442\u0430\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u0456\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u0438\u0441\u044f \u0447\u0435\u0440\u0435\u0437 3G-\u043c\u043e\u0434\u0435\u043c. \u0412 \u0434\u0430\u043d\u043e\u043c\u0443 \u0432\u0438\u043f\u0430\u0434\u043a\u0443 \u0446\u0435 Huawei e3372. \u0421\u043a\u0440\u0438\u043f\u0442 \u043f\u0456\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044f \/opt\/scripts\/usb_modem.sh:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,10],"tags":[],"class_list":["post-6350","post","type-post","status-publish","format-standard","hentry","category-linux","category-others"],"_links":{"self":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/6350","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6350"}],"version-history":[{"count":1,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/6350\/revisions"}],"predecessor-version":[{"id":6351,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/6350\/revisions\/6351"}],"wp:attachment":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}