<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>京东云无线宝 &#8211; 天地一沙鸥</title>
	<atom:link href="https://haoluobo.com/tag/%e4%ba%ac%e4%b8%9c%e4%ba%91%e6%97%a0%e7%ba%bf%e5%ae%9d/feed/" rel="self" type="application/rss+xml" />
	<link>https://haoluobo.com</link>
	<description>to be continue....</description>
	<lastBuildDate>Tue, 31 Oct 2023 08:34:00 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>
	<item>
		<title>京东云无线宝（OpenWrt）控制终端定时断网</title>
		<link>https://haoluobo.com/2023/07/jd-cloud-wireless-treasure-openwrt-controls-client-timing-disconnection/</link>
		
		<dc:creator><![CDATA[vicalloy]]></dc:creator>
		<pubDate>Mon, 31 Jul 2023 12:43:42 +0000</pubDate>
				<category><![CDATA[软件推荐]]></category>
		<category><![CDATA[OpenWrt]]></category>
		<category><![CDATA[京东云无线宝]]></category>
		<category><![CDATA[路由器]]></category>
		<guid isPermaLink="false">https://haoluobo.com/?p=12448</guid>

					<description><![CDATA[最近将家里的路由器从 小米 换成了 京东云无线宝 。换完后发现新路由器不支持设备的定时断网了。对于有小朋友的家 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>最近将家里的路由器从 <code>小米</code> 换成了 <code>京东云无线宝</code> 。换完后发现新路由器不支持设备的定时断网了。对于有小朋友的家庭，定时断网可以很好的帮助小朋友控制上网时间。好在新入的这款路由器基于 <code>OpenWrt</code> 开发，经过几天的研究，顺利的搞定了定时断网功能。</p>



<h2 class="wp-block-heading">开启路由器的SSH</h2>



<p><strong>注：</strong>2023-10 近期路由器被自动升级了。网上的开门方法全部失效，只能尝试TTL开门了。</p>



<p>开始折腾的第一步是搞定路由器的SSH。SSH登录到路由器后就可以随意折腾了。</p>



<p>由于京东云官方的封堵，不同版本固件的SSH开启方式有所不同。</p>



<ol class="wp-block-list">
<li><code>1.5.40r2181&lt;=</code> <a href="https://zyyme.com/jdc.html" target="_blank" rel="noreferrer noopener">郑羊羊咩的窝-京东云</a></li>



<li><code>r2262&lt;</code> <a href="https://www.bilibili.com/read/cv21409975" target="_blank" rel="noreferrer noopener">京东云无线宝r2262之前固件版本开SSH</a></li>



<li><code>r2279&lt;</code> <a href="https://www.bilibili.com/read/cv21907565" target="_blank" rel="noreferrer noopener">京东云无线宝升级r2262固件后打开SSH</a></li>
</ol>



<p>我拿到的这台路由器的固件版本很老，直接采用第一个方法开启SSH。具体方法如下：</p>



<p>登录京东云，打开f12控制台，将下面的代码贴入浏览器控制台并运行。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
$.ajax({
    url: &quot;/jdcapi&quot;,
    async: false,
    data: JSON.stringify({
        jsonrpc: &quot;2.0&quot;,
        id: 1,
        method: &quot;call&quot;,
        params: &#x5B;
            $.cookie(&quot;sessionid&quot;),
            &quot;service&quot;,
            &quot;set&quot;,
            {
                &quot;name&quot;: &quot;dropbear&quot;,
                &quot;instances&quot;: {&quot;instance1&quot;: {&quot;command&quot;: &#x5B;&quot;/usr/sbin/dropbear&quot;]}}
            }
        ]
    }),
    dataType: &quot;json&quot;,
    type: &quot;POST&quot;
})
</pre></div>


<h2 class="wp-block-heading">设备定时断网方案</h2>



<p>OpenWrt系统通常自带 web 管理界面 <code>LuCI</code> ，即使没带也可自行安装。如果有 <code>LuCI</code> ，通过 <code>LuCI</code> 丰富的插件系统，可以轻松的实现上网时间的管控。</p>



<p>京东的这款路由器毕竟不是完整的OpenWrt系统，无法直接安装 <code>LuCI</code> 。为了设备的稳定性，保险起见没有继续折腾 <code>LuCI</code> 。研究后发现京东云路由器的自带的黑明单功能是通过修改设备 <code>/etc/config/wireless</code> 配置文件实现，于是有了下面的方案。</p>



<ol class="wp-block-list">
<li>使用 <code>uci</code> 命令修改 wireless 配置文件，将需要管控的设备加入/移出 Wi-Fi 黑明单。</li>



<li>使用 crontab 创建定时任务，实现定时控制。</li>



<li>在路由器的黑明单中无法查看到通过修改 wireless 加入黑明单的设备。但可以通过将设备加入黑名单再移除的方式对设备进行临时解禁。</li>
</ol>



<h2 class="wp-block-heading">具体操作步骤</h2>



<h3 class="wp-block-heading">登录路由器</h3>



<p>开始路由器的 SSH 登录功能，使用 SSH 客户端登录路由器。用户名为 <code>root</code> ，密码为路由器的管理密码。</p>



<pre class="wp-block-code"><code>ssh root@jdcloudwifi.com</code></pre>



<h3 class="wp-block-heading">创建将设备加入黑明单的相关脚本</h3>



<p>1. 创建目录 <code>/scripts</code> 。我们自己的脚本都将放到该目录。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
mkdir -p /scripts 
cd /scripts
</pre></div>


<p>2. 将下列脚本复制到 <code>/scripts</code> 目录，并使用命令 <code>chmod +x /scripts/*.sh</code> 为脚本添加可执行权限。</p>



<p>disable-wifi.sh</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
#!/bin/sh
# 禁止设备连接 Wi-Fi
# 使用 `cat /etc/config/wireless` 查看无线配置。通过 `option ssid` 找到对应的 Wi-Fi 配置项名称。注： 2.4G 和 5G 两个热点都需要配置。 
uci add_list wireless.ath0.maclist=&quot;$1&quot;
uci add_list wireless.ath1.maclist=&quot;$1&quot;
uci commit wireless
wifi reload
</pre></div>


<p>enable-wifi.sh</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
#!/bin/sh
# 允许设备连接 Wi-Fi
uci del_list wireless.ath0.maclist=&quot;$1&quot;
uci del_list wireless.ath1.maclist=&quot;$1&quot;
uci commit wireless
wifi reload
</pre></div>


<p>disable-tv.sh</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
#!/bin/sh
# 将 dd:dd:dd:dd:dd:dd 换成需要加入黑名单的设备的 MAC 地址
/scripts/disable-wifi.sh dd:dd:dd:dd:dd:dd
</pre></div>


<p>enable-tv.sh</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
#!/bin/sh
/scripts/enable-wifi.sh dd:dd:dd:dd:dd:dd
</pre></div>


<p>3. 执行 <code>crontab -e</code> 编辑系统定时任务。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
# 周一到周五，8点关闭电视网络
0 8 * * 1-5 /scripts/disable-tv.sh
# 周一到周五，18点开启电视网络
0 18 * * 1-5 /scripts/enable-tv.sh
</pre></div>]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
