ASCII码 ASCII码

【阿里云镜像】使用VM虚拟机安装OpenWRT并更换阿里云镜像源

发布于:2021-12-20 10:50:43  栏目:技术文档

一、参考链接

阿里巴巴开源镜像站-OPSX镜像站-阿里云开发者社区 (aliyun.com)

openwrt镜像-openwrt下载地址-openwrt安装教程-阿里巴巴开源镜像站 (aliyun.com)

VMware安装OpenWrt让宿主机上网&旁路由(两种方案)_Algorithm的博客-CSDN博客_vmware 旁路由

VM虚拟机搭建openwrt系统环境配置和使用_weixin_41782780的博客-CSDN博客_openwrt vm

二、OpenWRT简介

OpenWRT(曾用名 LEDE)是一款广泛应用于路由器的嵌入式操作系统。本站提供 OpenWRT 的包管理器 opkg的镜像,以加快国内访问速度。

三、使用VM虚拟机安装OpenWRT操作步骤

1、下载OpenWRT.img镜像源

下载地址:https://mirrors.aliyun.com/openwrt

image-20211219145914763

2、将.img镜像文件转换成.vmdk虚拟硬盘格式文件

所需工具为:StarWind V2V Image Converter

(1)打开StarWind V2V Image Converter

image-20211219150359357

(2)选择将要转换的镜像文件存储的位置

(选择Local file)本地文件夹

image-20211219150534801

(3)选择源镜像文件

image-20211219150618775

(4)选择转换格式

image-20211219150654650

(5)选择磁盘格式

image-20211219150718266

(6)确认信息,开始转换

image-20211219150745518

(7)转换完成

image-20211219150830039

3、使用VM虚拟机创建OpenWRT

==部分关键截图如下图所示==

① 选择的客户机操作系统如下图所示

image-20211219151033407

② 使用NAT地址转换模式

image-20211219151135165

③ 选择磁盘,为刚刚转换过后的.vmdk磁盘格式文件

image-20211219151308758

image-20211219151333701

image-20211219151424001

④ 创建完成,点击“开启此虚拟机”

image-20211219151527356

⑤ 登录成功

image-20211219151648444

4、修改网络参数信息并SSH连接

  1. root@OpenWrt:~# vi /etc/config/network
  2. root@OpenWrt:~# cat /etc/config/network
  3. config interface 'loopback'
  4. option device 'lo'
  5. option proto 'static'
  6. option ipaddr '127.0.0.1'
  7. option netmask '255.0.0.0'
  8. config globals 'globals'
  9. option ula_prefix 'fd33:8f52:e9fd::/48'
  10. config device
  11. option name 'br-lan'
  12. option type 'bridge'
  13. list ports 'eth0'
  14. config interface 'lan'
  15. option device 'br-lan'
  16. option proto 'static'
  17. option ipaddr '192.168.200.50'
  18. option netmask '255.255.255.0'
  19. option ip6assign '60'
  20. root@OpenWrt:~# ip a
  21. 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
  22. link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
  23. inet 127.0.0.1/8 scope host lo
  24. valid_lft forever preferred_lft forever
  25. inet6 ::1/128 scope host
  26. valid_lft forever preferred_lft forever
  27. 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br-lan state UP qlen 1000
  28. link/ether 00:0c:29:b4:2f:04 brd ff:ff:ff:ff:ff:ff
  29. 5: br-lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
  30. link/ether 00:0c:29:b4:2f:04 brd ff:ff:ff:ff:ff:ff
  31. inet 192.168.200.50/24 brd 192.168.200.255 scope global br-lan
  32. valid_lft forever preferred_lft forever
  33. inet6 fd33:8f52:e9fd::1/60 scope global noprefixroute
  34. valid_lft forever preferred_lft forever
  35. inet6 fe80::20c:29ff:feb4:2f04/64 scope link
  36. valid_lft forever preferred_lft forever
  37. root@OpenWrt:~#
  38. _________________________________________________________________
  39. C:\Users\xybdiy>ssh root@192.168.200.50
  40. The authenticity of host '192.168.200.50 (192.168.200.50)' can't be established.
  41. ED25519 key fingerprint is SHA256:uINCvTddAyG9bGGRCD/5R2b7DSmUoxLDcyNe4Pcr9OA.
  42. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
  43. Warning: Permanently added '192.168.200.50' (ED25519) to the list of known hosts.
  44. BusyBox v1.33.1 (2021-10-24 09:01:35 UTC) built-in shell (ash)
  45. _______ ________ __
  46. | |.-----.-----.-----.| | | |.----.| |_
  47. | - || _ | -__| || | | || _|| _|
  48. |_______|| __|_____|__|__||________||__| |____|
  49. |__| W I R E L E S S F R E E D O M
  50. -----------------------------------------------------
  51. OpenWrt 21.02.1, r16325-88151b8303
  52. -----------------------------------------------------
  53. === WARNING! =====================================
  54. There is no root password defined on this device!
  55. Use the "passwd" command to set up a new password
  56. in order to prevent unauthorized SSH logins.
  57. --------------------------------------------------
  58. root@OpenWrt:~#

