标签归档:openwrt

如何让外网访问小米路由器的硬盘文件

解决只能lan口访问,不能wan口访问硬盘资源的问题。

1、小米路由器要开启ssh
2、ssh到小米路由器,编辑/etc/samba/smb.conf.template 文件,将其中的interfaces那一行改为

interfaces = br-lan eth0.2

3、编辑/etc/config/firewall文件,在文件最后添加以下内容:

config rule 'samba_udp'                                
        option src 'wan'                    
        option dest_port '137 138'             
        option proto 'udp'                                  
        option target 'ACCEPT'                  
        option name 'samba_incoming_udp'

config rule 'samba_tcp'        
        option src 'wan'                                   
        option dest_port '139 445'            
        option proto 'tcp'                
        option target 'ACCEPT'                 
        option name 'samba_incoming_tcp'

4、执行/etc/init.d/samba restart命令重启samba服务
5、执行/etc/init.d/firewall restart命令重启防火墙

用\\xxx.xxx.xxx.xxx 访问试试。xxx是小米路由器的wan ip地址

openwrt shadowsocks chinadns 自动脚本

k2定时脚本

[email protected]:~# crontab -l
0 1 * * *  /etc/shadowsocks/update.sh    >> /var/log/shadowsocks_watchdog.log 2>&1
*/10 * * * * /etc/shadowsocks/checknet.sh  >> /var/log/shadowsocks_watchdog.log 2>&1
0 1 * * 7 echo "" > /var/log/shadowsocks_watchdog.log

更新ip地址

[email protected]:~# cat /etc/shadowsocks/update.sh
wget -O- 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | awk -F\| '/CN\|ipv4/ \
{ printf("%s/%d\n", $4, 32-log($5)/log(2)) }' > /etc/chinadns_chnroute.txt \
 && /etc/init.d/shadowsocks restart && /etc/init.d/chinadns restart
[email protected]:~#
检查网络状态,发现有问题就重启
[email protected]:~# cat /etc/shadowsocks/checknet.sh
#!/bin/sh

LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
wget --spider --quiet --tries=1 --timeout=10 www.google.co.jp
if [ "$?" == "0" ]; then
        echo '['$LOGTIME'] No Problem.'
        exit 0
else
        wget --spider --quiet --tries=1 --timeout=10 www.baidu.com
        if [ "$?" == "0" ]; then
                echo '['$LOGTIME'] Problem decteted, restarting shadowsocks.'
                /etc/init.d/shadowsocks restart
                /etc/init.d/chinadns restart
        else
                echo '['$LOGTIME'] Network Problem. Do nothing.'
        fi
fi
[email protected]:~#