二、OpenWRT简介
OpenWRT(曾用名 LEDE)是一款广泛应用于路由器的嵌入式操作系统。本站提供 OpenWRT 的包管理器 opkg的镜像,以加快国内访问速度。
三、使用VM虚拟机安装OpenWRT操作步骤
1、下载OpenWRT.img镜像源
下载地址:https://mirrors.aliyun.com/openwrt
2、将.img镜像文件转换成.vmdk虚拟硬盘格式文件
所需工具为:StarWind V2V Image Converter
(1)打开StarWind V2V Image Converter
(2)选择将要转换的镜像文件存储的位置
(选择Local file)本地文件夹
(3)选择源镜像文件
(4)选择转换格式
(5)选择磁盘格式
(6)确认信息,开始转换
(7)转换完成
3、使用VM虚拟机创建OpenWRT
部分关键截图如下图所示
① 选择的客户机操作系统如下图所示
② 使用NAT地址转换模式
③ 选择磁盘,为刚刚转换过后的.vmdk磁盘格式文件
④ 创建完成,点击“开启此虚拟机”
⑤ 登录成功
4、修改网络参数信息并SSH连接
root@OpenWrt:~# vi /etc/config/network root@OpenWrt:~# cat /etc/config/network config interface 'loopback' option device 'lo' option proto 'static' option ipaddr '127.0.0.1' option netmask '255.0.0.0' config globals 'globals' option ula_prefix 'fd33:8f52:e9fd::/48' config device option name 'br-lan' option type 'bridge' list ports 'eth0' config interface 'lan' option device 'br-lan' option proto 'static' option ipaddr '192.168.200.50' option netmask '255.255.255.0' option ip6assign '60' root@OpenWrt:~# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br-lan state UP qlen 1000 link/ether 00:0c:29:b4:2f:04 brd ff:ff:ff:ff:ff:ff 5: br-lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000 link/ether 00:0c:29:b4:2f:04 brd ff:ff:ff:ff:ff:ff inet 192.168.200.50/24 brd 192.168.200.255 scope global br-lan valid_lft forever preferred_lft forever inet6 fd33:8f52:e9fd::1/60 scope global noprefixroute valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:feb4:2f04/64 scope link valid_lft forever preferred_lft forever root@OpenWrt:~# _________________________________________________________________ C:\Users\xybdiy>ssh root@192.168.200.50 The authenticity of host '192.168.200.50 (192.168.200.50)' can't be established. ED25519 key fingerprint is SHA256:uINCvTddAyG9bGGRCD/5R2b7DSmUoxLDcyNe4Pcr9OA. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '192.168.200.50' (ED25519) to the list of known hosts. BusyBox v1.33.1 (2021-10-24 09:01:35 UTC) built-in shell (ash) _______ ________ __ | |.-----.-----.-----.| | | |.----.| |_ | - || _ | -__| || | | || _|| _| |_______|| __|_____|__|__||________||__| |____| |__| W I R E L E S S F R E E D O M ----------------------------------------------------- OpenWrt 21.02.1, r16325-88151b8303 ----------------------------------------------------- === WARNING! ===================================== There is no root password defined on this device! Use the "passwd" command to set up a new password in order to prevent unauthorized SSH logins. -------------------------------------------------- root@OpenWrt:~#
5、访问OpenWRT的WEB界面,输入配置的IP地址即可
四、更换阿里OpenWRT镜像源
手工替换
登录到路由器,并编辑 /etc/opkg/distfeeds.conf文件,
将其中的downloads.openwrt.org 替换为 **mirrors.aliyun.com/openwrt`**即可。
快捷替换
执行如下命令自动替换
sed -i 's_downloads.openwrt.org_mirrors.aliyun.com/openwrt_' /etc/opkg/distfeeds.conf
操作过程如下:
root@OpenWrt:~# cat /etc/opkg/distfeeds.conf src/gz openwrt_core https://downloads.openwrt.org/releases/21.02.1/targets/x86/64/packages src/gz openwrt_base https://downloads.openwrt.org/releases/21.02.1/packages/x86_64/base src/gz openwrt_luci https://downloads.openwrt.org/releases/21.02.1/packages/x86_64/luci src/gz openwrt_packages https://downloads.openwrt.org/releases/21.02.1/packages/x86_64/packages src/gz openwrt_routing https://downloads.openwrt.org/releases/21.02.1/packages/x86_64/routing src/gz openwrt_telephony https://downloads.openwrt.org/releases/21.02.1/packages/x86_64/telephony root@OpenWrt:~# sed -i 's_downloads.openwrt.org_mirrors.aliyun.com/openwrt_' /etc/opkg/distfeeds.conf root@OpenWrt:~# cat /etc/opkg/distfeeds.conf src/gz openwrt_core https://mirrors.aliyun.com/openwrt/releases/21.02.1/targets/x86/64/packages src/gz openwrt_base https://mirrors.aliyun.com/openwrt/releases/21.02.1/packages/x86_64/base src/gz openwrt_luci https://mirrors.aliyun.com/openwrt/releases/21.02.1/packages/x86_64/luci src/gz openwrt_packages https://mirrors.aliyun.com/openwrt/releases/21.02.1/packages/x86_64/packages src/gz openwrt_routing https://mirrors.aliyun.com/openwrt/releases/21.02.1/packages/x86_64/routing src/gz openwrt_telephony https://mirrors.aliyun.com/openwrt/releases/21.02.1/packages/x86_64/telephony root@OpenWrt:~#
五、问题反馈
暂未解决使用VM虚拟机创建的OpenWRT系统,使其能够访问外网,已经尝试多种方法,依旧不行。问题留存,待解决。
root@OpenWrt:~# ping qq.com ping: bad address 'qq.com' root@OpenWrt:~#