5、访问OpenWRT的WEB界面,输入配置的IP地址即可

image-20211219152730428

image-20211219152743381

四、更换阿里OpenWRT镜像源

手工替换登录到路由器,并编辑 /etc/opkg/distfeeds.conf文件,

将其中的downloads.openwrt.org 替换为 mirrors.aliyun.com/openwrt`即可。

快捷替换执行如下命令自动替换

  1. sed -i 's_downloads.openwrt.org_mirrors.aliyun.com/openwrt_' /etc/opkg/distfeeds.conf

操作过程如下:

  1. root@OpenWrt:~# cat /etc/opkg/distfeeds.conf
  2. src/gz openwrt_core https://downloads.openwrt.org/releases/21.02.1/targets/x86/64/packages
  3. src/gz openwrt_base https://downloads.openwrt.org/releases/21.02.1/packages/x86_64/base
  4. src/gz openwrt_luci https://downloads.openwrt.org/releases/21.02.1/packages/x86_64/luci
  5. src/gz openwrt_packages https://downloads.openwrt.org/releases/21.02.1/packages/x86_64/packages
  6. src/gz openwrt_routing https://downloads.openwrt.org/releases/21.02.1/packages/x86_64/routing
  7. src/gz openwrt_telephony https://downloads.openwrt.org/releases/21.02.1/packages/x86_64/telephony
  8. root@OpenWrt:~# sed -i 's_downloads.openwrt.org_mirrors.aliyun.com/openwrt_' /etc/opkg/distfeeds.conf
  9. root@OpenWrt:~# cat /etc/opkg/distfeeds.conf
  10. src/gz openwrt_core https://mirrors.aliyun.com/openwrt/releases/21.02.1/targets/x86/64/packages
  11. src/gz openwrt_base https://mirrors.aliyun.com/openwrt/releases/21.02.1/packages/x86_64/base
  12. src/gz openwrt_luci https://mirrors.aliyun.com/openwrt/releases/21.02.1/packages/x86_64/luci
  13. src/gz openwrt_packages https://mirrors.aliyun.com/openwrt/releases/21.02.1/packages/x86_64/packages
  14. src/gz openwrt_routing https://mirrors.aliyun.com/openwrt/releases/21.02.1/packages/x86_64/routing
  15. src/gz openwrt_telephony https://mirrors.aliyun.com/openwrt/releases/21.02.1/packages/x86_64/telephony
  16. root@OpenWrt:~#

五、总结与问题反馈

暂未解决使用VM虚拟机创建的OpenWRT系统,使其能够访问外网,已经尝试多种方法,依旧不行。问题留存,待解决。

  1. root@OpenWrt:~# ping qq.com
  2. ping: bad address 'qq.com'
  3. root@OpenWrt:~#
相关推荐
阅读 +