Professional Documents
Culture Documents
OpenWrtisaLinuxdistributionprimarilytargetedatroutingonembeddeddevices.OpenWrt
canbeconfiguredusingtheLinuxcommandlineinterface.
Thefollowingreferenceswereusedinthislab:
http://wiki.openwrt.org/doc/howto/build
https://forum.openwrt.org/viewtopic.php?id=15201
https://help.ubuntu.com/community/CiscoConsole
http://open80211s.org/trac/wiki/OpenWrtBuilding
*IfserveralreadyhastrunkfileskiptoSetupSerialConsolemakingsurethattheDHCPserver
hasbeenconfiguredtogivetherouterboardsMACaddressastaticIPaddress.
Netboot
Thisisdoneonthehostcomputer,nottheRouterBOARD.Thehostcomputermustbeconnectedtothe
internetsothefilescanbedownloaded.Thefollowingpackagesshouldbeinstallednowwhile
connectedtotheinternet.Theywillbeconfiguredandusedthroughouttheprocess:
GettingtheOpenWrtTrunk:
1. Setupthetrunkusingthefollowingcode:
gi t cl one gi t : / / nbd. name/ openwr t . gi t ~/ t r unk/
cd ~/ t r unk/
. / scr i pt s/ f eeds updat e
2. Usethefollowingcodetocheckwhatpackagesaremissing.Thenuseaptgettoinstallthe
missingpackages.Figure1providesthenameofthepackagedependingonwhatdistributionof
Linuxisbeingused.
make menuconf i g
apt - get i nst al l <mi ssi ng packages i n t abl e>
Figure1.Listofpackagesrequiredtomakethebootimage.
3. Oncealltheappropriatepackageshavebeenaddedtypemakemenuconfig.AGUIshouldpop
upaskingfortheconfigurationofOpenWRT.Thismenuallowsforpackagestobeaddedand
removedfromtheimagethatisbeingbuilt.Changethesettingstothefollowing:
TargetSystem
[*]AtherosAR7xxx/AR9xxx
Subtarget
[*]DeviceswithNANDflash(mostlyMikrotik)
TargetProfile
[*]DefaultProfile(NoWiFi)
TargetImages
[*]ramdisk
[*]tar.gz
BaseSystem
[*]Basefiles
[*]Busybox
[*]dnsmasq
[*]hotplug2
[*]mtd
[*]opkg
[*]wirelesstools
KernelModules
NetworkSupport
[*]kmod8021q
WirelessDrivers
[*]kmodath9k
Network
SSH
[*]opensshclient
[*]opensshserver
WebServers/Proxies
[*]lighttpd
[*]lighttpdmodcgi
[*]lighttpdmodauth
[*]hostapd
4. Runthefollowingcommandtomakethebootimage(.elf).
make wor l d
Note:Thiswillprobablytakeatleastanhour.
Figure2.ScreenshotsfromthemenuconfigofOpenWRT.
5. Aftertheimageisdonemaking,makeadirectorythattheimagewillbebootedfrom.Then
makeashortcutfromwheretheimageactuallyistothetftpfolderusingthefollowing
commands:
sudo mkdi r p / t f t pboot
sudo l n sf / home/ est adi um/ t r unk/ bi n/ ar 71xx/ openwr t - ar 71xx-
nand- vml i nux- i ni t r amf s. el f / t f t pboot / openwr t . el f
6. Allfileshavebeendownloaded.InorderfortheRouterBOARDtobootoverEthernet,
theEthernetportonthehostcomputermustbeconfigured.Runthefollowing
commandstosetuptheEthernetport:
SettinguptheDHCPandTFTPServer
7. Makechangestothe/etc/dnsmasq.confasfollows:
onlylistenontheinterfacewhichisdirectlyconnectedtotheRouterBoardsWAN(PoE)port.
e.g.
i nt er f ace=et h0
allowaDHCPrange,e.g.
dhcp- r ange=192. 168. 0. 50, 192. 168. 0. 150, 12
allocateanIPaddresstotheboard(replacetheXXwiththeMACaddressofyourboard!)
dhcp- host =00: 0C: 42: XX: XX: XX, 192. 168. 0. 60
enablednsmasq'sbuiltinTFTPserver
enabl e- t f t p
settherootdirectoryforfilesavailableviaFTP.
t f t p- r oot =/ t f t pboot
setfilename(producedabove)andtftpdserverforBOOTP,e.g.
dhcp- boot =/ t f t pboot / openwr t . el f , boot host , 192. 168. 0. 1
8. Finallyrestartdnsmasq
sudo / et c/ i ni t . d/ dnsmasq r est ar t
WhentheRouterBOARDispoweredon,thehostcomputerwillgivetheassignedIPaddressto
theRouterBOARD.ThiswillallowtheRouterBOARDandthehostcomputertocommunicate
witheachotherandtransferfiles.
SettingupaSerialConsole
9. Usethefollowingcommandtofindwhatthenametheserialportis.Afterthewordserialand
somenumbers,therewillbettyXX.Thisisthenameoftheserialportandwillbeneededlater.
dmesg | gr ep t t y
10. Runminicomwiththecommandbelow.ChooseSerialPortSetupandchangethenameofthe
serialporttothenamethatwasfoundinstep11.Figure3showstheminicomsetup.
sudo mi ni coms
Figure3.Screenshotoftheminicomsetup.
11. ChooseExit.Theserialportisallsetup.ConnecttheserialcablefromtheRouterBOARDtothe
computer.Also,connecttheRouterBOARDfromtheEthernetportwiththeMACaddressadded
totheDHCPservertotheEthernetportonthecomputerthattheDHCPserverislisteningon.
12. ConnecttheRouterBOARDtopower.Immediatelyafterconnectingpower,textshouldstart
showingupintheminicomwindow.Pressenterbeforetwosecondstointerrupttheboot
sequenceontheRouterBOARD.
13. PressotochangethebootdeviceandthenselectewhichtellstheRouterBOARDtobootover
Ethernet.PressxtoleavethesetupandlettheRouterBOARDreboot.Ifallhasbeendoneright,
theoutputshouldlooksimilartofigure4.
RouterBoard433AH
CPUfrequency:680MHz
Memorysize:128MB
Pressanykeywithin2secondstoentersetup..
tryingbootpprotocol..........OK
GotIPaddress:192.168.6.101
resolvedmacaddress4E:80:00:00:00:00
Gateway:192.168.6.1
transferstarted...................................transferok,time=7.16s
settingupelfimage...OK
jumpingtokernelcode
Linuxversion2.6.26.7(joerga@thinkpad)(gccversion4.1.2)#2MonNov1011:23:37CET2008
console[early0]enabled
...
Figure4.Outputfromsuccessfullynetbootedrouterboard.
14. Leavetheboardnetbootedforthepermanentinstallation.
PermanentInstallation
SettingupanHTTPserver
1. Maketheappropriatechangesto/etc/default/minihttpd:
Startdaemon
START=1
2. Maketheappropriatechangeto/etc/minihttpd.conf:
Onwhichhostmini_httpdshouldbind
host =192. 168. 0. 1
Runinchrootmode
chr oot
Wherearethewebfilesstored
dat a_di r =/ home/ owner / t r unk/ bi n/ ar 71xx/
3. Restarttheminihttpdwebserver
sudo / et c/ i ni t . d/ mi ni - ht t pd r est ar t
BuildingthePermanentImage
4. Changeintothedirectorytrunkthatwasusedtomakethefirstimage.Allthesettings
arethesameexceptthetargetimages.Runmenuconfigandusethefollowingsettings:
cd ~/ t r unk/
make menucof i g
Tar get Syst em
[ *] AtherosAR7xxx/AR9xxx
Subtarget
[*]DeviceswithNANDflash(mostlyMikrotik)
TargetProfile
[*]DefaultProfile(NoWiFi)
TargetImages
[*]tar.gz
[*]squashfs
BaseSystem
[*]Basefiles
[*]Busybox
[*]dnsmasq
[*]hotplug2
[*]mtd
[*]opkg
[*]wirelesstools
KernelModules
NetworkSupport
[*]kmod8021q
WirelessDrivers
[*]kmodath9k
Network
SSH
[*]opensshclient
[*]opensshserver
WebServers/Proxies
[*]lighttpd
[*]lighttpdmodcgi
[*]lighttpdmodauth
[*]hostapd
5. Makethepermanentimage:
make wor l d
InstallOpenWrtintoFlash
6. Ontherouterboardwhichisstillnetbooted,pressentertogetashellprompt.
7. RunthefollowinglineofcodewhichwilldeletetheflashmemoryandcopytheOpenWRTimage
intoit
8. Whenthetransferhascompleted,typereboot.Therouterboardwillreboot.Pressenterto
interruptthebootsequence.Chooseoptionotochangethebootdevice.Thenchooseoptiono
tobootfromtheNANDonly.Chooseoptionxandlettherouterboardreboot.
9. Aftertherouterboardhasreboot,pressentertogetashellprompt.Thefilerc.localisthescript
thatautomaticallyrunsatboot.Inordertoconfigurethewirelesscards,thehardware
encryptionneedstobeturnedoff.Thiswillbeaddedtotherc.localfilesoitisdoneeverytime
therouterboardbootsusingthefollowingcode:
vi / et c/ r c. l ocal
r mmod at h9k
i nsmod / l i b/ modul es/ 2. 6. 39. 4/ at h9k. ko nohwcr ypt =1
i f conf i g et h0 192. 168. <net wor kI D>. 10<Node#>
i f conf i g et h0 net mask 255. 255. 255. 0
10. Saveandexitthefile(Shift+zz)andreboottherouterboard.Therouterboardnowhas
OpenWRTrunning.Usingtheiwconfigcommand,thewirelesscardsshouldbevisible.Theyare
downwhentherouterboardbootssotheywillnotshowupinifconfig.Usetheifconfig
commandtobringthemup.
ConfiguringRouterBOARD
1. Installnano.Nanoisatexteditorfortheterminalthatismuchmoreuserfriendlythanvi.
opkg updat e
opkg i nst al l nano
2. Changethehostnameandthetimezone
3. Setpassword(e$tad465)forroot,whichwillbeusedforSSH.ConfigureOpenSSHto
acceptconnectionsfromroot.
passwd
nano / et c/ ssh/ sshd_conf i g
Per mi t Root Logi n yes
4. ReboottheRouterBOARD.Ifallwentwell,youshouldbeabletoSSHintothe
RouterBOARDfromthehostcomputerbyrunningthefollowcommandfromthe
terminalonthehost:
ssh r oot @192. 168. <net wor kI D>. 10<Node#>
Or
ssh r oot @Node<net wor kI D>- <Node#>