该文档主要讲解如何在VirtualBox中安装OpenWrt x86
准备:
-
下载和安装 VirtualBox
-
获取OpenWrt 安装镜像:
-
处理OpenWrt镜像文件,
-
下载通用的组合镜像. chaos_calmer/15.05/x86/)
-
如果是zip压缩的需要解压出来:
gunzip openwrt.img.gz
-
转换为VirtualBox支持的启动 虚拟硬盘文件,在 VirtualBox的安装目录下可以找到
VBoxManage
,使用如下命令转换,任选其一。 -
vdi虚拟硬盘格式:
VBoxManage convertfromraw --format VDI openwrt.img openwrt.vdi
(in virtualbox version 5.0.12 the "--format VDI
" is at the end of command) -
vmdk 虚拟硬盘格式 : VirtualBox format:
VBoxManage convertfromraw --format VMDK openwrt.img openwrt.vmdk
-
-
也可以使用源文件进行编译 ( Target System → x86 and Target Images → Build VirtualBox image files).
ext4
needs to be enabled first.
-
在VirtualBox中配置虚拟机
-
打开 VirtualBox
-
- 点击New ,新建虚拟机
-
-
为你的虚拟机设置一个名称
-
系统类型选择linux系统版本选择linux 2.6/3.x/4.x
-
点击next
-
设置RAM大小,256MB或默认值,更小一点也是可以的
- 点击Next
-
-
- 点击完成
- 已经配置好的虚拟机
-
启动虚拟机:
网络配置和问题处理:
1、如果虚拟已经启动,但是Console 没有反应
请点击回车键
2、如果你重新编译镜像后,VirtualBox提示:invalid UUIDs for the disk
在VM设置中和全局设置-->虚拟介质管理器中删除虚拟硬盘
再次在VM机中添加虚拟硬盘
3、设置WAN,LAN网络
1) 关闭或中断虚拟机
2) 打开虚拟机设置中的网络设置
网卡1 共享模式选择NAT network,网卡2选择桥接
指定你需要共享网络的本机(宿主机)的实体网卡
最好禁用混杂模式,如果必须的话可以指定
3)重启虚拟机
4)在配置文件 /etc/config/network
配置LAN和WAN网络
OpenWrt 第一次启动是,网络配置默认是空的,如下所示:
config 'interface' 'wan'
option 'proto' 'dhcp'
option 'ifname' 'eth0'
config 'interface' 'lan'
#option type 'bridge'
option ifname 'eth1'
#option ip6assign '60'
我们需要根据自己的需求配置网络
Tips:
当OpenWrt 配置好LAN,默认启用LAN的DHCP server但是连接的设备获取不到IP时,在本机适用LAN地址如配置的172.16.1.1打开WEB配置页面,默认没有登录密码,在network->Interface ->Lan 点击Lan的Edit,进入LAN的配置页面去掉Physical Settings 的Bridge interface的勾选。
在安装是请尽可能使用最新发布的VirtualBox 以及他的扩展组件。目前在Windows xp/7//8/10 ; Window Server 2008/2012 ;32/64bit都可以正常安装;如果在第一次启动虚拟机的过程中出现中断不相应,请确保本机(宿主机)BIOS中CPU虚拟化的支持是打开的!
原文链接:https://wiki.openwrt.org/doc/howto/virtualbox