梅林定时开关访客网络

一直搞不懂,据说很强大的梅林,居然连定时开关访客网络这样一个功能都没有现成的(主 WIFI 网络是可以设置定时开关的)。还有就是竟然不能只对访客网络限速!!!——也许资本主义国家可能没有这样的需求吧。

TP-LINK 路由器有些是带定时开关访客网络这个功能的,官网可是设置方法都有呢——访客网络如何定时开启或关闭?▼展开

实现方法

定时执行脚本开启访客网络,定时执行脚本关闭访客网络。

准备工作:启用 jffs——系统管理 -> 系统设置 -> Persistent JFFS2 partition -> Enable JFFS custom scripts and configs。接着打开 SSH,方便通过 WinSCP 传输文件到路由器。

建立一个空白文件,我这里用了 .sh 后缀,取名 GuestWIFIOn.sh,其实没有后缀也可以,编码 utf-8。写入下面的代码并保存。

#!/bin/sh
nvram set wl0.1_bss_enabled=1
nvram set wl0.1_radio=1
nvram commit
service restart_wireless

再建立一个文件:GuestWIFIOff.sh,代码:

#!/bin/sh
nvram set wl0.1_bss_enabled=0
nvram set wl0.1_radio=0
nvram commit
service restart_wireless

两个文件通过 WinSCP 传输到路由器的 /jffs/scripts 目录下,记得权限改为 0755。接着在 wan-start 文件里添加下面的代码:

cru a Start-Guest-WIFI "00 08 * * * /jffs/scripts/GuestWIFIOn.sh"
cru a Stop-Guest-WIFI "00 22 * * * /jffs/scripts/GuestWIFIOff.sh"

意思是每天早上八点开启访客网络,每天晚上十点关闭访客网络。代码添加完,重启一下路由器就生效。

这个方法有个缺点:执行开启和关闭访客网络脚本的时候,主 WIFI 信号也会断一下(目测中断时间在半分钟以内)

RT-AC68U + KoolShare 改版梅林 380.66_4-X7.5 测试通过。

折腾完忽然觉得其实没什么太大用处。囧。

参考文章

0、Setting a random password for guest wifi▼展开

#61

I found an easier way (for me) to manage my kid's WiFi access. I enable/disable guest networks via a small script that my wife and I can run from a term app on our phones. The networks then automatically turn off via a cron set to run in the evening. This way, they don't have to "forget the network" and retype a password every day. Also, if I want to turn off their WiFi at some point during the day, I just run the script with "off" as an argument instead of "on".

Code: #/bin/sh

# Turn on/off kid's wifi for 16 hours

if [ $1 = "on" ]; then nvram set wl0.1_bss_enabled=1 nvram set wl0.1_expire_tmp=57600 service restart_wireless elif [ $1 = "off" ]; then nvram set wl0.1_bss_enabled=0 nvram set wl0.1_expire_tmp=0 service restart_wireless else echo "Invalid parameter! Acceptable parameters are ON or OFF" fi

1、Script to switch on or off a VLAN (guest wireless)▼展开

It seems that: wl -i wl0.1 radio off turns the virtual wireless interface off but it has a "small" side effect: it also turns the real interface wl0 off at the same time! So if you try to manipulate the virtual interface wl0.1 with wl remember that it's always bound to the actual interface. So this is not a solution. However I guess if you have another wireless interface wl1 (e.g. 5 Ghz) you could use wl to change wl0.1 without side effects to wl1. But I don't have such a router now at hand so I can't test this. And it would still mess up wl0.

I now also see why wl0.1_bss_enabled is used in the original script. It's just trying to simulate the behaviour of the Tomato GUI. I checked what changes in the nvram when you enable and disable guest wifi from the GUI. And the result is that wl0.1_bss_enabled and wl0.1_radio go hand in hand.

So the only issue I have with the original script is the echo which is like shouting at the sky :) So here's an improved version of the script (which also fixes the incorrect usage of the term VLAN): Code: if [ $(nvram get wl0.1_radio) -eq 0 ]; then nvram set wl0.1_bss_enabled=1 nvram set wl0.1_radio=1 nvram commit service wireless restart logger -t "custom script" -p info "Button pressed: guest wifi turned ON" else nvram set wl0.1_bss_enabled=0 nvram set wl0.1_radio=0 nvram commit service wireless restart logger -t "custom script" -p info "Button pressed: guest wifi turned OFF" fi Last edited: Jan 31, 2016

