如题,为了能在虚拟机上安装openwrt,我们需要在openwrt官网下载img文件到本机,然后将img镜像文件转为虚拟机能够识别的vmdk文件,这样就可以直接进行安装使用了。
找到需要的版本后,进入的x86文件夹下,选择64文件夹,然后找到对应的下载文件,下载后的gz文件使用指令解压为img文件
gzip -vd openwrt-21.02.1-x86-64-generic-squashfs-combined.img.gz
得到的img文件,有两种方式制作vmdk文件
方法一:VirtualBox
如果你的电脑使用的是VirtualBox,那么可以按照以下指令进行转换
VBoxManage convertfromraw openwrt-21.02.1-x86-64-generic-squashfs-combined.img openwrt.vmdk --format VMDK
方法二:qemu
首先需要确认电脑上安装了qemu,在终端输入qemu-img -v查看
qemu安装,附上华为官方安装教程
brew install qemu
或者
yum install qemu-img -y
转换
qemu-img convert -f raw -O vmdk openwrt-21.02.1-x86-64-generic-squashfs-combined.img openwrt.vmdk
其他相关转换命令
VBoxManage convertfromraw xxx.img xxx.VDI --format VDI # .img 转 VDI
VBoxManage convertfromraw xxx.img xxx.VHD --format VHD # .img 转 VHD
配置好虚拟机后,打开openwrt,进入到network中修改网络配置
vi /etc/config/network
配置参数仅供参考
option device 'br-lan' # 如果没有这一行,使用最后两行替换
option proto 'static'
option ipaddr '192.168.123.123' # 非固定格式,根据自己本机ip配置
option broadcast '192.168.123.255' # 非固定格式,根据自己本机ip配置
option gateway '192.168.123.1' # 网关很重要,根据本机ip配置
option dns '8.8.8.8 129.129.129.129' # 非固定格式,根据需要配置
option netmask '255.255.255.0'
option ip6assign '60'
# 可替换device
option ifname 'eth0'
option type 'bridge'
网友评论