openWRT学习
更新时间:2024-01-04 08:43:01 阅读量: 教育文库 文档下载
openwrt学习
OPENWRT学习总结
版本信息
版本 1.0 修订日期 修订人员 2012-3-3 初始版本 修订内容 审核人/日期/意见
版权所有?2012 成都科技有限公司
第 1 页 共 29 页
openwrt学习
目录
Openwrt编译及烧写 ......................................................................................................... 4 Build.tex........................................................................................................................... 4
Building an image ....................................................................................................... 4 Download OpenWrt .................................................................................................... 4 The directory structure................................................................................................. 4
tools和toolchain................................................................................................. 4 Package .............................................................................................................. 5 Target ................................................................................................................. 5 Building OpenWrt....................................................................................................... 5 Creating packages ....................................................................................................... 5 Creating binary packages ............................................................................................. 5 Creating kernel modules packages ................................................................................ 6 Conventions ............................................................................................................... 6 Troubleshooting.......................................................................................................... 6 Using build environments ............................................................................................ 6 Config.tex......................................................................................................................... 6
配置文件结构............................................................................................................ 6 Parsing configuration files in custom scripts ................................................................... 6 wireless.tex文档部分学习 ................................................................................................. 7
通用的atheros无线配置:......................................................................................... 7
通用的多radio atheros无线配置: ............................................................................. 8 配置文件详述............................................................................................................ 8 Mesh Point................................................................................................................. 9 WDS ....................................................................................................................... 10
Unencrypted WDS connections ........................................................................... 10 Encrypted WDS connections ............................................................................... 10 802.1x configurations .................................................................................................11 EAP-PEAP ...............................................................................................................11 限制说明..................................................................................................................11 Adding a new driver configuration ...............................................................................11 Network-scripts.tex .......................................................................................................... 12
Using the network scripts........................................................................................... 12
Writing protocol handers............................................................................................ 12 Network.tex .................................................................................................................... 12
网络接口配置.......................................................................................................... 12
Static................................................................................................................ 13 DHCP .............................................................................................................. 13
版权所有?2012 成都科技有限公司
第 2 页 共 29 页
openwrt学习
PPPOE ............................................................................................................. 13 MTU设置 ........................................................................................................ 14 设置静态路由.......................................................................................................... 14 设置交换机 ............................................................................................................. 14 IPV6设置 ............................................................................................................... 14 Init_script.tex .................................................................................................................. 15
功能脚本................................................................................................................. 15
etc/rc.common说明 .................................................................................................. 15 重载初始化脚本函数 ............................................................................................... 17 定制脚本命令.......................................................................................................... 18 Iw .................................................................................................................................. 18
Iw命令行................................................................................................................ 18
iw说明 ................................................................................................................... 20
列出所有命令行 ............................................................................................... 21
列出所有命令及帮助 ........................................................................................ 21 列出设备支持能力,如带宽信息、802.11n信息 ................................................ 21 扫描................................................................................................................. 21 监听事件,调试目的 ........................................................................................ 21 获取链路状态(STA适用) ............................................................................. 21 建立连接.......................................................................................................... 21 获取STA统计信息........................................................................................... 22 获取特定STA的统计 ....................................................................................... 22 修改transmit bitrates ......................................................................................... 22 设置txpower .................................................................................................... 22 省电模式.......................................................................................................... 22 添加接口.......................................................................................................... 22 删除接口.......................................................................................................... 23 设置频率.......................................................................................................... 23 设置信道.......................................................................................................... 23 设置RTS.......................................................................................................... 23 设置FRAG ...................................................................................................... 23 修改monitor接口标识 ...................................................................................... 24 更新regulatory domain (国家码???) ........................................................ 24 创建mesh 接口................................................................................................ 24 设置WDS peer ................................................................................................. 24 AP和client模式使用4-address ......................................................................... 24
wifi启动 ........................................................................................................................ 25 WEB设置 ...................................................................................................................... 27
LuCI(Lua Configuration Interface) ......................................................................... 27
Web设置 ................................................................................................................ 27 web小测试 ............................................................................................................. 28 频率信道转换函数.......................................................................................................... 28
版权所有?2012 成都科技有限公司 第 3 页 共 29 页
openwrt学习
Openwrt编译及烧写
Build.tex
Building an image
Openwrt采用不同的方式来build a firmware,从头开始来dowloading、patching、compiling一切,包括交叉编译器。也就是说,openwrt不包含任何可执行程序,甚至源代码,他自动下载源代码、打补丁来满足指定平台,并编译。通过修改template,我们就可以改变此过程中的任何步骤。
例如,如果一新的kernel发布了,只需要简单地修订其中的一个makefile文件就会download最新的kernel,patch,编译新的firmware映像。这不仅适用于kernel,也适用于openwrt的所有模块,包含openwrt。这使得openwrt保持最新的编译器、最新的内核及最新的应用。
Download OpenWrt
Openwrt的下载方式:
svn checkout svn://svn.openwrt.org/openwrt/trunk openwrt-trunk
在https://dev.openwrt.org/上有一个trac接口,可用来检视svn提交及浏览源代码仓库。
The directory structure
有四个关键目录:Tools、Toolchain、Package、Target。
tools和toolchain
其中tools和toolchain是通用工具,用来编译firmware image、编译器及C库。其编译结果是三个新的目录:build_dir/host,临时目录,用来build target独立的工具;build_dir/toolchain-,用来编译特定architecture的toolchain;staging_dir/toolchain-,toolchain编译结果的安装目录;对于toolchain目录不需要做任何事情,除非you intend to add a new version of one of the components above。
版权所有?2012 成都科技有限公司
第 4 页 共 29 页
openwrt学习
Package
Package包目录,在openwrt firmware中,所有模块均是.ipk,这种软件包可用来add to iremware中来提供新的特性或去除以节省空间。这些软件包也是在主干外维护的,并可通过package feed系统来获取到。
./scripts/feeds update
Those packages can be used to extend the functionality of the build system and need to be symlinked into the main trunk. Once you do that, the packages will show up in the menu for configuration. You would do something like this: ./scripts/feeds search nmap
Search results in feed 'packages':
nmap Network exploration and/or security auditing utility
$ ./scripts/feeds install nmap
To include all packages, issue the following command: $ make package/symlinks
Target
Target指的是嵌入式平台,包括特定嵌入式平台的内容。其中target/linux目录,which is broken down by platform ,包含了特定平台的kernel patch 、profile config。Target/image目录描述了怎么为特定平台打包firmware。
Target和package步骤均会使用build_dir/作为临时目录来编译,另外,toolchain、target、package步骤所下载的内容均会放到dl目录下。
Building OpenWrt
略
Creating packages
略
Creating binary packages
略
版权所有?2012 成都科技有限公司
第 5 页 共 29 页
openwrt学习
option device \
config wifi-iface
option device \ option network lan
option mode wds
option bssid ca:fe:ba:be:00:02 option ssid \ option encryption psk2
option key \
option network lan option mode ap
option ssid \option encryption psk2
option key \
802.1x configurations
配置略
EAP-PEAP
配置略
限制说明
Limitations
There are certain limitations when combining modes. Only the following mode combinations are supported:
WDS links can only be used in pure AP mode and cannot use WEP (except when sharing the settings with the master interface, which is done automatically).
VAP num defaults to 4, but can be changed by loading the module with the maxvaps=N parameter.
Adding a new driver configuration
具体添加方式略
版权所有?2012 成都科技有限公司
第 11 页 共 29 页
openwrt学习
Network-scripts.tex
Using the network scripts
为使用network,必须通过如下方式包含必须的shell脚本: . /etc/functions.sh # common functions
include /lib/network # include /lib/network/*.sh
scan_interfaces # read and parse the network config
有些协议,如PPP会在运行期间改变配置的接口名,如PPPOE会将eth0改为ppp0,因此要运行scan_interface,而不是从配置中直接读取。运行scan_interface后,ifname选项将包含有效的接口名(用于ip traffic),如果物理设备名与此不同,则会保存在device选项中。
这意味着在scan_interface后运行config_get_lan_ifname,获取的结果可能与运行之前不同。
Writing protocol handers
添加协议处理
可通过在/lib/network下添加shell脚本来定制协议处理,脚本包含: scan_
# change the interface names if necessary }
setup_interface_
Network.tex
网络接口配置
网络配置文件为/etc/config/network,被分隔为多个接口配置。每一个接口配置或直接就是ethernet/wifi接口(如eth0、wl0),或包含多个接口的桥接口。
如:
版权所有?2012 成都科技有限公司 第 12 页 共 29 页
openwrt学习
config interface \
option ifname \option proto \
option ipaddr \option netmask \
option gateway \
option dns \
其中ifname指定linux接口名,如果使用bridge接口则将ifname设置为接口列表,同时添加option type “bridge”。
可通过添加vlanid来支持vlan功能如eth0.1,具体参照switch一节。
此配置是一个简单的eth0静态配置,proto指定了接口使用的协议,支持none、static、dhcp,可通过install额外的包来支持其他的协议。
Static
当为static时,ipaddr与netmask必填,而gateway与dns可选,支持多个DNS服务器,中间以空格隔开即可,如:option dns \
如:
config interface \ option ifname \ option proto \
...
option dns \
DHCP
DHCP当前仅接受ipaddr与hostname选项。其中ipaddr指定了dhcp server的地址,而hostname指定了客户的的hostname标识,两者均可选。
config interface \ option ifname \ option proto \
option ipaddr \ option hostname \
PPPOE
PPP基础的协议,如PPPOE、PPTP支持下列选项: Username:PPP用户名,用于PAP认证 Password:PPP密码
Keepalived:使用LCP ping PPP服务器,保活值,缺省间隔为5. Demand:按需拨友,值指定了最大空闲时间。 Server:对端PPTP服务器IP地址
版权所有?2012 成都科技有限公司
第 13 页 共 29 页
openwrt学习
MTU设置
对所有协议,均可指定MTU,通过设置mtu选项即可,如: config interface \ option ifname \ option proto \ option username \ option password \ option mtu
1492 (optional)
设置静态路由
Setting up static routes
可对指定的接口添加静态路由,在接口配置后会自动添加,举例配置: config route foo
option interface lan option target 1.1.1.0
option netmask 255.255.255.0 option gateway 192.168.1.1
其中route节的名称可选,interface、target、gateway选项是必须的。如果netmsk不填,则默认为主机路由。
设置交换机
Setting up the switch (currently broadcom only) 设置交换机,当前仅broadcom支持。 略
IPV6设置
Setting up IPv6 connectivity 略
版权所有?2012 成都科技有限公司
第 14 页 共 29 页
openwrt学习
Init_script.tex
功能脚本
由于openwrt使用自己的初始script系统,所有的init script必须使用/etc/rc.common作为wrapper安装在/etc/init.d/
如/etc/init.d/httpd: #!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
START=50 start() {
[ -d /www ] && httpd -p 80 -h /www -r OpenWrt }
stop() {
killall httpd }
从上可以看出,script本身并不解析命令行参数,而是由/etc/rc.common来完成。 Start和stop是最基本的功能,几乎所有init script都要提供。Start是在运行/etc/init.d/httpd start时来调用,可以是系统启动时,或用户手动运行此脚本时。
通过/etc/init.d/
/etc/rc.common说明
#!/bin/sh # Copyright (C) 2006-2011 OpenWrt.org
. $IPKG_INSTROOT/lib/functions.sh . $IPKG_INSTROOT/lib/functions/service.sh initscript=$1 action=${2:-help} shift 2
start() { return 0
版权所有?2012 成都科技有限公司
第 15 页 共 29 页
正在阅读:
openWRT学习01-04
烟草丛顶病毒ORF3的功能分析 - 图文05-24
用应接不暇造句02-21
家长会培训材料04-20
董事长秘书岗位职责02-25
中国水处理器行业深度分析报告08-21
酒店前台的工作职责02-25
全国2018年4月自考新闻事业管理真题12-28
街道办事处工作职责02-25
服装督导工作职责02-25
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- openWRT
- 学习
- 共基极放大电路理论分析与计算解读
- 2012年《精细化工概论》期末考试题B卷样卷参考答案
- 一年级上册《雪地里的小画家》集体备课教案
- 发声亮剑学习心得体会
- 家庭装修必知系列之家装全套施工工艺
- 2014年全国历年中考数学分类汇编:分式与分式方程
- 十三五重点项目-冰箱变频压缩机项目资金申请报告
- 实验室使用安全测试题及答案1
- 《单片机原理与应用》复习题1
- 最新湘教版八年级音乐上册全册教案 - 图文
- 复杂网络主要拓扑参数的matlab实现
- 生物化学期末考试试题及答案
- Java实验五
- 青年友谊圆舞曲说课稿
- 深圳私人迷你自助仓储业市场分析和战略规划
- 物理化学复习思考题课件
- 2014年高血压考试试题及答案解析
- 斯柯达昊锐故障案例
- 化工类课程设计
- 资产评估练习题