2、Time-of-Day limits on Guest access▼展开

Create two scripts: guest_wifi_start.sh

#!/bin/sh

####################################################################################
#                                                                                  #
# Start / Stop Guest WIFI                                                          #
# L. de Bles, 2014                                                                 #
#                                                                                  #
# Called via init-start                                                            #
#                                                                                  #
# 2.4 Ghz Radio                                                                    #
# wl0.1 ---> Guest Network 1                                                    #
# wl0.2 ---> Guest Network 2                                                    #
# wl0.3 ---> Guest Network 3                                                    #
#                                                                                  #
# 5 Ghz Radio                                                                      #
# wl1.1 ---> Guest Network 1                                                    #
# wl1.2 ---> Guest Network 2                                                    #
# wl1.3 ---> Guest Network 3                                                    #
#                                                                                  #
####################################################################################

# start: enabled=1
# stop: enabled=0

   nvram set wl0.1_bss_enabled=0
   service restart_wireless

and

guest_wifi_stop.sh Code: #!/bin/sh

#################################################################################### # # # Start / Stop Guest WIFI # # L. de Bles, 2014 # # # # Called via init-start # # # # 2.4 Ghz Radio # # wl0.1 ---> Guest Network 1 # # wl0.2 ---> Guest Network 2 # # wl0.3 ---> Guest Network 3 # # # # 5 Ghz Radio # # wl1.1 ---> Guest Network 1 # # wl1.2 ---> Guest Network 2 # # wl1.3 ---> Guest Network 3 # # # ####################################################################################

# start: enabled=1 # stop: enabled=0

nvram set wl0.1_bss_enabled=0 service restart_wireless Example is for wl0.1 (Guest Network 1 2,4Ghz)

Create cronjobs with help of init-start script

init-start

Code: #!/bin/sh

# L. de Bles, 2014 # # * * * * * command to execute # - - - - - # | | | | | # | | | | | # | | | | +----- day of week (0 - 7) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, # | | | +------- month (1 - 12) # | | +--------- day of month (1 - 31) # | +----------- hour (0 - 23) # +------------- min (0 - 59) # # --------------------------------------------------------------------------------------------------

cru a Start-Guest-WIFI "00 09 * * * /jffs/scripts/guest_wifi_start.sh" cru a Stop-Guest-WIFI "00 17 * * * /jffs/scripts/guest_wifi_stop.sh" Place all (three) scripts in /jffs/scripts. Don't forget to chmod a+rx /jffs/scripts/*

After rebooting the router guest wifi starts and stops. Last edited: Aug 25, 2014 __________________ RT-AC88U Merlin 380.64 (Main router) RT-AC68U Merlin 380.64 (AP mode)

**One SSID **Different Channels **Total coverage at 2,4 and 5 GHz

3、用命令开关访客网络▼展开

3#+5# 自己找到了,如下: nvram set wl0.1_bss_enabled=1 nvram set wl0.1_expire_tmp=10800 nvram commit service restart_wireless

4、有没有不重启开关访客无线的命令?▼展开

现在论坛里能找到的命令是: 1.不用重启开关所有无线,包括主无线跟访客无线 2.4G wl -i eth1 radio off wl -i eth1 radio on

wl -i eth1 up wl -i eth1 down

5G wl -i eth2 radio off wl -i eth2 radio on

wl -i eth2 up wl -i eth2 down

2.需要重启才有效的单独开关访客无线 2.4G nvram set wl0.1_bss_enabled=0关 nvram set wl0.1_bss_enabled=1开

nvram commit 5G nvram set wl1.1_bss_enabled=0关 nvram set wl1.1_bss_enabled=1开

