OpenWrt安装配置学习笔记

来源:互联网 发布:excel表格转化html js 编辑:程序博客网 时间:2024/05/16 02:58

一、OpenWrt概述

OpenWrt是一种嵌入式开源Linux操作系统,我们选用的内核版本是Kamikaze8.09.2,当然也可以选用其它的内核,如:White RussianBackfire等等。

二、安装Linux系统

开发和编译OpenWrt时,主机必须是Linux系统(Fedora12,Ubuntu9.04等),如果你的电脑现在装的是Windows系统的话,你可以先安装虚拟机,再在虚拟机上安装Linux系统(推荐),或者你也可以安装双系统。

三、下载并编译OpenWrt

       kamikaze8.09.2可以通过svn工具来下载,也可以通过http直接下载,地址为: http://downloads.openwrt.org/ 。下载后的源码是bz2文件,解压时要加-jxvf选项。因为配置编译选项的时候不允许root用户,所以最好在解压时就su到普通用户。

       Linux系统下先安装以下库(编译需要):autoconf ,binutils,bison ,bzip2,flex,gawk,gcc,c++,gettext,make,ncurses,devel,patch,unzip,get,zlib-devel .

在非root用户下,进入解压后目录,运行make menuconfig指令,出现图形配置窗口。几个重要选项: Target System->X86Target Profile->Alix;一般来说可以选Select all packages by default;开发工具SDK也选上。其余的配置看具体需求。

 

接下来在当前目录下make V=99,即开始编译。第一次编译的时间会很长(以后再编译就很快了),而且你一定要确保你的linux主机始终接在 Internet上。编译完成后,在bin目录下生成镜像文件openwrt-x86-ext2.image

四、将镜像写到CF卡上

方法一:在windows下用physdiskwrite工具是一个很好的办法。将镜像和physdiskwrite放置在同一个目录下,运行cmd,进入镜像目录,运physdiskwrite,选择目标驱动器,也就是CF卡(必须十分小心,选错会带来灾难性后果)。

方法二:LINUX下面直接使用dd命令就可以。格式如下:dd if=input_file of=output_file

五、远程登陆

通过串口登录的方法:使用终端软件(PUTTY/SecureCRT),串口波特率38400,数据位8,奇偶校验无,停止位1。注意板载串口为公口,一般pc机上的口也是公口,需要将收发线对接才能通信。

也可通过ssh工具登录。在此之前需要配置系统网络ip地址并确保其能接入网络。ssh登录需要用户名和密码,在串口终端运行passwd命令初始化root用户密码。

若以上步骤都正确,则会出现如下界面:

 

六、网络配置

1OpenWRT网络的配置在/root/etc/config/network文件中, 一个典型的配置如下:

config     'interface’       ‘wan’

        option     ‘ifname' 'eth0

       #option     'type'       'bridge'

        option     'proto'    dhcp

       #option     'ipaddr' ‘192.168.1.188'

      #option     'netmask'       '255.255.255.0'

       # option    ‘dns’       ‘192.168.1.1'

       # option    'gateway' ‘192.168.1.1'

config     ‘interface'       ’lan’

        option     ‘ifname' ‘ath0’

        option     'proto'     'static'

        option 'netmask'   '255.255.255.0'

        option 'ipaddr'         ‘192.168.0.1’

注意:不能使用和wan同一网段的IP

1OpenWRT无线网卡的配置在/root/etc/config/wireless文件中, 一个典型的配置如下madwifi-r3314):

config wifi-device wifi0

        option type     atheros

        option channel auto

           option disabled 0

config wifi-iface

        option device   wifi0

        option network lan

        option mode     ap

        option ssid     OpenWrt

        option encryption psk/wep

       option key       000

1The ‘wifi-device’ refers to the physical wifi interface and ‘wifi-iface’ configures a virtual interface on top of that (if supported by the driver).

2:若network,wireless文件配置被改动了之后,用命令/etc/init.d/network restart重启网络服务。

到此,在局域网的无线设备已经可以受到ssidOpenWrt的无线网络,将Alix3D2板子的以太网接口连接到上一级路由上,就可以连接到Internet上了。网络拓扑如下图所示:

 

七、安装路由管理软件X-Wrt

       打开Linux终端

/scripts/feeds update      //更新源

/scipts/feeds install haserl      //安装haserl

make package/haserl/compile              //编译生成haserl_0.9.24-1_i386.ipk

1/scripts下的feeds是个perl脚本

2haserl包是被webif包所依赖的

/scipts/feeds install webif      //安装webif

make package/webif/compile              //编译生成很多webif*.ipk

8.09.2/bin/packet下将haserl_0.9.24-1_i386.ipkwebif_0.3-4845_i386.ipk两个包拷到CF卡上,安装。安装命令如下:

       Opkg install haserl_0.9.24-1_i386.ipk

Opkg install webif_0.3-4845_i386.ipk

到此,你在浏览器上输入:192.168.3.1时,就能进入webif管理界面,并对路由进行管理。

原创粉丝点击