您好,欢迎访问三七文档
当前位置:首页 > 办公文档 > 工作计划 > Openwrt编译进阶
摘要:这篇文章是Openwrt编译的学习笔记包括(1)Openwrt基础入门(2)Openwrt基础进阶(3)集成软件之前总喜欢在在写文章之前写一大段自己的光荣事迹,后来发现看别人这样写的文章是一件很蛋疼的事,毕竟这是一篇技术类文章,不是小学生日记。好吧,这次直接进入正题,抱歉,又写了一段和本文内容无关的文字……去年学校开始用H3C认证来限制我们上网,于是好奇心再次害死猫,本宫终于修成正果,误入Openwrt这个大坑,折腾Openwrt有一年多了,到了回馈社会的时候了,这篇文章写写Openwrt编译的一些高级配置(相对入门级编译教程而言),以HG255D为例。Openwrt基础编译这类文章一手一大把,精简的,详细的(多半是废话)都有,这里就简单的把一些指令写下编译环境为Ubuntu#升级组件包sudoapt-getupdate#安装编译需要的组件sudoapt-getinstallgccg++binutilspatchbzip2flexbisonmakeautoconfgettexttexinfounzipsharutilssubversionlibncurses5-devncurses-termzlib1g-devgit-coregawkasciidoclibz-devsphinxsearchlibtoolsphinx-commonlibssl-devlibsqlite3*intltoollibiconv*gstreamer-0.10*glib2.0libxml2-devqemu(*64位系统需安装ia32-libs)#使用非root用户登录,建立openwrt目录mkdiropenwrt#进入openwrt目录cdopenwrt#下载openwrt源码svncheckoutsvn://svn.openwrt.org/openwrt/trunk#赋予trunk目录权限sudochmod-R777trunk#进入trunk目录cdtrunk#更新最新源码./scripts/feedsupdate-a#安装最新源码./scripts/feedsinstall-a#更新版本号svnup#进入编译菜单makemenuconfigY:选择Y,该软件将被编译,并且加入到你的目标固件里;M:选择M,该软件包将会被编译,但不会被放入固件里。在需要它的时候,可以用OPKG软件包管理器进行安装;N:选择N,该软件包将不会被编译,也不会被安装进固件。方向键是移动光标回车键是确认空格键是选择,可以代替Y/M/N键的使用/:搜索#编译makeV=99#清除编译过程产生的临时文件makeclean#恢复编译环境makedefconfigOpenwrt编译进阶其实按照上面的指令一路执行下来,你已经能够在/bin/$target下找到刷机固件了,是不是很简单……修改WIFI设置package/kernel/mac80211/files/lib/wifi/mac80211.shconfigwifi-deviceradio$devidxoptiontypemac80211optionchannel11optionhwmode11ngoptionpath'10180000.wmac'optionhtmodeHT20listht_capabGFlistht_capabSHORT-GI-20listht_capabSHORT-GI-40listht_capabTX-STBClistht_capabRX-STBC12#REMOVETHISLINETOENABLEWIFI:optiondisabled0optionnoscan1optiontxpower20optionhtmodeHT40-configwifi-ifaceoptiondeviceradio$devidxoptionnetworklanoptionmodeap#自定义SSID为MakeBlaze_MAC后六位optionssidMakeBlaze_$(cat/sys/class/ieee80211/${dev}/macaddress|awk-F:'{print$4$5$6}'|tra-zA-Z)optionencryptionnone修改LUCI修改LUCI界面配置feeds/luci/modules/base/root/etc/config/luciconfigcoremainoptionresourcebase'/luci-static/resources'#设置默认语言optionlang'zh_cn'#设置默认主题optionmediaurlbase'/luci-static/bootstrap'#设置可选择的语言configinternallanguagesoptionzh_cn'chinese'optionen'English'#设置可选择的主题configinternalthemesoptionBootstrap'/luci-static/bootstrap'添加释放内存feeds/luci/modules/admin-full/luasrc/controller/admin/index.luafunctionindex()+entry({admin,Free_Memory},call(Free_Memory),_(释放内存),75)endfunctionFree_Memory()luci.util.exec(echo3/proc/sys/vm/drop_caches)luci.http.redirect(luci.dispatcher.build_url(admin,status,overview))end在顶栏显示重启feeds/luci/modules/admin-full/luasrc/controller/admin/system.luafunctionindex()entry({admin,reboot},call(action_reboot),_(Reboot),90)endfeeds/luci/modules/admin-full/luasrc/view/admin_system/reboot.htm%:Performreboot%在顶栏显示备份/升级feeds/luci/modules/admin-full/luasrc/controller/admin/system.luafunctionindex()entry({admin,flashops},call(action_flashops),_(Backup/FlashFirmware),70)end修改配置文件package/base-files/files/etc/在这个目录里,你可以把你的备份的路由器导入进来修改root密码package/base-files/files/etc/shadow#默认情况下root是没有密码的,需设定密码才能开启sshroot:$1$wEehtjxj$YBu4quNfVUjzfv8p/PBo5.:0:0:99999:7:::修改路由连接数package/base-files/files/etc/sysctl.confnet.netfilter.nf_conntrack_max=65535修改主机名,设定时区package/base-files/files/etc/config/systemconfigsystem#设置主机名optionhostname'MakeBlaze'optionconloglevel'8'optioncronloglevel'8'#设置时区optionzonename'Asia/Shanghai'optiontimezone'CST-8'#设置时间服务器configtimeserver'ntp'optionenable_server'1'listserver'210.72.145.44'listserver's1a.time.edu.cn'listserver's1b.time.edu.cn'listserver'202.120.2.101'configled'usb_led'optionname'USB'optionsysfs'hg255d:usb'optiontrigger'usbdev'optiondev'1-1'optioninterval'50'configled'wlan_led'optionname'WLAN'optionsysfs'hg255d:wlan'optiontrigger'netdev'optiondev'ra0'optionmode'linktx'configled'internet_led'optionname'INTERNET'optionsysfs'hg255d:internet'optiontrigger'netdev'optiondev'eth0.2'optionmode'txrx'SAMBA免密码访问package/base-files/files/etc/config/sambaconfigsamba#显示中文optioncharset'gb2312'configsambashareoptionread_only'no'optionguest_ok'yes'optioncreate_mask'0777'optiondir_mask'0777'optiondisplaycharsetpackage/base-files/files/etc/samba/smb.conf.template[global]netbiosname=|NAME|displaycharset=|CHARSET|interfaces=|INTERFACES|serverstring=|DESCRIPTION|unixcharset=|CHARSET|workgroup=|WORKGROUP|browseable=yesdeadtime=30domainmaster=yesencryptpasswords=trueenablecorefiles=noguestaccount=rootguestok=yes#invalidusers=rootlocalmaster=yesloadprinters=nomaptoguest=BadUsermaxprotocol=SMB2minreceivefilesize=16384nullpasswords=yesobeypamrestrictions=yesoslevel=20passdbbackend=smbpasswdpreferredmaster=yesprintable=nosecurity=sharesmbencrypt=disabled#smbpasswdfile=/etc/samba/smbpasswdsocketoptions=TCP_NODELAYIPTOS_LOWDELAYsyslog=2usesendfile=yeswriteable=yes集成软件添加aria2,luci添加,web管理界面aria2的依赖安装sudoapt-getupdatesudoapt-getinstallautoconfautomakelibcppunit-devautopointopenssllibtoolsphinx-commonsphinxsearchlibgcrypt11-dev#下载aria2源码cddlsudoapt-getinstallwgetwget获取md5码md5sumaria2-1.18.7.tar.bz2#添加luci-aria2这里用的是南浦月的luci-app-aira2和webui-aria
本文标题:Openwrt编译进阶
链接地址:https://www.777doc.com/doc-5053415 .html