nvram commit 3.不用重启断开访客无线,但是人家还能搜的到的,能连的上就是上不了网 关闭2.4访客: ifconfig wl0.1 down或者 ip link set wl0.1 down 启动2.4访客: ifconfig wl0.1 up或者 ip link set wl0.1 up(这条重启了之后,访客限速脚本失效,要重新运行 关闭5G访客 ifconfig wl1.1 down或者 ip link set wl1.1 down

开启5G访客 ifconfig wl1.1 up或者 ip link set wl1.1 up(这条重启了之后,访客限速脚本失效,要重新运行

++++++++++++++++++++++++++++++++++++++++++++++++ 就是没找到不用重启开关访客网络的命令,向各位大神讨一个好用的,还请大家不要吝啬吆

除非注明,垃圾站文章均为网络收集,本文地址 https://cyhour.com/523/AMP 加速版本」,转载请以链接形式注明出处。
声明:我们不销售主机,任何VPS主机均有跑路风险且需定期备份,防止数据丢失。信息以实际为准,评测仅供参考不代表权威!
🍄:Netflix 奈飞 YouTube 合租

Gravatar 头像被墙及解决方案 Gravatar 头像国内镜像地址大全

Gravatar 头像真是一言难尽,时而正常时而抽风时而无法访问……就一个 Gravatar 头像,这有啥好强(现代通假字)的呢?(据说是被其它服务连累?) 解决办法 - 调用 ssl/cn 头像链接 历史解决办法:调用 ssl 头像链接——https还是没被墙的,而且速度还不错,直接调用这个最简单了。主题 functi…
浏览: 123 标签:  , 

Redmi Note 9 4G 刷机欧洲EU版净化去广告

虽然口水苹果十三香,但是眼下囊中确实只有红米……到手不用 1000 大洋,试试也无妨,实在不行再找银行/东哥要十三香。 入手 Redmi Note 9 4G 缘由:领导的微信机 iPhone SE 一代确实很老了(再过两个月就开始第六个年头了),没有换过电池,进过水修过一次,现在经常尿崩突然就关机了得插上…

使用 GoAccess 分析 Nginx 日志

最近发现博客加载图片大多时候都是龟速,想过换服务器,换回主机(比如传说中的外贸主机 SiteGround),图片上 CDN……想了一圈,最终什么都没动,一是穷二是懒三是图片多茄大的水文并不多,先这样吧,实在不行再折腾。倒是忍不住折腾了一下 GoAccess 分析 Nginx 日志,分析了一圈,没什么用。 记录…
浏览: 97 标签:  ,  ,  , 

WordPress 纯代码实现彩色标签云及简单优化配置

WordPress 自带标签云小工具,侧栏直接添加即可,就是默认样式有点平淡,可以加点代码实现彩色标签云及简单优化一下。 WordPress 纯代码实现彩色标签云 代码丢到 WordPress 主题 functions.php 文件即可: //彩色标签云 tag cloudfunction theme_color_cloud_hook($text) { $text = preg_rep…
浏览: 27 标签:  ,  ,  ,  , 
浏览: 82 标签:  , 

Comments:12

  1. 感觉没什么必要,特别是在我家。。
    路由放的位置,正好出门只有-85dBm以下了,能上也卡卡的。

    2017.07.01 14:57 # 回复
    1楼
    • @kn007 其实我也只是以前有这个需求,因为邻居的蹭我的 WIFI 的,现在邻居们都用上了移动免费光宽带了。

      2017.07.01 17:37 # 回复
      • @老杨 哈哈哈,好吧。我能说我用着电信,偶尔页蹭下邻居的移动宽带么。。。毕竟20M国际出口的上传下载速度,确实比电信强多了

        2017.07.01 17:39 # 回复
        • @kn007 我现在自己也用着移动的免费宽带呢,不过明年应该就不免费了。移动的上传确实很爽。

          2017.07.01 17:58 # 回复
  2. 然并卵~
    现在流量便宜了~大巴流量用不完~

    2017.07.01 19:04 # 回复
    2楼
    • @chencool 流量?开玩笑,WIFI 有时候都不稳定,4G 信号就更扯淡了,再多的流量也是然并卵,还有电脑呢……

      2017.07.01 20:24 # 回复
  3. 梅林是什么?第一次看到

    2017.07.01 22:09 # 回复
    3楼
    • @安满 一个第三方修改的华硕路由器固件。官网好像是这个:https://asuswrt.lostrealm.ca/。

      2017.07.01 23:08 # 回复
  4. 折腾完发现没什么卵用,因为根本没有访客(好悲伤去哭一会儿

    2017.07.02 10:26 # 回复
    4楼
  5. 天朝的路由器都比较傻瓜啊

    2017.07.02 23:54 # 回复
    5楼

发表留言

Vultr 送$100,搬瓦工年付最低$49,优惠码 BWH3HYATVBJW,更多推荐VPS信息