安装官方版 LEDE 到 virtualbox

  1. 1. 安装官方版 LEDE 到 virtualbox
    1. 1.1. 安装
    2. 1.2. 配置/常用命令
    3. 1.3. SS

安装官方版 LEDE 到 virtualbox

已放弃 Deprecated,已放弃 Deprecated,已放弃 Deprecated, 已改回我最老的 r8000 merlin 性能虽然差,但免折腾

不知为何我在虚拟机中的 koolshare 版本 lede 有奇怪的问题, 例如当开启 v2ray 时, 每隔 8 小时(怀疑与 DHCP 有关) v2ray 必然短链, 且重启插件无效, 日志中都是疯狂的自动重启, 必须要重启系统(koolshare 版 lede)才可以重新连接上 v2ray, 或者是使用 PC Chrome 登陆不上去 Web 配置界面, 必须开启隐私浏览才能登陆或者换其他浏览器(应该是 Chrome 的锅, 但也不爽), 所以有了安装官方版 LEDE 到 virtualbox 的想法, 这肯定是个大坑.

安装

首先给出官方文档, 我说的不理解的可以去看看.

  1. 下载官方镜像

    选择最新的 combined-ext4.img.gz 下载

    1
    2
    3
    4
    cd /tmp
    wget https://downloads.openwrt.org/snapshots/targets/x86/64/openwrt-x86-64-combined-ext4.img.gz
    # 解压
    atool -x openwrt-x86-64-combined-ext4.img.gz
  2. 转换为 virtualbox 的硬盘 vdi 格式

    1
    2
    3
    4
    5
    6
    7
    8
    # 转换
    VBoxManage convertfromraw --format VDI openwrt-x86-64-combined-ext4.img openwrt-x86-64-combined-ext4.vdi
    # Converting from raw image file="openwrt-x86-64-combined-ext4.img" to file="openwrt-x86-64-combined-ext4.vdi"...
    # Creating dynamic image with size 285736960 bytes (273MB)...
    # 成功

    # 如果需要的话,可以修改大小,例如下面的命令是修改大小为 128MB
    VboxManage modifymedium openwrt-x86-64-combined-ext4.vdi --resize 128
  3. 创建虚拟机

    1. 起个名字,我的叫 ledeOfficial

    2. 选择类型为 Linux

    3. 版本选择为 Linux 2.6 / 3.x / 4.x (64-bit)

    4. 设置内存,我设置为 2048MB, 官方说 128MB 就足够了

    5. 选择硬盘,使用现有的虚拟磁盘, 找到刚解压出来的 vdi 文件

  4. 设置虚拟机

    1. 设置网卡 1, 选择使用桥接网卡(Bridged Adapter), 选择本机网卡(提供网络)

    2. 设置网卡 2, 与上述一样(提供 DHCP 一类)

    3. [可选]设置 CPU,越多越好

    4. [可选]设置启动顺序,最好把 软盘,光盘都取消了

  5. 启动虚拟机

配置/常用命令

  1. 设置网卡

    1
    vi /etc/config/network

    我这里支持 IPV6, 如果你那边不支持,记得删掉 v6 的内容

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    config interface 'loopback'
    option ifname 'lo'
    option proto 'static'
    option ipaddr '127.0.0.1'
    option netmask '255.0.0.0'

    config globals 'globals'
    option ula_prefix 'fdba:e06d:7c2c::/48'

    config interface 'wan'
    option ifname 'eth0'
    option proto 'static'
    option ipaddr '192.168.1.20'
    option netmask '255.255.255.0'
    option gateway '192.168.1.1'
    option broadcast '192.168.1.255'
    option ip6assign '64'
    option dns '2001:dc7:1000::1 114.114.114.114 2001:4860:4860::8888 8.8.8.8'
  2. 更新软件源

    1
    opkg update
  3. 替换软件源为 https

    1
    2
    3
    4
    5
    6
    # 让 openwrt 支持 ssl
    opkg install wget ca-certificates libustream-openssl
    # 替换
    sed -i 's/http/https/g' /etc/opkg/distfeeds.conf
    # 更新软件源
    opkg update

    或者替换源为国内镜像

    1
    sed -i 's_downloads\.lede-project\.org_mirrors.ustc.edu.cn/lede_' /etc/opkg/distfeeds.conf
  4. 安装 ssh server 官方文档

  5. 安装 luci (界面) 官方文档

    1
    2
    3
    4
    # 安装原版
    opkg update && opkg install luci-ssl-openssl libuhttpd-openssl
    # 安装中文汉化
    opkg install luci-i18n-base-zh-cn

SS

  1. 添加源

    1
    2
    3
    4
    5
    6
    cd /tmp
    wget http://openwrt-dist.sourceforge.net/packages/openwrt-dist.pub
    mount -o remount,rw /
    opkg-key add openwrt-dist.pub
    echo 'src/gz openwrt_dist http://openwrt-dist.sourceforge.net/packages/base/x86_64' >> /etc/opkg/customfeeds.conf
    echo 'src/gz openwrt_dist_luci http://openwrt-dist.sourceforge.net/packages/luci' >> /etc/opkg/customfeeds.conf
  2. 安装软件包

    1
    2
    3
    4
    5
    6
    # ss,shadowsocks-libev 核心,luci-app-shadowsocks 界面,iptables-mod-tproxy 透明代理
    opkg install shadowsocks-libev luci-app-shadowsocks iptables-mod-tproxy
    # DNS 优化
    # ChinaDNS:解决DNS污染问题,优化DNS解析以提升访问速度
    # DNS-Forwarder:将 UDP协议的DNS 查询转换为 TCP 协议,避免某些ISP不稳定的UDP查询
    opkg install ChinaDNS luci-app-chinadns dns-forwarder luci-app-dns-forwarder