如題河质,為了能在虛擬機(jī)上安裝openwrt辕坝,我們需要在openwrt官網(wǎng)下載img文件到本機(jī)骏啰,然后將img鏡像文件轉(zhuǎn)為虛擬機(jī)能夠識別的vmdk文件恼五,這樣就可以直接進(jìn)行安裝使用了。
找到需要的版本后策彤,進(jìn)入的x86文件夾下奥吩,選擇64文件夾册养,然后找到對應(yīng)的下載文件傲绣,下載后的gz文件使用指令解壓為img文件
gzip -vd openwrt-21.02.1-x86-64-generic-squashfs-combined.img.gz
得到的img文件掠哥,有兩種方式制作vmdk文件
方法一:VirtualBox
如果你的電腦使用的是VirtualBox,那么可以按照以下指令進(jìn)行轉(zhuǎn)換
VBoxManage convertfromraw openwrt-21.02.1-x86-64-generic-squashfs-combined.img openwrt.vmdk --format VMDK
方法二:qemu
首先需要確認(rèn)電腦上安裝了qemu秃诵,在終端輸入qemu-img -v查看
qemu安裝续搀,附上華為官方安裝教程
brew install qemu
或者
yum install qemu-img -y
轉(zhuǎn)換
qemu-img convert -f raw -O vmdk openwrt-21.02.1-x86-64-generic-squashfs-combined.img openwrt.vmdk
其他相關(guān)轉(zhuǎn)換命令
VBoxManage convertfromraw xxx.img xxx.VDI --format VDI # .img 轉(zhuǎn) VDI
VBoxManage convertfromraw xxx.img xxx.VHD --format VHD # .img 轉(zhuǎn) VHD
配置好虛擬機(jī)后,打開openwrt菠净,進(jìn)入到network中修改網(wǎng)絡(luò)配置
vi /etc/config/network
配置參數(shù)僅供參考
option device 'br-lan' # 如果沒有這一行目代,使用最后兩行替換
option proto 'static'
option ipaddr '192.168.123.123' # 非固定格式,根據(jù)自己本機(jī)ip配置
option broadcast '192.168.123.255' # 非固定格式嗤练,根據(jù)自己本機(jī)ip配置
option gateway '192.168.123.1' # 網(wǎng)關(guān)很重要,根據(jù)本機(jī)ip配置
option dns '8.8.8.8 129.129.129.129' # 非固定格式在讶,根據(jù)需要配置
option netmask '255.255.255.0'
option ip6assign '60'
# 可替換device
option ifname 'eth0'
option type 'bridge'