添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

2. 未解决问题

  1. go 1.13+ 运行 Illegal instruction 问题: 需要开启FPU (Emulator) https://github.com/v2ray/v2ray-core/issues/843

  2. merlin 固件从 380.68 (18-Aug-2017) 就内置了 TPROXY 模块,但是需要手动加载。但是在使用 TPROXY 转发 UDP 流量,或者使用 V2Ray TPROXY 转发是,会出现 udp 转发死循环问题,暂时还没解决。参考:

  3. https://github.com/v2ray/v2ray-core/issues/1432

  4. https://github.com/v2ray/v2ray-core/issues/1671

  5. https://guide.v2fly.org/app/transparent_proxy.html

  6. https://guide.v2fly.org/app/tproxy.html#%E8%AE%BE%E7%BD%AE%E7%BD%91%E5%85%B3

    2.1. 相关下载地址

    2.1.1. V2Ray

    v2ray-core 下载地址:
    https://github.com/v2ray/v2ray-core/releases

    注意选择对应版本,RT-AC68U 的版本是 v2ray-linux-arm.zip,下载后,上传到路由器。

    2.1.2. RT-AC68U 固件

    固件的内核有两个版本,384.xx(新的版本) 和 380.xx(老得版本) 两个版本,注意选择。

    固件有三个版本: 华硕官方,原版 merlin 固件,还有安装软件市场的国内修改 koolshare 版本。

  7. 原版 merlin 下载地址: https://www.asuswrt-merlin.net/download
  8. koolshare 的下载地址: http://firmware.koolshare.cn/
  9. 注意: 梅林原版古剑,不带有 Software Center, 如果需要下载带有 Software Center 的固件版本,参考: https://github.com/koolshare/rogsoft

    arm380软件中心 arm384软件中心 hnd/axhnd软件中心 软路由-酷软 koolshare.github.io armsoft rogsoft ledesoft armv7l armv7l armv8(aarch64) hnd/axhnd by fw867 linux内核 2.6.36.4 2.6.36.4 4.1.27/4.1.51 bcm4708/9 bcm4708/9 bcm4906/8 intel/AMD koolshare 梅林380 koolshare 梅林384 koolshare 梅林/官改 OpenWRT/LEDE 软件中心api 1.0 代 1.5 代 1.5 代 1.5 代 代表机型-1 RT-AC68U 改版梅林380 RT-AC88U 改版梅林384 RT-AC86U 改版梅林 代表机型-2 RT-AC88U 改版梅林380 RT-AC5300 改版梅林384 GT-AC5300 华硕官改 代表机型-3 R7000 改版梅林380 RT-AX88U 改版梅林

    我的 AC68U 有两个版本,旧版的是 Koolshare_Merlin_Legacy_380(380.xx),新版的是 Koolshare_Merlin_New_Gen_384(384.xx),我选择下载的是 : https://koolshare.cn/thread-164857-1-1.html

    3. 安装步骤

    3.1. 安装V2Ray

    将 v2ray-linux-arm.zip 压缩包上传到 路由器,然后解压到一个目录,配置 config.json 文件,使用 ./v2ray -config config.json 命令即可启动。

    如果出现内存不够的错误,增加 swap 内存即可 :

    1
    2
    3
    4
    5
    6
    7
    8
    # 创建要作为swap分区的文件:增加1GB大小的交换分区,则命令写法如下,其中的count等于想要的块的数量(bs*count=文件大小)。
    dd if=/dev/zero of=/tmp/mnt/nas/swapfile bs=1M count=1024
    # 格式化为交换分区文件:
    mkswap /tmp/mnt/nas/swapfile #建立swap的文件系统
    # 启用交换分区文件:
    swapon /tmp/mnt/nas/swapfile #启用swap文件
    # 查看
    free

    配置 config.json 文件,参考: V2Ray 透明代理

    配置好了,启动:

    1
    2
    3
    4
    chmod +x v2ray
    chmod +x v2ctl
    ulimit -n 65536
    ./v2ray -config config.json

    3.2. 配置 iptables

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    #!/bin/bash

    # 新建一个名为 V2RAY 的链
    iptables -t nat -N V2RAY
    # 直连 SO_MARK 为 0xff 的流量(0xff 是 16 进制数,数值上等同与上面配置的 255),此规则目的是避免代理本机(网关)流量出现回环问题
    iptables -t nat -A V2RAY -p tcp -j RETURN -m mark --mark 0xff
    # 允许连接保留地址
    # 直连 192.168.0.0/16
    iptables -t nat -A V2RAY -d 0.0.0.0/8 -j RETURN
    iptables -t nat -A V2RAY -d 10.0.0.0/8 -j RETURN
    iptables -t nat -A V2RAY -d 127.0.0.0/8 -j RETURN
    iptables -t nat -A V2RAY -d 169.254.0.0/16 -j RETURN
    iptables -t nat -A V2RAY -d 172.16.0.0/12 -j RETURN
    iptables -t nat -A V2RAY -d 192.168.0.0/16 -j RETURN
    iptables -t nat -A V2RAY -d 224.0.0.0/4 -j RETURN
    iptables -t nat -A V2RAY -d 240.0.0.0/4 -j RETURN

    # 其余流量转发到 12345 端口(即 V2Ray)
    iptables -t nat -A V2RAY -p tcp -j REDIRECT --to-ports 12345
    # 对局域网其他设备进行透明代理
    iptables -t nat -A PREROUTING -p tcp -j V2RAY
    # 对本机进行透明代理
    iptables -t nat -A OUTPUT -p tcp -j V2RAY

    写入到一个脚本文件,然后执行脚本即可。

    4. 开机自启动和定时监测

    4.1. 创建定时监测脚本

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    cat << EOF > /tmp/mnt/nas/v2ray/koolshare-v2ray-restart.sh 
    #!/bin/sh
    v2ray_dir=/tmp/mnt/nas/v2ray
    cd ${v2ray_dir}
    ps | grep -i 'v2ray'| grep -i 'config.json' | grep -v 'grep' | awk '{print $1}' | xargs kill -9
    ulimit -n 65536
    nohup ${v2ray_dir}/v2ray -config ${v2ray_dir}/config.json &
    echo "time: $(date +%Y-%m-%d) $(date +%H:%M:%S)" >> ${v2ray_dir}/log/monitor.log

    sh /tmp/mnt/nas/v2ray/router-iptables.sh

    EOF

    4.2. 添加开机自启动

    修改 /jffs/scripts/services-start

    1
    2
    3
    4
    5
    6
    cat << EOF >> /jffs/scripts/services-start

    sh /tmp/mnt/nas/v2ray/koolshare-v2ray-restart.sh
    cru a ScheduledReboot "*/2 * * * * /tmp/mnt/nas/v2ray/koolshare-v2ray.sh"

    EOF