├── Compress_bin.md ├── Guide.md ├── IPv6_Relay.md ├── LICENSE ├── Old_version.md ├── README.md ├── _config.yml ├── compile.sh ├── config ├── config │ ├── dhcp │ └── network ├── index.html └── rc.local ├── files └── README.md └── images ├── breed.png ├── compiled.png ├── dir.png ├── disconnected.jpg ├── ftp.jpg ├── ipv6_prefix.png ├── ipv6_settings.png ├── k2p.jpg ├── no_response.png ├── openwrt.png ├── pandorabox.png ├── platform.png ├── ssh.png ├── telnet.png ├── tracert.png ├── upload.png ├── winscp.png ├── wsl.png └── xenial.png /Compress_bin.md: -------------------------------------------------------------------------------- 1 | # 空间太小放不下mentohust二进制怎么办 2 | 3 | ## 思路:压缩 4 | 运行: 5 | ```shell script 6 | cd /tmp 7 | mkdir compress 8 | cd compress 9 | 10 | # upload your mentohust file here 11 | 12 | tar -czf mentohust.gz mentohust 13 | 14 | cp mentohust.gz /usr/bin 15 | ``` 16 | 体积可以缩小为原来46%左右 17 | 18 | 启动项: 19 | ```shell script 20 | # startup 21 | mkdir /tmp/mentohust 22 | 23 | cp /usr/bin/mentohust.gz /tmp/mentohust 24 | tar -xzf /tmp/mentohust/mentohust.gz -C /tmp/mentohust 25 | rm /tmp/mentohust/mentohust.gz 26 | chmod 755 /tmp/mentohust/mentohust 27 | 28 | /tmp/mentohust/mentohust <*args> 29 | ``` 30 | -------------------------------------------------------------------------------- /Guide.md: -------------------------------------------------------------------------------- 1 | # 支持锐捷认证与IPv6的路由器配置指南:以K2P为例 2 | 3 | ### 写在「写在前言之前」之前: 4 | 5 | 由于交叉编译过程十分繁琐,容易出错,你可以到[MentoHUST-SYSU-OpenWrt](https://github.com/KumaTea/MentoHUST-SYSU-OpenWrt)获取软件包,通过OpenWrt编译工具方便的生成路由器专用软件,省去交叉编译的配置过程。 6 | 7 | [MentoHUST可执行文件直达链接](https://github.com/KumaTea/MentoHUST-SYSU-Guide/releases) 8 | 9 | --- 10 | 11 | _写在前言之前:_ 12 | 13 | _这篇文章是我在2018年8月10日撰写的,当时水平不足,导致文章有不少谬误;且后来[简书](https://www.jianshu.com)平台出现过一段时间不可访问的情况,让我决定作修改后搬来GitHub上。_ 14 | 15 | _修改后的文章会更加严肃。有任何问题或建议,欢迎提出Issue或直接发送Pull Request。_ 16 | 17 | _联系我:[Telegram @KumaTea](https://t.me/kumatea)_ 18 | 19 | --- 20 | 21 | *前言:这篇教程希望给读者,特别是没有相关IT知识的读者,提供一个尽可能简单易读而详尽的路由器配置指南,且期盼与本文实际情况不相同的读者也可以得到一些启发。整个过程用到了许多前辈的技术成果,在此表达感谢。由于水平有限,可能* ***十分冗长*** *、有不少错误和疏漏,还请各位多多海涵。* 22 | 23 | 在校园网只有有线网络的限制下,满足手机平板等无线设备联网并享受校园网的各种优势应该是很多学生党的刚需。本文就以在SYSU的v4.90版本锐捷认证的校园网下,配置典型的**MT7621**芯片的路由器 (PHICOMM **K2P** A2 24 | ) 的实例,来说明这个过程。其他平台及芯片的读者,也可参考本文的通用方法。 25 | 26 | 尽管本文设计为可以按步骤直接从头至尾配置完成,但建议有相似需求的读者,可以先通读一遍教程,再动手。 27 | 28 | ![K2P路由器](images/k2p.jpg) 29 | 30 | --- 31 | 32 | # 准备工作 33 | 34 | * 计算机、支持OpenWrt的路由器 35 | * 查询到IPv6网关(说明见下) 36 | * **“刷入Breed”**步骤中的**k2p.sh**文件 37 | * (建议)“上传MentoHUST到路由器”步骤的[WinSCP](https://winscp.net/eng/download.php)工具 38 | * (建议)[恩山论坛](http://www.right.com.cn/forum)的账号 39 | * Linux系统,推荐Ubuntu 18.04(说明见“锐捷认证与MentoHUST”章节) 40 | 41 | ![路由追踪](images/tracert.png) 42 | 43 | 使用“路由追踪” (Windows: tracert; Linux: traceroute) 命令,可以方便的知道你的网关。 44 | 45 | 例如,在Windows下,请使用有线上网的方式,追踪一个IPv6地址,例如: 46 | 47 | ```cmd 48 | tracert tv.byr.cn 49 | ``` 50 | 51 | 然后记录第一条地址(应该以 2xxx: 开头,不应以 fe80: 开头;记录包含冒号的完整地址)即可。 52 | 53 | --- 54 | 55 | # 锐捷认证与MentoHUST 56 | 57 | **工具 / 步骤 / 参考文献 / 请先阅读** 58 | 1. [Mentohust V4版本的心得](https://codingstory.com.cn/mo-gai-mentohust-v4ban-ben-de-xin-de/),作者是ShanQincheng;**(原网址已失效,且无WebArchive存档,[这里是无图版本](https://github.com/kkkeQAQ/mentohust_nwafu/blob/master/README.md),谷歌图片可搜到少量缓存低清晰度图片) 59 | 2. [Cross Compile [OpenWrt Wiki]](https://wiki.openwrt.org/doc/devel/crosscompile),作者是OpenWrt官方; 60 | 3. [交叉编译mentohust实现锐捷认证共享上网](https://blog.csdn.net/warriorpaw/article/details/7990226),作者是[warriorpaw](https://blog.csdn.net/warriorpaw); 61 | 4. [mentohust v4版本编译及ipv6的配置教程](http://soundrain.net/2016/04/25/mentohust-v4%E7%89%88%E6%9C%AC%E7%BC%96%E8%AF%91%E5%8F%8Aipv6%E7%9A%84%E9%85%8D%E7%BD%AE/),作者请见原页面; 62 | 5. ivechan的[mentohust的SYSU版本](https://github.com/ivechan/mentohust-SYSU) 63 | 6. [mentohust加入v4支持](https://github.com/hyrathb/mentohust),作者是hyrathb; 64 | 7. MentoHUST源码、交叉编译工具包、libpcap请见下文详述。 65 | **MentoHUST**,是由华中科技大学的**HustMoon**(一说liuqun)开发的一款无客户端锐捷认证的软件。近十年来,MentoHUST经过原作者和众多贡献者的努力,已经逐步发展到支持锐捷v2, v3甚至v4认证了。本文中所采用的例子是v4.90版锐捷,也就是v3认证。MentoHUST的原始版本需要再做修改才能适用于实际环境。 66 | 67 | ### 锐捷数据包的分析与MentoHUST的修改 68 | 69 | 对于分析与修改的问题,建议参考[Mentohust V4版本的心得](https://codingstory.com.cn/mo-gai-mentohust-v4ban-ben-de-xin-de/)。 70 | 71 | **分析心跳包这一步需要注意间隔,默认间隔是30s,但我校的间隔则是20s,故需要在后续步骤配置,请大家注意。** 72 | 73 | 本指南没有自行分析修改,而是使用了ivechan的[mentohust的SYSU版本](https://github.com/ivechan/mentohust-SYSU)。 74 | 75 | ### 交叉编译 76 | 77 | 而所谓[交叉编译](enwp.org/Cross_compiler),即为在非目标机器上为目标机器编译。 78 | 79 | 此步骤,推荐使用Ubuntu 18.04 LTS。可选方式: 80 | * 直接安装Linux系统 81 | * 使用 WSL (Windows Subsystem for Linux) 82 | 83 | ![Windows的Linux子系统安装过程](images/wsl.png) 84 | 85 | * 在Windows或Mac上安装虚拟机 86 | 87 | ![虚拟机是比较稳妥的选择](images/xenial.png) 88 | 89 | 90 | 91 | 一 安装Ubuntu完毕后,打开终端 (Terminal),前往 `home` (本指南用户名采用`kumatea`),并创建一个目录。 92 | 93 | ```bash 94 | cd /home/kumatea 95 | mkdir k2p 96 | cd k2p 97 | ``` 98 | 99 | 二 到[OpenWrt的官网](http://downloads.openwrt.org)下载适用于你的路由器的芯片和**当前版本系统**的交叉编译工具包 (SDK)。 100 | 101 | 本指南使用的是[18.06.4版的SDK](http://downloads.openwrt.org/releases/18.06.4/targets/ramips/mt7621/openwrt-sdk-18.06.4-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64.tar.xz)。 102 | 103 | ```bash 104 | wget http://downloads.openwrt.org/releases/18.06.4/targets/ramips/mt7621/openwrt-sdk-18.06.4-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64.tar.xz -O sdk.tar.xz 105 | 106 | tar -xJf sdk.tar.xz 107 | mv openwrt-sdk-18.06.4-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64 sdk 108 | 109 | # 格式为.tar.bz2,命令则为 110 | # tar -xjf sdk.tar.xz 111 | # 注意大小写 112 | # 如果不使用WSL,你还可以使用GUI操作 113 | 114 | rm sdk.tar.xz 115 | ``` 116 | 117 | 三 下载libpcap,[撰文时最新为1.9.1版](https://www.tcpdump.org/release/libpcap-1.9.1.tar.gz),解压到此目录下,注意命令不同: 118 | 119 | ```bash 120 | wget https://www.tcpdump.org/release/libpcap-1.9.1.tar.gz -O libpcap.tar.gz 121 | tar -xzf libpcap.tar.gz 122 | mv libpcap-1.9.1 libpcap 123 | rm libpcap.tar.gz 124 | ``` 125 | 126 | 四 把前面做好的MentoHUST的文件夹放到该目录下。 127 | 128 | ![得到这三个文件](images/dir.png) 129 | 130 | 五 配置环境: 131 | 132 | **首先把下面代码的`kumatea`换成你所创建的账户名,并修改为你自定义的文件夹名,尤其是PATH=$PATH:和STAGING_DIR=这里**,再(建议逐行复制)运行下面的命令: 133 | 134 | ```bash 135 | sudo -i 136 | apt install build-essential bison flex zlib1g-dev libncurses5-dev subversion quilt intltool ruby fastjar unzip gawk autogen autopoint ccache gettext libssl-dev xsltproc zip git 137 | # 大约需要下载55MB 138 | ``` 139 | 140 | ```bash 141 | PATH=$PATH:/home/kumatea/k2p/sdk/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/bin 142 | export PATH 143 | STAGING_DIR=/home/kumatea/k2p/sdk/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl 144 | export STAGING_DIR 145 | export CC=mipsel-openwrt-linux-gcc 146 | export CPP=mipsel-openwrt-linux-cpp 147 | export GCC=mipsel-openwrt-linux-gcc 148 | export CXX=mipsel-openwrt-linux-g++ 149 | export RANLIB=mipsel-openwrt-linux-musl-ranlib 150 | export ac_cv_linux_vers=2.6.24 151 | export LDFLAGS="-static" 152 | export CFLAGS="-Os -s" 153 | 154 | ``` 155 | 这一步需要**特别注意**: 156 | 157 | **`RANLIB`要根据`sdk`里目录的结尾修改**。这个例子,结尾是`musl`,因此`export RANLIB=mipsel-openwrt-linux-musl-ranlib`。如果你的结尾是`uClibc`,就应该改成`export RANLIB=mipsel-openwrt-linux-uclibc-ranlib`。 158 | 159 | 然后cd进入`libpcap`文件夹并执行命令,**要更改`--prefix`路径**: 160 | 161 | ```bash 162 | cd /home/kumatea/k2p/libpcap 163 | ./configure --host=mipsel-linux --prefix=/home/kumatea/k2p/ --with-pcap=linux 164 | make 165 | ``` 166 | `./configure`部分不应出错; 167 | 168 | `make`部分,**只要看到`ranlib libpcap.a`没有出错即可**,不用理会`libpcap.so`是否出错(当然,不出错更好)。 169 | 170 | 完成后,应在`/home/kumatea/k2p/libpcap`下看到`libpcap.a`。 171 | 172 | 六 编译MentoHUST: 173 | 174 | 首先,要获取一下我们自己所在的平台: 175 | 176 | ```bash 177 | cd /home/kumatea/k2p/mentohust 178 | sh autogen.sh 179 | ./config.guess 180 | ``` 181 | 182 | 这时终端会输出你的平台: 183 | ![平台代码](images/platform.png) 184 | 185 | 例如虚拟机是`x86_64-pc-linux-uclibc`,WSL是`x86_64-pc-linux-gnu`;替换到下面的`--build`,再执行: 186 | 187 | ```bash 188 | ./configure --build=x86_64-pc-linux-gnu --host=mipsel-linux --disable-encodepass --disable-notify --with-pcap=/home/kumatea/k2p/libpcap/libpcap.a 189 | make 190 | ``` 191 | 192 | 这个时候,如果运行无误,就可以进入/home/kumatea/k2p/mentohust/src,获取`mentohust`文件了。你也可以立即计算MD5,确保后续操作时文件保持原样。 193 | ![文件如图,仅供参考](images/compiled.png) 194 | 195 | ```bash 196 | md5sum /home/kumatea/k2p/mentohust/src/mentohust 197 | ``` 198 | 199 | --- 200 | 201 | # 刷入Breed 202 | 203 | ### [更新] 下方工具方法已经过时,请使用[K2P_Telnet.exe](files/firmware/K2P_Telnet.exe) 204 | 205 | **工具 / 步骤 / 参考文献 / 请先阅读** 206 | 1. [[k2p] K2/K2P/K3/K3C 新版固件 Telnet 激活工具 207 | ](http://www.right.com.cn/forum/thread-221578-1-1.html),作者是[phitools](http://www.right.com.cn/forum/space-uid-389408.html); 208 | 2. [[k2p] 【2018-06-19】斐讯K2P MTK官方固件定制版,加adb、S-S R、KMS等【V1.6】](http://www.right.com.cn/forum/thread-221578-1-1.html),作者是[abccba94](http://www.right.com.cn/forum/space-uid-140971.html)。 209 | * 由于路由器买来之后一般附带的是官方固件,我们需要把它更换为第三方的功能更全的固件,才能进行下一步的操作。 210 | * 刷入固件前,一般需要刷入Breed,可以近似的理解为解锁BootLoader后刷入的Recovery,还是TWRP这一类的。 211 | 212 | 1. 在[[k2p] K2/K2P/K3/K3C 新版固件 Telnet 激活工具 213 | ](http://www.right.com.cn/forum/thread-221578-1-1.html)处确认适用的版本,如适合则下载```RoutAckProV1B2.rar```并解压。 214 | 2. 确保开启Telnet: 215 | ![Windows下开启Telnet](images/telnet.png) 216 | 3. 仅连接电脑的有线网口与路由器的LAN口,不连接WAN口,然后路由器上电启动。 217 | 4. 打开`RoutAckProV1B2.exe`,当路由器LED灯由红变为黄时,立即点击`打开Telnet`按钮。等待出现成功信息,若不成功请再试一次。下图示失败情况: 218 | ![错误示范](images/no_response.png) 219 | 5. 成功打开Telnet后,连接到你的路由器,可以使用PuTTY等工具连接,也可以用命令提示符: 220 | 221 | ```cmd 222 | telnet 192.168.1.1 223 | ``` 224 | 225 | 6. 使你在准备步骤中下载的`k2p.sh`文件处于可访问状态。如果路由器不能上网,可以通过ftp服务器的方式上传: 226 | ![用es文件浏览器开启ftp服务器](images/ftp.jpg) 227 | 然后执行: 228 | 229 | ```bash 230 | wget <你的k2p.sh地址> -O - |sh 231 | ``` 232 | 233 | 来进行Breed刷写。出现`upgrade ok! reboot...`就成功了。 234 | 235 | 7 进入Breed: 236 | * 路由断电 237 | * 按住Reset,通电 238 | * 待LED颜色交替闪烁时放开 239 | * 访问[http://192.168.1.1](http://192.168.1.1),若能看到**Breed Web 恢复控制台**的蓝色大字标题,即为成功。 240 | ![Breed](images/breed.png) 241 | 242 | --- 243 | 244 | # 刷入OpenWrt 245 | 246 | ### [更新] 目前已换用对**IPv6多线多拨负载均衡**支持良好的: 247 | ### [k2p-openwrt R9.10.1固件](https://www.right.com.cn/forum/thread-1008147-1-1.html),作者是[haoreng](https://www.right.com.cn/forum/space-uid-15139.html) 248 | 249 | **工具 / 步骤 / 参考文献 / 请先阅读:** 250 | 1. [K2P PandoraBox](https://downloads.pangubox.com/pandorabox/19.02/targets/ralink/mt7621/packages/),作者是[Lintel](https://www.right.com.cn/forum/space-uid-37585.html); 251 | * 注:目前已经无法访问,升级文件[有备份](files/firmware/PandoraBox.bin)。 252 | 253 | 1. 上一章节进入Breed后,下载适用的OpenWrt固件,注意鉴别版本,且应为`.bin`文件。 254 | 2. (建议)在左边**`固件备份`**处,备份现有固件 255 | 3. (建议)在左边**`恢复出厂设置`**处,重置Config区 256 | 4. 在左边**`固件更新`**处,**仅点击**`固件`的`选择文件`按钮,选中下载的`.bin`文件,再点击下面的“上传” 257 | 5. 会开始刷机 258 | 6. 进入OpenWrt 259 | ![Pandorabox](images/pandorabox.png) 260 | **特别提醒,有的学校采用IP与MAC绑定的上网方式,如果后续锐捷认证步骤上不了网,可以尝试在路由配置里启用MAC地址克隆,复制电脑网卡地址和IP地址。** 261 | 262 | --- 263 | 264 | # 上传MentoHUST到路由器 265 | 266 | **工具 / 步骤 / 参考文献 / 请先阅读:** 267 | 1. [锐捷、赛尔认证MentoHUST](http://wiki.ubuntu.org.cn/%E9%94%90%E6%8D%B7%E3%80%81%E8%B5%9B%E5%B0%94%E8%AE%A4%E8%AF%81MentoHUST),作者是HustMoon; 268 | 2. (建议)[WinSCP](http://winscp.net),[Windows或Linux下载链接](https://winscp.net/eng/download.php) 269 | 270 | 编译完MentoHUST,安装好OpenWrt之后,我们就可以把它传输到路由器里运行了。喜欢命令行的同学可以使用Telnet或SSH,但这里用有图形界面,较易操作的WinSCP来说明。 271 | 272 | 1 打开WinSCP后,请点击“新增站点”,再填写 "`SCP`" "`192.168.1.1`" "`22`" "`root`" "`<你设定的管理密码>`",再点击`登录`按钮。 273 | ![WinSCP](images/winscp.png) 274 | 275 | 2 进入后,左边定位到你的放置MentoHUST文件的文件夹,右边定位到```/usr/bin/```,然后选中文件,点击“上传” 276 | ![上传](images/upload.png) 277 | 278 | 3 这个时候接上WAN口网线,然后即可运行。进入[路由管理页面](http://192.168.1.1),进入网络-接口,查看你的WAN口地址。推荐使用ssh登录至后台: 279 | ![ssh](images/ssh.png) 280 | 281 | 运行```/usr/bin/mentohust -h```可以获取帮助。 282 | 283 | ``` 284 | >用法: /usr/bin/mentohust [-选项][参数] 285 | 选项: -h 显示本帮助信息 286 | -k -k(退出程序) 其他(重启程序) 287 | -w 保存参数到配置文件 288 | -u 用户名 289 | -p 密码 290 | -n 网卡名 291 | -i IP[默认本机IP] 292 | -m 子网掩码[默认本机掩码] 293 | -g 网关[默认0.0.0.0] 294 | -s DNS[默认0.0.0.0] 295 | -o Ping主机[默认0.0.0.0,表示关闭该功能] 296 | -t 认证超时(秒)[默认8] 297 | -e 心跳间隔(秒)[默认30] 298 | -r 失败等待(秒)[默认15] 299 | -l 允许失败次数[0表示无限制,默认8] 300 | -a 组播地址: 0(标准) 1(锐捷) 2(赛尔) [默认0] 301 | -d DHCP方式: 0(不使用) 1(二次认证) 2(认证后) 3(认证前) [默认0] 302 | -b 是否后台运行: 0(否) 1(是,关闭输出) 2(是,保留输出) 3(是,输出到文件) [默认0] 303 | -v 客户端版本号[默认0.00表示兼容xrgsu] 304 | -f 自定义数据文件[默认不使用] 305 | -c DHCP脚本[默认dhclient] 306 | -q 显示SuConfig.dat的内容(如-q/path/SuConfig.dat) 307 | ``` 308 | 309 | 不是全部参数都需要填,我的配置如下: 310 | 311 | `/usr/bin/mentohust -u<账号,中间不空格> -p<密码> -neth0.2 -e20 -b3` 312 | 313 | 修改为你的配置,再运行,尝试能否上网,如果可以就成功了。 314 | 315 | **特别提醒,如果校园网IPv4不是自动获取IP地址,这里就需要配置固定IP,否则无法上网。** 316 | 317 | 4 为了让路由器断电或重启后还能自动启动认证,我们可以设置其开机启动。 318 | 进入**系统**下的`启动项`,拉到最底的`本地启动脚本`,**在`exit 0`上面**添加你的代码即可。 319 | 320 | ```bash 321 | # mentohust 322 | /usr/bin/mentohust -u<账号,中间不空格> -p<密码> -neth1 -e20 -b3 323 | ``` 324 | 325 | # 路由器IPv6的配置 326 | 327 | ## 更新 328 | 329 | 尽量不要NAT,建议先尝试[配置Relay(中继)模式](./IPv6_Relay.md) 330 | 331 | --- 332 | 333 | **工具 / 步骤 / 参考文献 / 请先阅读:** 334 | 1. [在OpenWrt上配置原生IPv6 NAT](https://tang.su/2017/03/openwrt-ipv6-nat/),作者是[Cod1ng](https://blog.csdn.net/Cod1ng); 335 | 336 | 337 | IPv6因为其**几乎**无尽的地址,本身不需要[网络地址转换 (NAT)](http://zhwp.org/网络地址转换) 。然而,由于校园网IPv6的局限,NAT具有其必要性。下面就尝试讲述一下如何配置。 338 | 339 | 1 进入[路由管理页面](http://192.168.1.1),到**系统**下的`软件包`检查是否有`ip6tables`和`kmod-ipt-nat6`。 340 | 341 | ```bash 342 | opkg update 343 | opkg install ip6tables 344 | opkg install kmod-ipt-nat6 345 | ``` 346 | 347 | 2 打开左侧的**网络**。 348 | 349 | * 进入`接口`, 在`全局网络选项`下,更改`Pv6 ULA 前缀`为`非f开头的任意地址`。 350 | ![IPv6 Prefix](images/ipv6_prefix.png) 351 | 352 | * 修改**LAN**接口:`基本设置`下,`IPv6 分配长度`设为`64` 353 | ![IPv6 Settings](images/ipv6_settings.png) 354 | 355 | 3 进入[路由管理页面](http://192.168.1.1),进入**网络**下的`防火墙`,再进入`自定义规则`选项卡,添加以下内容: 356 | 357 | ```bash 358 | # iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53 359 | # iptables -t nat -A PREROUTING -p tcp --dport 53 -j REDIRECT --to-ports 53 360 | # IPv6 361 | ip6tables -t nat -A POSTROUTING -j MASQUERADE 362 | # ip6tables -t nat -A POSTROUTING -o eth0.2 -j MASQUERADE 363 | # ip6tables -t nat -A POSTROUTING -o eth0.3 -j MASQUERADE 364 | # ip6tables -F 365 | ip6tables -P INPUT ACCEPT 366 | ip6tables -P FORWARD ACCEPT 367 | ip6tables -P OUTPUT ACCEPT 368 | ``` 369 | 370 | 4 手动添加网关。这一步用到了最前面获取的网关。直接在Shell输入下方命令即启动IPv6: 371 | 372 | `route -A inet6 add default gw <你的网关>` 373 | 374 | 但我推荐输到启动项里(`系统` - `启动项` - `本地启动脚本`): 375 | 376 | ```bash 377 | # mentohust 378 | /usr/bin/mentohust -u -p -neth0.2 -e20 -b1 379 | # sleep 2s 380 | # rm /var/run/mentohust.pid 381 | 382 | #ipv6 383 | # 如果获取IPv6地址比较慢 384 | # sleep 300s 385 | route -A inet6 add default gw <网关> 386 | exit 0 387 | ``` 388 | 389 | 重启路由器,大功告成! 390 | 391 | --- 392 | 393 | # EOF 394 | 395 | 希望大家不畏失败,获得成功! 396 | 397 | 对本文参考的各位前辈表达笔者衷心的感谢。 398 | 399 | 我的环境: 400 | >Windows: Windows 10 Pro 1903 401 | > 402 | >Linux: Windows Subsystem for Linux: Ubuntu 18.04 LTS 403 | > 404 | >Router: PhiComm K2P A2 405 | > 406 | >Firmware: OpenWrt / 407 | > 408 | >Libpcap: v1.9.1 409 | > 410 | >锐捷: v4.90 411 | > 412 | >MentoHUST: v0.3. 413 | > 414 | >IPv4: China Unicomm 415 | > 416 | >IPv6: CERNET2 417 | 418 | 资源(慎重使用): 419 | 420 | MentoHUST: 421 | * [15052](files/15052/mentohust_k2p_openwrt_15052) 422 | * [18064](files/18064/mentohust_k2p_openwrt_18064) 423 | -------------------------------------------------------------------------------- /IPv6_Relay.md: -------------------------------------------------------------------------------- 1 | # IPv6 中继模式配置 2 | NAT野蛮,Relay文明,,, 3 | 4 | 前提条件: 5 | * 校园网 IPv6 不限制设备数量 6 | * WAN口获取到后缀 `/64` 的IPv6地址 7 | 8 | --- 9 | 10 | ## 防火墙 11 | **不用配置** 12 | 13 | ## 网关 14 | **同NAT:** 15 | 16 | `route -A inet6 add default gw [Your IPv6 Gateway]` 17 | 18 | ## 网络 19 | ### 接口 20 | 21 | **全局网络选项** - `IPv6 ULA 前缀` 22 | 23 | **不用配置** 24 | ### WAN6 25 | 26 | * 协议 `DHCPv6` 27 | * 请求 IPv6 地址 `try` 28 | * 请求指定长度的 IPv6 前缀 `auto` 29 | * **高级** - 使用内置的 IPv6 管理 **不选中** 30 | * 路由通告服务 `中继模式` 31 | * DHCPv6 服务 `中继模式` 32 | * NDP 代理 `中继模式` 33 | 34 | 如果没有上述选项,则在 `/etc/config/dhcp` 手动加入 35 | 36 | ``` 37 | config dhcp 'wan6' 38 | option interface 'wan6' 39 | option master '1' 40 | option ra 'relay' 41 | option dhcpv6 'relay' 42 | option ndp 'relay' 43 | ``` 44 | 45 | ### LAN 46 | 47 | **一般配置** - 高级设置 48 | * 使用内置的 IPv6 管理 **可选** 49 | 50 | **DHCP 服务器** - IPv6 设置 51 | 52 | * 路由通告服务 `中继模式` 53 | * DHCPv6 服务 `中继模式` 54 | * NDP 代理 `中继模式` 55 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 KumaTea 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Old_version.md: -------------------------------------------------------------------------------- 1 | *前言:这篇教程希望给读者,特别是没有相关IT知识的读者,提供一个尽可能简单易读而详尽的路由器配置指南,且期盼与本文实际情况不相同的读者也可以得到一些启发。整个过程用到了许多前辈的技术成果,在此表达感谢。由于水平有限,可能* ***十分冗长*** *、有不少错误和疏漏,还请各位多多海涵。* 2 | 3 | 在校园网只有有线网络的限制下,满足手机平板等无线设备联网并享受校园网的各种优势应该是很多学生党的刚需。本文就以在SYSU的v4.90版本锐捷认证的校园网下,配置典型的**MT7621**芯片的路由器 (PHICOMM **K2P** A2 4 | ) 的实例,来说明这个过程。其他平台及芯片的读者,也可参考本文的通用方法。 5 | 尽管本文设计为可以按步骤直接从头至尾配置完成,但建议有相似需求的读者,可以先通读一遍教程,再动手。 6 | ![K2P定妆照](https://upload-images.jianshu.io/upload_images/13484287-4abc9f2a0b04eaa0.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 7 | 8 | * * * 9 | # 准备工作 10 | * 一只电脑和一只路由器 11 | * 两坨网线 12 | * 你的IPv6网关(说明见下) 13 | * 有线连接设为“自动获取IP地址” 14 | * **“刷入Breed”**步骤中的**k2p.sh**文件 15 | * (建议)“上传MentoHUST到路由器”步骤的[WinSCP](https://winscp.net/eng/download.php)工具 16 | * (建议)[恩山论坛](http://www.right.com.cn/forum)的账号 17 | * Linux系统,推荐Ubuntu 16.04(说明见“锐捷认证与MentoHUST”章节) 18 | * 一杯茶️ 19 | * 一个下午 20 | 21 | ![路由追踪](http://upload-images.jianshu.io/upload_images/13484287-20f56cc56e8e480c?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 22 | 使用“路由追踪” (Windows: tracert; Linux: traceroute) 命令, 23 | 可以方便的知道你的网关。 24 | 例如,在Windows下,请使用有线上网的方式,追踪一个IPv6地址,例如: 25 | ```cmd 26 | tracert tv.byr.cn 27 | ``` 28 | 然后记录第一条地址(应该以 2xxx: 开头,不应以 fe80: 开头;冒号很重要,要记全)即可。 29 | * * * 30 | # 锐捷认证与MentoHUST 31 | **工具 / 步骤 / 参考文献 / 请先阅读:(排名不分先后)** 32 | **1. [Mentohust V4版本的心得](https://codingstory.com.cn/mo-gai-mentohust-v4ban-ben-de-xin-de/),作者是ShanQincheng;**(原网址已失效,且无WebArchive存档,[这里是无图版本](https://github.com/kkkeQAQ/mentohust_nwafu/blob/master/README.md),谷歌图片可搜到少量缓存低清晰度图片) 33 | **2. [Cross Compile [OpenWrt Wiki]](https://wiki.openwrt.org/doc/devel/crosscompile),作者是OpenWrt官方;** 34 | **3. [交叉编译mentohust实现锐捷认证共享上网](https://blog.csdn.net/warriorpaw/article/details/7990226),作者是[warriorpaw](https://blog.csdn.net/warriorpaw);** 35 | **4. [mentohust v4版本编译及ipv6的配置教程](http://soundrain.net/2016/04/25/mentohust-v4%E7%89%88%E6%9C%AC%E7%BC%96%E8%AF%91%E5%8F%8Aipv6%E7%9A%84%E9%85%8D%E7%BD%AE/),作者请见原页面;** 36 | **5. ivechan的[mentohust的SYSU版本](https://github.com/ivechan/mentohust-SYSU);Placya的[Fork的版本](https://github.com/Placya/mentohust-SYSU)** 37 | **6. [mentohust加入v4支持](https://github.com/hyrathb/mentohust),作者是hyrathb;** 38 | **7. MentoHUST源码、交叉编译工具包、libpcap请见下文详述。** 39 | **MentoHUST**,是由华中科技大学的**HustMoon**(一说liuqun )开发的一款破解锐捷认证的软件。近十年来,MentoHUST经过原作者和众多贡献者的努力,已经逐步发展到可以破解锐捷v2, v3甚至v4认证了。本文中所采用的例子是v4.90版锐捷,也就是v3认证。 40 | ![MentoHUST是大学生的大救星 (](https://upload-images.jianshu.io/upload_images/13484287-2033c8f1bab06a94.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 41 | 42 | MentoHUST一开始开发出来,只是适合于华中科技大学 (HUST),需要再做修改才能适用于实际环境,而这个适配过程是十分痛苦的。笔者是外行,只能尝试大致的说明一下。 43 | 44 | ### 锐捷数据包的分析与MentoHUST的修改 45 | 对于分析与修改的问题,上面提到的[Mentohust V4版本的心得](https://codingstory.com.cn/mo-gai-mentohust-v4ban-ben-de-xin-de/)这篇文章已经写得十分详细和易于操作,我也成功通过该方法分析到了数据,自己水平有限就不造轮子了,大家看一看会很有帮助。 46 | **分析心跳包这一步需要注意间隔,默认间隔是30s,但我校的间隔则是20s,故需要在后续步骤配置,请大家注意。** 47 | 但是在做到一半的时候,偶然看到了Placya的[mentohust的SYSU版本](https://github.com/Placya/mentohust-SYSU),~~服从于人类懒的天性,~~于是就直接拿来用了。 48 | 有了修改好的文件之后,就可以进入下一步了。 49 | 向各位贡献者表达敬意。 50 | ### 交叉编译 51 | 我们知道,编程语言需要翻译为机器语言才能让机器理解并执行。而所谓[交叉编译](enwp.org/Cross_compiler),就是在A机器上为B机器编译软件。 52 | 首先,为了编译MT76XX的可执行文件,我们需要一个Linux系统。为什么推荐Ubuntu呢?因为——Windows 10可以不装虚拟机就运行Ubuntu啊~(当然还有别的,但是Ubuntu比较适合新手) 53 | ![Windows的Linux子系统安装过程](https://upload-images.jianshu.io/upload_images/13484287-bbab43aae9b0adff.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 54 | ![虚拟机是比较稳妥的选择](https://upload-images.jianshu.io/upload_images/13484287-1a542b5b1ee258cf.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 55 | 至于为什么是16.04版,因为笔者在使用18.04编译时一直遭遇不明错误,而使用16.04两次就成功了。 56 | 要注意的是,Linux对大小写**敏感**,所以图方便改文件名的时候要特别小心。 57 | 58 | 1. 确保装好了Linux系统,打开你们头大或喜闻乐见的终端 (Terminal) 59 | 2. 到[OpenWrt的官网](http://downloads.openwrt.org)下载适用于你的路由器的芯片和系统的交叉编译工具包 (SDK),比如我下载的是[这个版本的SDK](http://archive.openwrt.org/chaos_calmer/15.05.1/ramips/mt7621/OpenWrt-SDK-15.05.1-ramips-mt7621_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar.bz2)。可以先改个文件名;解压```.tar.bz2```文件到```/home/xxx```**(xxx是你的用户名)**下: 60 | ``` 61 | tar jxvf SDK.tar.bz2 62 | ``` 63 | 3. 下载libpcap,[戳我下载1.7.4版](http://www.tcpdump.org/release/libpcap-1.7.4.tar.gz),一样解压到```/home/xxx```下,注意命令不同了: 64 | ``` 65 | tar zxvf libpcap-1.7.4.tar.gz 66 | ``` 67 | 4. 把前面做好的MentoHUST的文件夹放到```/home/xxx```下 68 | ![得到这三个文件](https://upload-images.jianshu.io/upload_images/13484287-3986c6870d89afe5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 69 | 5. 配置环境: 70 | **首先把下面代码的“xxx”换成你所创建的账户名,并修改为你自定义的文件夹名,尤其是PATH=$PATH:和STAGING_DIR=这里**,再(建议逐行复制)运行下面的命令: 71 | ``` 72 | sudo -i 73 | ``` 74 | 这一步需要输入密码,来以管理员身份进行下面步骤。**再次提醒要改路径!** 75 | ``` 76 | apt-get install build-essential bison flex zlib1g-dev libncurses5-dev subversion quilt intltool ruby fastjar unzip gawk autogen autopoint 77 | PATH=$PATH:/home/xxx/SDK/staging_dir/toolchain-mipsel_1004kc+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin 78 | export PATH 79 | STAGING_DIR=/home/xxx/SDK/staging_dir/toolchain-mipsel_1004kc+dsp_gcc-4.8-linaro_uClibc-0.9.33.2 80 | export STAGING_DIR 81 | export CC=mipsel-openwrt-linux-gcc 82 | export CPP=mipsel-openwrt-linux-cpp 83 | export GCC=mipsel-openwrt-linux-gcc 84 | export CXX=mipsel-openwrt-linux-g++ 85 | export RANLIB=mipsel-openwrt-linux-uclibc-ranlib 86 | export ac_cv_linux_vers=2.6.24 87 | export LDFLAGS="-static" 88 | export CFLAGS="-Os -s" 89 | ``` 90 | 然后cd进入libpcap文件夹并执行命令,**同样要改路径**: 91 | ``` 92 | cd /home/xxx/libpcap-1.7.4 93 | ./configure --host=mipsel-linux --prefix=/home/xxx/work/ --with-pcap=linux 94 | make 95 | ``` 96 | 这里会滚一段代码,有所了解的同学能看到出错了,但是我们会发现目录里已经生成了我们需要的```libpcap.a```文件,根据黑猫白猫论,这次编译是成功的。 97 | 6. 重头戏——编译MentoHUST: 98 | 首先,要获取一下我们自己所在的平台: 99 | ``` 100 | cd /home/xxx/MentoHUST 101 | sh autogen.sh 102 | ./config.guess 103 | ``` 104 | (说明一下,./config.guess这一步,只在OpenWrt的官方文档中出现,在笔者看到的教程中并未见到。加上去的理由是,不通过这一步一直编译失败,加上应该能规避一些问题) 105 | 这时终端会输出你的平台: 106 | ![平台代码](https://upload-images.jianshu.io/upload_images/13484287-209402681d1ab6a6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 107 | 108 | 例如我的虚拟机是```x86_64-pc-linux-uclibc```,复制一下。然后把复制的内容替换到下面的```<替换>```,再执行: 109 | ``` 110 | ./configure --build=<替换> --host=mipsel-linux --disable-encodepass --disable-notify --with-pcap=/home/xxx/libpcap-1.7.4/libpcap.a 111 | make 112 | ``` 113 | 这个时候,你就可以进入```/home/xxx/MentoHUST/src```,获取你的```MentoHUST```文件了。 114 | ![文件如图,大小仅供参考,我编译的大小都不一样,能用就行](https://upload-images.jianshu.io/upload_images/13484287-ff85f51f18b52018.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 115 | 116 | PC端工作大功告成,喝杯昏睡红茶庆祝一下。 117 | * * * 118 | # 刷入Breed 119 | **工具 / 步骤 / 参考文献 / 请先阅读:(排名不分先后)** 120 | **1. [[k2p] K2/K2P/K3/K3C 新版固件 Telnet 激活工具 121 | ](http://www.right.com.cn/forum/thread-221578-1-1.html),作者是[phitools](http://www.right.com.cn/forum/space-uid-389408.html);** 122 | **2. [[k2p] 【2018-06-19】斐讯K2P MTK官方固件定制版,加adb、S-S R、KMS等【V1.6】](http://www.right.com.cn/forum/thread-221578-1-1.html),作者是[abccba94](http://www.right.com.cn/forum/space-uid-140971.html)。** 123 | * 由于路由器买来之后一般附带的是官方固件,我们需要把它更换为第三方的功能更全的固件,才能进行下一步的操作。 124 | * 刷入固件前,一般需要刷入Breed,可以近似的理解为解锁BootLoader后刷入的Recovery,还是TWRP这一类的。 125 | 126 | 1. 在[[k2p] K2/K2P/K3/K3C 新版固件 Telnet 激活工具 127 | ](http://www.right.com.cn/forum/thread-221578-1-1.html)处确认适用的版本,如适合则下载```RoutAckProV1B2.rar```并解压。 128 | 2. 确保开启Telnet:![Windows下开启Telnet](https://upload-images.jianshu.io/upload_images/13484287-3506cb773ec3e156.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 129 | 130 | 3.仅连接电脑的有线网口与路由器的LAN口,不连接WAN口,然后路由器上电启动。 131 | 4. **打开```RoutAckProV1B2.exe```,当路由器LED灯由红变为黄时,立即点击“打开Telnet”按钮。**等待出现成功信息,若不成功请再试一次。![错误示范](https://upload-images.jianshu.io/upload_images/13484287-7ee789b65a11b83b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 132 | 5. 成功打开Telnet后,连接到你的路由器,可以使用PuTTY等工具连接,也可以用命令提示符: 133 | ```cmd 134 | telnet 192.168.2.1 135 | ``` 136 | 6. 使你在准备步骤中下载的```k2p.sh```文件处于可访问状态。这个时候一般路由器不能上网,怎么解决大家见仁见智,我用的是开启ftp服务器的方式:![用es文件浏览器开启ftp服务器](https://upload-images.jianshu.io/upload_images/13484287-76016a6fc61b62a8.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 137 | 然后执行: 138 | ``` 139 | wget <你的k2p.sh地址> -O - |sh 140 | ``` 141 | 来进行Breed刷写。出现“```upgrade ok! reboot...```”就成功了。 142 | 7. 然后进入Breed: 143 | * 路由断电 144 | * 按住Reset,通电 145 | * 待LED颜色交替闪烁时放开 146 | * 访问[http://192.168.1.1](http://192.168.1.1),若能看到**“Breed Web 恢复控制台”**的蓝色大字标题,即为成功 147 | ![就是这个](https://upload-images.jianshu.io/upload_images/13484287-4aac807b18931b76.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 148 | * * * 149 | # 刷入OpenWrt 150 | **工具 / 步骤 / 参考文献 / 请先阅读:** 151 | **1. [[k2p] [2018-03-06] K2P openwrt chaos_calmer V1.7 正式版发布](http://www.right.com.cn/forum/thread-240730-1-1.html),作者是[mleaf](http://www.right.com.cn/forum/space-uid-284724.html);** 152 | **2. mleaf的适用于K2P的OpenWrt固件1.7.2版(由于下载地址在原帖中为隐藏内容,故这里也不应当提供下载)** 153 | * 一般来说,第三方固件在性能、功耗方面的表现都比原版的好。 154 | * 一般来说,刷入Breed后,就不怕刷砖了。 155 | * 经过笔者多次尝试,Padavan(又称老毛子)固件各方面都较适合家用,而为了支持锐捷和NAT6,则应该选择**OpenWrt**固件。仅供参考。 156 | 157 | 1. 上一章节进入Breed后,下载适用的OpenWrt固件,注意鉴别版本,且应为```.bin```文件。 158 | 2. (建议)在左边**“固件备份”**处,备份现有固件 159 | 3. (建议)在左边**“恢复出厂设置”**处,重置Config区 160 | 4. 在左边**“固件更新”**处,**仅点击**“固件”的“选择文件”按钮,选中下载的```.bin```文件,再点击下面的“上传” 161 | 5. 机器会开始刷机,这个时候可以喝茶了 162 | 163 | 注:进度条飙到150%不要怕,它会自己刷机重启;重启不了也不要怕,过五分钟断电上电就可以;我们可是有Breed的人 /滑稽 164 | 6. 欢迎来到OpenWrt 165 | ![mleaf的K2P的OpenWrt的1.7.2版](https://upload-images.jianshu.io/upload_images/13484287-3a6908d7f4210d49.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 166 | **特别提醒,有的学校采用IP与MAC绑定的上网方式,如果后续锐捷认证步骤上不了网,可以尝试在路由配置里启用MAC地址克隆,复制电脑网卡地址和IP地址。** 167 | * * * 168 | # 上传MentoHUST到路由器 169 | **工具 / 步骤 / 参考文献 / 请先阅读:** 170 | **1. [锐捷、赛尔认证MentoHUST](http://wiki.ubuntu.org.cn/%E9%94%90%E6%8D%B7%E3%80%81%E8%B5%9B%E5%B0%94%E8%AE%A4%E8%AF%81MentoHUST),作者是HustMoon;** 171 | **2. (建议)[WinSCP](http://winscp.net),[Windows或Linux下载链接](https://winscp.net/eng/download.php)** 172 | 173 | 编译完MentoHUST,安装好OpenWrt之后,我们就可以把它传输到路由器里运行了。喜欢命令行的同学可以使用Telnet或SSH,但这里用有图形界面,较易操作的WinSCP来说明。 174 | 1. 打开WinSCP后,请点击“新增站点”,再填写 "```SCP```" "```192.168.2.1```" "```22```" "```root```" "```<你设定的管理密码>```",再点击“登录”按钮。 175 | ![WinSCP](https://upload-images.jianshu.io/upload_images/13484287-ee7ce35e96935f20.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 176 | 2. 进入后,左边定位到你的放置MentoHUST文件的文件夹,右边定位到```/usr/bin/```,然后选中文件,点击“上传” 177 | ![又截一张](https://upload-images.jianshu.io/upload_images/13484287-85ec3c659c52debd.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 178 | 3. 这个时候接上WAN口网线,然后在**WebShell**里就可以运行了。进入[路由管理页面](http://192.168.2.1),WebShell在**“系统”**下。网卡代码(eth)在OpenWrt可以查到。 179 | ![Webshell的位置与MentoHUST运行示例](https://upload-images.jianshu.io/upload_images/13484287-38b54a25db8397b5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 180 | 运行```/usr/bin/mentohust -h```可以获取帮助。 181 | >用法: /usr/bin/mentohust [-选项][参数] 182 | 选项: -h 显示本帮助信息 183 | -k -k(退出程序) 其他(重启程序) 184 | -w 保存参数到配置文件 185 | -u 用户名 186 | -p 密码 187 | -n 网卡名 188 | -i IP[默认本机IP] 189 | -m 子网掩码[默认本机掩码] 190 | -g 网关[默认0.0.0.0] 191 | -s DNS[默认0.0.0.0] 192 | -o Ping主机[默认0.0.0.0,表示关闭该功能] 193 | -t 认证超时(秒)[默认8] 194 | -e 心跳间隔(秒)[默认30] 195 | -r 失败等待(秒)[默认15] 196 | -l 允许失败次数[0表示无限制,默认8] 197 | -a 组播地址: 0(标准) 1(锐捷) 2(赛尔) [默认0] 198 | -d DHCP方式: 0(不使用) 1(二次认证) 2(认证后) 3(认证前) [默认0] 199 | -b 是否后台运行: 0(否) 1(是,关闭输出) 2(是,保留输出) 3(是,输出到文件) [默认0] 200 | -v 客户端版本号[默认0.00表示兼容xrgsu] 201 | -f 自定义数据文件[默认不使用] 202 | -c DHCP脚本[默认dhclient] 203 | -q 显示SuConfig.dat的内容(如-q/path/SuConfig.dat) 204 | 205 | 不是全部参数都需要填,我的配置如下: 206 | ```/usr/bin/mentohust -u<账号,中间不空格> -p<密码> -neth1 -e20 -b3``` 207 | 修改为你的配置,再填入WebShell运行,可能没有输出反馈,但可以尝试能否上网,如果可以就成功了。**特别提醒,如果校园网IPv4不是自动获取IP地址,这里就需要配置固定IP,否则无法上网。** 208 | 4. 为了让路由器断电或重启后还能自动启动认证,我们可以设置其开机启动。 209 | 进入**“系统”**下的“启动项”,拉到最底的“本地启动脚本”,**在```exit 0```上面**添加你的代码即可。 210 | ``` 211 | # mentohust (这是示例) 212 | /usr/bin/mentohust -u<账号,中间不空格> -p<密码> -neth1 -e20 -b3 213 | ``` 214 | # 路由器IPv6的配置 215 | **1. [在OpenWrt上配置原生IPv6 NAT](https://tang.su/2017/03/openwrt-ipv6-nat/),作者是[Cod1ng](https://blog.csdn.net/Cod1ng);** 216 | 217 | >“其实地上本没有路,走的人多了,也便成了路。” ——鲁迅 218 | 219 | IPv6因为其**几乎**无尽的地址,本身不需要[网络地址转换 (NAT)](http://zhwp.org/网络地址转换) 这种东西。然而,由于校园网IPv6的局限和迟缓的发展(历史的行程),大学生们仍然需要IPv6 NAT来满足探索世界的需求(人民的选择)。所幸,OpenWrt是支持NAT6的(Padavan则测试失败了),所以下面就尝试讲述一下如何配置。 220 | 1. 进入[路由管理页面](http://192.168.2.1),到**“系统”**下的“软件包”检查是否有```ip6tables```和```kmod-ipt-nat6```,没有就安装一下。 221 | ``` 222 | opkg update 223 | opkg install ip6tables 224 | opkg install kmod-ipt-nat6 225 | ``` 226 | 2. 使用WinSCP进入```/etc/config/```目录。 227 | * 修改**network**文件:打开```network```文件,找到```config interface 'lan'```这一栏,在下面加入(#号那一行不用): 228 | ``` 229 | # 前面空空的不是空格是Tab键 230 | option ip6addr 'fc00:100:100:1::1/64' 231 | ``` 232 | 这是确定了分配的IPv6地址范围。 233 | ![示例](https://upload-images.jianshu.io/upload_images/13484287-34f9c7ae12f1d4d0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 234 | 235 | * 修改**dhcp**文件:打开```dhcp```文件,找到```config dhcp 'lan'```这一栏,比对下面的代码,有缺失的、不同的就请加上: 236 | ``` 237 | # 前面空空的不是空格是Tab键 238 | option interface 'lan' 239 | option start '100' 240 | option limit '100' 241 | option leasetime '12h' 242 | option dhcpv6 'server' 243 | option ra 'server' 244 | option ra_management '1' 245 | option ra_default '1' 246 | ``` 247 | 3. 进入[路由管理页面](http://192.168.2.1),进入**“网络”**下的“防火墙”,再进入“自定义规则”选项卡,添加这些内容(#号那一行不用): 248 | ``` 249 | # 让IPv6顺利通过路由器防火墙 250 | ip6tables -t nat -A POSTROUTING -o eth1 -j MASQUERADE 251 | ip6tables -F 252 | ip6tables -P INPUT ACCEPT 253 | ip6tables -P FORWARD ACCEPT 254 | ip6tables -P OUTPUT ACCEPT 255 | ``` 256 | 4. 手动添加网关。这一步用到了最前面获取的网关。直接在WebShell输入下方命令即可上IPv6了,但我推荐输到启动项里(#号那一行不用): 257 | ``` 258 | # ipv6 259 | sleep 30s 260 | route -A inet6 add default gw <你的网关> 261 | ``` 262 | ```sleep```就是等待,作用是适配一些获取IPv6地址比较慢的校园网(SYSU就是这种情况,故加上) 263 | ![启动项全家福](https://upload-images.jianshu.io/upload_images/13484287-fccddfc6222029cd.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 264 | 265 | 重启路由器,大功告成! 266 | * * * 267 | # EOF 268 | 希望大家不要经历太多失败吧_(:з」∠) _ 269 | 对本文参考的各位前辈表达笔者衷心的感谢。 270 | 271 | 我的环境: 272 | >OS: Windows 10 Pro 1803 273 | >VM: Ubuntu 16.04 LTS 274 | >Router: PhiComm K2P A2 (Silver) 275 | >Firmware: OpenWrt Chaos Calmer 15.05.1 276 | >Libpcap: v1.7.4 277 | >锐捷: v4.90 278 | >MentoHUST: v0.3.1 279 | >IPv4: China Unicomm 280 | >IPv6: CERNET2 / Native 281 | 282 | 资源(只有跟我锐捷和路由芯片相同的才能拿去哦,否则请慎重使用): 283 | MentoHUST:[百度网盘](https://pan.baidu.com/s/1UO8HX4x3k4iIJuv40ENV_Q) 284 | 285 | 2018年8月10日第一版 286 | 2018年12月21日小修改 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MentoHUST-SYSU-Guide 2 | 3 | ### 2021年更新 4 | 5 | `mentohust` 已有十余年历史,部分功能可能已经不可用于当前系统。 6 | 7 | 例如,OpenWrt 更新到较新版本后,`mentohust` 出现了[每隔数分钟掉线一次](images/disconnected.jpg)的异常情况,是否为普遍现象未明。 8 | 9 | 因此,强烈建议换用 [**minieap**](https://github.com/KumaTea/minieap) 10 | (Forked from [updateing/minieap](https://github.com/updateing/minieap), 11 | [OpenWrt package](https://github.com/KumaTea/openwrt-minieap), 12 | [OpenWrt index](https://github.com/KumaTea/openwrt-packages)) 。 13 | 14 | 移植方式没有太多改变,十分简单,然而性能及稳定性大幅提升。 15 | 16 | ## [支持锐捷认证与IPv6的路由器配置指南:以K2P为例](./Guide.md) 17 | 这是主教程内容 18 | 19 | ## 其他 / Others 20 | 这是附加内容 21 | 22 | * [MentoHUST-SYSU-OpenWrt 软件包](https://github.com/KumaTea/MentoHUST-SYSU-OpenWrt) 23 | * [IPv6 中继模式配置(优于原NAT模式)](IPv6_Relay.md) 24 | * [空间太小放不下mentohust二进制怎么办](./Compress_bin.md) 25 | * [参考配置](./config) 26 | 27 | ## Changelog 28 | * 2018年08月10日 第一版 29 | * 2018年12月21日 小修改 30 | * 2019年10月22日 第二版 31 | * 2019年12月02日 小修改 32 | * 2020年01月06日 增加内容 33 | * 2020年05月11日 添加链接 34 | * 2021年04月05日 Deprecation Warning 35 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-slate -------------------------------------------------------------------------------- /compile.sh: -------------------------------------------------------------------------------- 1 | sudo -i 2 | apt install build-essential bison flex zlib1g-dev libncurses5-dev subversion quilt intltool ruby fastjar unzip gawk autogen autopoint ccache gettext libssl-dev xsltproc zip git 3 | 4 | cd /home/kumatea 5 | mkdir k2p 6 | cd k2p 7 | 8 | wget http://downloads.openwrt.org/releases/18.06.4/targets/ramips/mt7621/openwrt-sdk-18.06.4-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64.tar.xz -O sdk.tar.xz 9 | tar -xJf sdk.tar.xz 10 | mv openwrt-sdk-18.06.4-ramips-mt7621_gcc-7.3.0_musl.Linux-x86_64 sdk 11 | rm sdk.tar.xz 12 | 13 | wget https://www.tcpdump.org/release/libpcap-1.9.1.tar.gz -O libpcap.tar.gz 14 | tar -xzf libpcap.tar.gz 15 | mv libpcap-1.9.1 libpcap 16 | rm libpcap.tar.gz 17 | 18 | PATH=$PATH:/home/kumatea/k2p/sdk/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/bin 19 | export PATH 20 | STAGING_DIR=/home/kumatea/k2p/sdk/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl 21 | export STAGING_DIR 22 | export CC=mipsel-openwrt-linux-gcc 23 | export CPP=mipsel-openwrt-linux-cpp 24 | export GCC=mipsel-openwrt-linux-gcc 25 | export CXX=mipsel-openwrt-linux-g++ 26 | export RANLIB=mipsel-openwrt-linux-musl-ranlib 27 | export ac_cv_linux_vers=2.6.24 28 | export LDFLAGS="-static" 29 | export CFLAGS="-Os -s" 30 | 31 | cd /home/kumatea/k2p/libpcap 32 | ./configure --host=mipsel-linux --prefix=/home/kumatea/k2p/ --with-pcap=linux 33 | make 34 | 35 | cd /home/kumatea/k2p/mentohust 36 | sh autogen.sh 37 | ./config.guess 38 | 39 | ./configure --build=x86_64-pc-linux-gnu --host=mipsel-linux --disable-encodepass --disable-notify --with-pcap=/home/kumatea/k2p/libpcap/libpcap.a 40 | make 41 | 42 | md5sum /home/kumatea/k2p/mentohust/src/mentohust 43 | -------------------------------------------------------------------------------- /config/config/dhcp: -------------------------------------------------------------------------------- 1 | 2 | config dnsmasq 3 | option domainneeded '1' 4 | option localise_queries '1' 5 | option rebind_protection '1' 6 | option rebind_localhost '1' 7 | option local '/lan/' 8 | option domain 'lan' 9 | option expandhosts '1' 10 | option authoritative '1' 11 | option readethers '1' 12 | option leasefile '/tmp/dhcp.leases' 13 | option resolvfile '/tmp/resolv.conf.auto' 14 | option nonwildcard '1' 15 | option localservice '1' 16 | option noresolv '0' 17 | list server '127.0.0.1#5333' 18 | 19 | config dhcp 'lan' 20 | option interface 'lan' 21 | option start '100' 22 | option leasetime '12h' 23 | option limit '100' 24 | option ra 'relay' 25 | option dhcpv6 'relay' 26 | option ndp 'relay' 27 | 28 | config dhcp 'wan' 29 | option interface 'wan' 30 | option ignore '1' 31 | 32 | config dhcp 'wan6' 33 | option interface 'wan' 34 | option ra 'relay' 35 | option dhcpv6 'relay' 36 | option ndp 'relay' 37 | option master '1' 38 | 39 | config odhcpd 'odhcpd' 40 | option maindhcp '0' 41 | option leasefile '/tmp/hosts/odhcpd' 42 | option leasetrigger '/usr/sbin/odhcpd-update' 43 | option loglevel '4' 44 | 45 | config srvhost 46 | -------------------------------------------------------------------------------- /config/config/network: -------------------------------------------------------------------------------- 1 | 2 | config interface 'loopback' 3 | option ifname 'lo' 4 | option proto 'static' 5 | option ipaddr '127.0.0.1' 6 | option netmask '255.0.0.0' 7 | 8 | config globals 'globals' 9 | 10 | config interface 'lan' 11 | option type 'bridge' 12 | option proto 'static' 13 | option netmask '255.255.255.0' 14 | option ipaddr '192.168.2.1' 15 | option ip6assign '64' 16 | option _orig_ifname 'apcli0 apclix0 eth0.1 ra0 rax0' 17 | option _orig_bridge 'true' 18 | option ifname 'apclix0 eth0.1 rax0' 19 | 20 | config device 'lan_dev' 21 | option name 'eth0.1' 22 | option macaddr '[REDACTED]' 23 | 24 | config interface 'wan' 25 | option ifname 'eth0.2' 26 | option proto 'dhcp' 27 | option delegate '0' 28 | 29 | config device 'wan_dev' 30 | option name 'eth0.2' 31 | option macaddr '[REDACTED]' 32 | 33 | config interface 'wan6' 34 | option ifname 'eth0.2' 35 | option proto 'dhcpv6' 36 | option reqaddress 'try' 37 | option reqprefix 'auto' 38 | option delegate '0' 39 | 40 | config switch 41 | option name 'switch0' 42 | option reset '1' 43 | option enable_vlan '1' 44 | 45 | config switch_vlan 46 | option device 'switch0' 47 | option vlan '1' 48 | option vid '1' 49 | option ports '0 1 2 3 6t' 50 | 51 | config switch_vlan 52 | option device 'switch0' 53 | option vlan '2' 54 | option vid '2' 55 | option ports '4 6t' 56 | -------------------------------------------------------------------------------- /config/index.html: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /config/rc.local: -------------------------------------------------------------------------------- 1 | # Put your custom commands here that should be executed once 2 | # the system init finished. By default this file does nothing. 3 | 4 | # mentohust 5 | /usr/bin/mentohust [REDACTED] 6 | 7 | # mt wifi 8 | ifconfig rax0 up 9 | ifconfig ra0 up 10 | ifconfig apclix0 up 11 | ifconfig apcli0 up 12 | 13 | # ipv6 14 | # old method 15 | # sleep 300s 16 | # new method 17 | while ! ip a | grep 2001 18 | do 19 | sleep 10s 20 | done 21 | route -A inet6 add default gw [REDACTED] 22 | 23 | exit 0 24 | -------------------------------------------------------------------------------- /files/README.md: -------------------------------------------------------------------------------- 1 | All files here have been moved to 2 | [release](https://github.com/KumaTea/MentoHUST-SYSU-Guide/releases/tag/R9.11.23) 3 | to avoid _using GitHub Pages to distribute binary files_ warning. 4 | -------------------------------------------------------------------------------- /images/breed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KumaTea/MentoHUST-SYSU-Guide/9b3cbf3f355d1f8c666bb4dee45f9ead341dd951/images/breed.png -------------------------------------------------------------------------------- /images/compiled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KumaTea/MentoHUST-SYSU-Guide/9b3cbf3f355d1f8c666bb4dee45f9ead341dd951/images/compiled.png -------------------------------------------------------------------------------- /images/dir.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KumaTea/MentoHUST-SYSU-Guide/9b3cbf3f355d1f8c666bb4dee45f9ead341dd951/images/dir.png -------------------------------------------------------------------------------- /images/disconnected.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KumaTea/MentoHUST-SYSU-Guide/9b3cbf3f355d1f8c666bb4dee45f9ead341dd951/images/disconnected.jpg -------------------------------------------------------------------------------- /images/ftp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KumaTea/MentoHUST-SYSU-Guide/9b3cbf3f355d1f8c666bb4dee45f9ead341dd951/images/ftp.jpg -------------------------------------------------------------------------------- /images/ipv6_prefix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KumaTea/MentoHUST-SYSU-Guide/9b3cbf3f355d1f8c666bb4dee45f9ead341dd951/images/ipv6_prefix.png -------------------------------------------------------------------------------- /images/ipv6_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KumaTea/MentoHUST-SYSU-Guide/9b3cbf3f355d1f8c666bb4dee45f9ead341dd951/images/ipv6_settings.png -------------------------------------------------------------------------------- /images/k2p.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KumaTea/MentoHUST-SYSU-Guide/9b3cbf3f355d1f8c666bb4dee45f9ead341dd951/images/k2p.jpg -------------------------------------------------------------------------------- /images/no_response.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KumaTea/MentoHUST-SYSU-Guide/9b3cbf3f355d1f8c666bb4dee45f9ead341dd951/images/no_response.png -------------------------------------------------------------------------------- /images/openwrt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KumaTea/MentoHUST-SYSU-Guide/9b3cbf3f355d1f8c666bb4dee45f9ead341dd951/images/openwrt.png -------------------------------------------------------------------------------- /images/pandorabox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KumaTea/MentoHUST-SYSU-Guide/9b3cbf3f355d1f8c666bb4dee45f9ead341dd951/images/pandorabox.png -------------------------------------------------------------------------------- /images/platform.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KumaTea/MentoHUST-SYSU-Guide/9b3cbf3f355d1f8c666bb4dee45f9ead341dd951/images/platform.png -------------------------------------------------------------------------------- /images/ssh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KumaTea/MentoHUST-SYSU-Guide/9b3cbf3f355d1f8c666bb4dee45f9ead341dd951/images/ssh.png -------------------------------------------------------------------------------- /images/telnet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KumaTea/MentoHUST-SYSU-Guide/9b3cbf3f355d1f8c666bb4dee45f9ead341dd951/images/telnet.png -------------------------------------------------------------------------------- /images/tracert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KumaTea/MentoHUST-SYSU-Guide/9b3cbf3f355d1f8c666bb4dee45f9ead341dd951/images/tracert.png -------------------------------------------------------------------------------- /images/upload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KumaTea/MentoHUST-SYSU-Guide/9b3cbf3f355d1f8c666bb4dee45f9ead341dd951/images/upload.png -------------------------------------------------------------------------------- /images/winscp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KumaTea/MentoHUST-SYSU-Guide/9b3cbf3f355d1f8c666bb4dee45f9ead341dd951/images/winscp.png -------------------------------------------------------------------------------- /images/wsl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KumaTea/MentoHUST-SYSU-Guide/9b3cbf3f355d1f8c666bb4dee45f9ead341dd951/images/wsl.png -------------------------------------------------------------------------------- /images/xenial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KumaTea/MentoHUST-SYSU-Guide/9b3cbf3f355d1f8c666bb4dee45f9ead341dd951/images/xenial.png --------------------------------------------------------------------------------