English Language flag
// Log In
// CVSweb
Project: FreeWRT
// Summary // Activity // Search // Tracker // Lists // News // SCM // Wiki

SCM Repository

ViewVC logotype

Contents of /branches/freewrt_1_0/docs/handbook/user/handbook.tex

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3805 - (show annotations) (download) (as text)
Tue Oct 7 15:14:16 2008 UTC (5 years, 4 months ago) by tg
File MIME type: application/x-tex
File size: 65642 byte(s)
fix SVN repo URIs

XXX someone please double-check the Teχ syntax, we have more begin than end

1 \documentclass[12pt,a4paper,openany,smallheadings,headinclude,headsepline,final]{scrreprt}
2 %\usepackage{ucs} % Unicode support
3 \usepackage[utf8]{inputenc} % UTF-8 characters as input are allowed
4 %\usepackage{amsmath}
5 %\usepackage{amsfonts}
6 %\usepackage{amssymb}
7 %\usepackage{caption2}
8 \usepackage[english]{babel} % Sets the layout to English style
9 \usepackage{varioref} % Intelligent page references
10 \usepackage{txfonts}
11 \usepackage[pdftex]{color} % Colour control for LaTeX documents
12 \usepackage[pdftex]{graphicx} % Enhanced support for graphics
13 %\usepackage{listings}
14 \usepackage{makeidx} % Standard LaTeX package for creating indexes
15 \usepackage{longtable} % Allow tables to flow over page boundaries
16 \usepackage[T1]{fontenc} % T1-fonts
17 \usepackage{fancyvrb} % Sophisticated verbatim text
18 \usepackage[a4paper,rmargin=2cm,lmargin=2cm,tmargin=2.5cm,bmargin=3.5cm]{geometry} % Flexible and complete interface to document dimensions
19 \usepackage{fixltx2e, mparhack} % Patches for LaTeX; A workaround for a LaTeX bug in marginpars
20 \usepackage[nofancy]{svninfo} % Typeset Subversion Keywords
21 \usepackage{float} % Improved interface for floating objects
22 \usepackage{hyperref} % Extensive support for hypertext in LaTeX
23
24
25 \definecolor{skyblue}{rgb}{0,0.3323,0.5720}
26 \restylefloat{figure}
27 \hypersetup{
28 colorlinks=true,anchorcolor=red,
29 breaklinks=true,linkcolor=blue,urlcolor=red,
30 citecolor=skyblue,
31 pdfauthor={The FreeWRT Team},
32 pdftitle={FreeWRT User Handbook},
33 pdfcreator={tetex and VIM},
34 pdfsubject={Open Source},
35 pdfview=FitV,
36 pdfstartview=FitV,
37 pdfstartpage={1},
38 pdfpagelayout=SinglePage,
39 pdfpagemode=None,
40 pdfkeywords={FreeWRT}
41 }
42 \fvset{fontsize=\small, frame=single} % fancyvrb: set small font size and enable frames
43 %\usepackage{cancel}
44 %\usepackage[final, activate, verbose=true]{microtype}
45 %\usepackage{ngerman}
46 %\usepackage{bookman}
47 %\usepackage[a4paper,twoside,rmargin=2cm,lmargin=2cm,tmargin=2.5cm]{geometry}
48 %\usepackage[a4paper,rmargin=2cm,lmargin=2cm,tmargin=2.5cm,bmargin=3.5cm]{geometry}
49 %\usepackage{ncntrsbk}
50 %\usepackage{float}
51 %\restylefloat{figure}
52 %\bibliographystyle{alphadin}
53 %\bibliographystyle{alpha}
54
55 % Generate index in preamble
56 \makeindex
57
58 \begin{document}
59 \svnInfo $Id$
60 \setlength{\marginparwidth}{10mm}
61
62 \include{cover}
63
64 \renewcommand{\thepage}{\roman{page}}
65 \tableofcontents
66 %Set Arabic Numbering 1,2,3,...
67 % Clear needed to renumber from the right position
68 \cleardoublepage
69 \renewcommand{\thepage}{\arabic{page}}
70 %Reset Counter
71 %\setcounter{page}{1}
72
73 % Set marks where it should Change
74 \renewcommand{\chaptermark}[1]{%
75 \markboth{\large \thechapter.\ \normalsize \scshape #1}{}}
76 \renewcommand{\sectionmark}[1]{\markright{\thesection.\ \scshape #1}}
77
78
79 % Create some new commands for designing the text
80 % applications
81 \newcommand{\app}[1]{%
82 \textsf{\textit{#1}}}
83 % terminology, vendor or product names
84 \newcommand{\term}[1]{%
85 \textsc{#1}}
86 % filenames and directories
87 \newcommand{\file}[1]{%
88 \textsf{#1}}
89 % user input
90 \newcommand{\command}[1]{%
91 \texttt{\textbf{#1}}}
92 % example code, output of applications
93 \newcommand{\code}[1]{%
94 \texttt{#1}}
95 % emphasized text (nicer than \emph{})
96 \newcommand{\strong}[1]{%
97 \textbf{#1}}
98
99
100 \chapter{Introduction}
101
102 Welcome to FreeWRT! This handbook covers the building, installation and usage
103 aspects of the FreeWRT 1.0 Linux distribution. FreeWRT is a portable, secure
104 and functional Linux distribution for embedded systems. As FreeWRT is a source
105 code distribution, it does not provide any pre-compiled firmware for embedded
106 systems. The latest version of this document is always available at the FreeWRT
107 website. If you have any comments, criticism or found some wrong description,
108 please send us an e-mail to
109 \href{mailto:freewrt-handbook@freewrt.org}{freewrt-handbook@freewrt.org}, we
110 are always happy about getting feedback to this document, and will try to
111 update or correct the issues mentioned by you.
112
113 The FreeWRT User handbook is split into several distinct chapters.
114 \nameref{ch:ADK} covers the building of FreeWRT firmware images. In
115 \autoref{ch:installing}, \nameref{ch:installing}, all aspects regarding the
116 installation and deinstallation of FreeWRT firmware images are covered. The
117 next chapter, \nameref{ch:administration}, covers administrational tasks, such
118 as network configuration, the FreeWRT configuration filesystem, package
119 management and update mechanism. The last chapter,
120 \nameref{ch:troubleshooting}, helps troubleshooting problems and recovering a
121 bad firmware installation. The appendix contains board specific information.
122 For FreeWRT 1.0 these are only Broadcom based embedded systems.
123
124 The intended audience for this handbook are advanced users with basic knowledge
125 about Linux, networking and software development. The reader should be aware of
126 basic command line tools, the vi editor and a shell. FreeWRT does not contain
127 any high level administration tools (e.g. web based administration) and is
128 fully configured via command line.
129
130 \section{Typographic Conventions}
131
132 Examples starting with \code{\#} indicate a command that must be invoked as
133 super user. You can use \command{su} to gain super user privileges.
134
135 \begin{Verbatim}[label=example for a command line with super user privileges]
136 # fwcf commit
137 \end{Verbatim}
138
139 Examples starting with \code{\$} indicate a command that can be invoked as a
140 normal user. The default user account on a freshly installed FreeWRT system is
141 "\code{admin}", the password "\code{FreeWRT}".
142
143 \begin{Verbatim}[label=example for a command line as non-privileged user]
144 $ cat /etc/banner
145 \end{Verbatim}
146
147 %\chapter{Web Interface Builder (WIB)}\label{ch:WIB}
148 %
149 %FIXME It is named later in the text, but not explained what it is. Probably
150 %this chapter can be joined with the chapter about ADK
151
152 \chapter{Appliance Development Kit (ADK)}\label{ch:ADK}
153
154 The ADK is the core of FreeWRT and contains all scripts and sources to create
155 firmware images for every supported embedded system. FreeWRT 1.0 supports the
156 following embedded systems:
157
158 \begin{itemize}
159 \item Asus WL500g
160 \item Asus WL500g deluxe
161 \item Asus WL500g premium
162 \item Linksys WRT54G v2.0
163 \item Linksys WRT54G v2.2
164 \item Linksys WRT54G v3.0
165 \item Linksys WRT54G v3.1
166 \item Linksys WRT54G v4.0
167 \item Linksys WRT54GS v1.0
168 \item Linksys WRT54GS v1.1
169 \item Linksys WRT54GS v4
170 \item Linksys WRT54G3G
171 \item Linksys WRT54GL
172 \item Netgear WGT634u
173 \end{itemize}
174
175 In this release we only support the Linux 2.4 kernel. The ADK contains over 600
176 software packages.
177
178 \section{Prerequisites}
179
180 Here is a list of all supported and tested host systems. The host system is
181 needed to create a firmware for your embedded system.
182
183 The list of supported GNU/Linux build systems is not an exclusive one, these
184 are just the ones tested and verified. The other millions of linux
185 distributions are very likely to work, too.
186
187 \begin{itemize}
188 \item Debian GNU/Linux
189 \item Gentoo Linux
190 \item OpenSuSE
191 \item Ubuntu GNU/Linux
192 \item Fedora Core
193 \item OpenBSD (partial support)
194 \footnote{some addon packages does not compile}
195 \item MirOS BSD (partial support)
196 \footnote{some addon packages does not compile}
197 \end{itemize}
198
199 Please install the following software, which is needed to build a basic
200 firmware image. If you choose more packages some more prerequisites might be
201 needed. The ADK host checks will warn you about any software you need to
202 install to compile a specific package. Here is a list of the required
203 software:
204
205 \begin{itemize}
206 \item gcc3 or higher
207 \item g++
208 \item binutils
209 \item patch
210 \item gzip
211 \item bzip2
212 \item unzip
213 \item flex
214 \item bison
215 \item GNU make
216 \item zlib (+headers)
217 \item ncurses (+headers)
218 \item (g)libc headers
219 \item perl
220 \end{itemize}
221
222 The ADK scripts will check for the required versions of these tools in advance.
223
224 To build FreeWRT with the ADK it is recommended to have an unprivileged user.
225 Please \underline{never} build FreeWRT as super user. Because all necessary
226 source tarballs are downloaded from the internet automatically, your host
227 system needs a working internet connection.
228
229 \section{Getting the source}
230
231 Now go to a directory where you want to build the firmware. Depending on the
232 features you select you will need about 2.5--5 GB free disk space. This
233 includes the ADK itself, any source archives which will be downloaded and their
234 extracted copies (for compiling).
235
236 To get the latest stable FreeWRT ADK try one of these commands:
237 \begin{Verbatim}[label=Check out an 1.0.x revision of FreeWRT ADK via HTTP protocol]
238 $ svn co http://www.freewrt.org/svn/tags/freewrt_1_0_x freewrt
239 \begin{Verbatim}[label=Check out an 1.0.x revision of FreeWRT ADK via Subversion protocol]
240 $ svn co svn://www.freewrt.org/svn/tags/freewrt_1_0_x freewrt
241 \begin{Verbatim}[label=Check out the 1.0-stable branch of FreeWRT ADK via HTTP protocol]
242 $ svn co http://www.freewrt.org/svn/branches/freewrt_1_0 freewrt
243 \begin{Verbatim}[label=Check out the 1.0-stable branch of FreeWRT ADK via Subversion protocol]
244 $ svn co svn://www.freewrt.org/svn/branches/freewrt_1_0 freewrt
245 \end{Verbatim}
246
247 The value $x$ is a place holder for the latest minor release number. Take a
248 look at our project page to find out which minor release number is the latest
249 one.
250
251 After successfully downloading, enter the directory:
252
253 \begin{Verbatim}
254 $ cd freewrt
255 \end{Verbatim}
256
257 This directory will be referred to as the ADK root later on.
258
259 \section{Some Theory First}
260
261 Building a FreeWRT firmware image is just like building a new Linux kernel, but
262 a little more complex. There is a \app{ncurses}-based configuration menu at the
263 beginning, the changes made are saved into a file named \file{.config} in the
264 ADK root. The build is done by the various Makefiles, compiling and linking the
265 sources together accordingly to the symbols defined in \file{.config}.
266
267 Unlike kernel compilation, FreeWRT needs to be cross-compiled. This leads to
268 special premises, as most of the tools need to be specially build. But no
269 panic, FreeWRT will do this all for you. In fact, this is done at the second
270 run of \command{make} (the first one opens the configuration), and therefore
271 can be seen as part of the first firmware build. For clarity though, we will
272 discuss these two things separately.
273
274 \section{Preparing the Build Process}
275
276 After downloading the FreeWRT ADK, it's time to prepare the ADK for the
277 building of firmware images (for explanations see the chapter above).
278
279 \subsection{Creating A Configuration}
280
281 The first step is to run \command{make}. After checking some prerequisites (see
282 \nameref{ch:troubleshooting} below for aid in problems), a console based
283 configuration menu should start. Theoretically no choices have to be made, but
284 it's proven useful to at least:
285 \begin{itemize}
286 \item select a target (menu: \code{Embedded System})
287 \item select the root filesystem type (menu: \code{Target Firmware type})
288 \end{itemize}
289
290 Then quit saving changes. If you forgot that, just run \command{make} again,
291 redo your changes, then save.
292
293 \subsection{Building ADK}
294
295 Now that you have a first minimal configuration, it is time to build the
296 toolchain for cross-compiling. To do this, just enter \command{make} again. The
297 build starts downloading and compiling each needed part of the toolchain, and
298 later continues with building the first firmware image. Later one can be taken
299 as proof of a working ADK.
300
301 Already experienced in compiling \app{gcc}? Then you know\dots If not, better
302 be told that it takes \underline{really long} to finish. In the meantime I
303 suggest reading the next chapter dealing with internals about cross-compiling.
304
305 \section{Details Of Cross-Compiling}
306
307 A cross-compile toolchain exists of a set of tools: a compiler, linker,
308 assembler, debugger and a C~library. A cross-compile toolchain runs on your
309 host system and creates native binaries for your target system. A cross-compile
310 toolchain is basically created in six steps:
311
312 \begin{enumerate}
313 \item Get and prepare the Kernel and C~library headers of your target system
314 \item Compile the binutils package for your target
315 \item Compile a static C~compiler for your target
316 \item Compile and install a C~library for your target
317 \item Compile and install a full C/C++~compiler
318 \item Compile and install the GNU debugger
319 \end{enumerate}
320
321 The cross-compile toolchain is created in
322 \file{staging\_dir\_\$(cpu\_arch)}\footnote{e.g. mipsel, which stands for MIPS
323 Little Endian}. All the tools running on the host, but used to create, analyze
324 or debug for the target are kept in this directory. All addon headers and
325 libraries are installed to this directory.
326
327 If you want to compile a simple application without using the ADK, just use the
328 compiler directly (e.g. compiling a MIPS Little Endian application):
329 \begin{Verbatim}[label=compile a simple application with the cross-compiler]
330 ./staging_dir_mipsel/bin/mipsel-linux-uclibc-gcc -o myapp myapp.c
331 \end{Verbatim}
332
333 Check with the tool \app{file} if you got a MIPS binary:
334 \begin{Verbatim}[label=check the binary with \app{file}]
335 $ file myapp
336 myapp: ELF 32-bit LSB MIPS-I executable, MIPS, version 1 (SYSV), dynamically
337 linked (uses shared libs), not stripped
338 \end{Verbatim}
339
340 \section{Building A FreeWRT Firmware Image}
341
342 Your local copy of the FreeWRT ADK should now be prepared for building firmware
343 images. The next step is to do an extensive configuration for the image you
344 want to create. To start the configuration menu, type \command{make
345 menuconfig}.
346
347 When selecting packages, \code{<*>} means it will be inserted into the firmware
348 images and \code{<M>} means it will be build as an addon package which can be
349 installed later at runtime.
350
351 The target device and filesystem should already been chosen by you to the right
352 value, if not you will have to issue a \command{make clean} before actually
353 building the firmware image. Otherwise things get messed up. A smooth rebuild
354 is a missing feature in the current ADK. For the packages, if unsure, you can
355 just select one of the package collections. After that, you can still manually
356 check the choices made by the collection and correct them if appropriate. Do
357 not forget to save your configuration when leaving!
358
359 After leaving the menubased configuration, type \command{make} again to build
360 the new FreeWRT firmware image. Depending on your package selections and
361 underlying hardware, this will take different amounts of time. For your spare
362 time there is the following chapter giving some explanation about what is done
363 at this point.
364
365 \section{Firmware Build Process In Detail}
366
367 Just like when building the ADK's toolchain, the sources for the selected
368 packages are downloaded from the internet first, then built using the
369 cross-compiler and libraries of the ADK.
370
371 The detailed order of firmware image building is:
372
373 \begin{itemize}
374 \item compile the Linux kernel and all supported kernel modules
375 \item compile all selected packages
376 \item clean the target root directory
377 \item install all packages to the target root directory
378 \item create the root filesystem image
379 \item create the firmware image (bootloader, kernel and root
380 filesystem)
381 \end{itemize}
382
383 The result of the build process is created in the directory \file{bin/}. You
384 will find a firmware image in the top level directory. Check the size of the
385 binary image file to see if it is small enough to fit into flash memory of your
386 embedded system. Furthermore there is a directory \file{package/}, which
387 contains all base and add--on packages.
388
389 \section{Troubleshooting}
390
391 This section deals with various tips for problems with the ADK installation.
392
393 \subsection{Errors During Prerequisites Check}
394
395 To re-issue the checks, use \command{make prereq}.
396
397 \begin{itemize}
398 \item GNU make 3.80 too old \\
399 On a Fedora Core 4 hostsystem the first you'll get is
400 \begin{Verbatim}[label=error message with too old GNU make]
401 $ make
402 GNU make 3.80 too old.
403 Please install GNU make 3.81 or higher to continue.
404 You can override this check, see http://www.freewrt.org/faq for details.
405 It is suggested to upgrade your copy of bison to
406 GNU Bison 2.3 because of its bug fixes.
407 make: *** [.prereq_done] Error 1
408 \end{Verbatim}
409 it is quite a nice error that tells you to use more up to date software, but
410 we can anyhow give this hostsystem a try and tell make to ignore those
411 errors/warnings running \command{make prereq-noerror}.
412 \end{itemize}
413
414 \subsection{Compilation errors}
415
416 If you encounter any compilation errors, then first try to reproduce the error.
417 First update your ADK tree via \command{svn update}, to be sure that the error
418 is not already fixed in the subversion repository. After that do a
419 \command{make clean \&\& make}, to reproduce your problem.
420
421 If you can reproduce the problem, please file a bug report. Please always
422 report following information:
423 \begin{itemize}
424 \item Operating system type and version
425 \item GCC and Binutils versions of your host system
426 \item complete error message, not only the last 4 lines
427 \end{itemize}
428
429 \chapter{Installing FreeWRT Firmware Images}\label{ch:installing}
430
431 The FreeWRT ADK produces a single image holding both kernel and root
432 filesystem. This image can be written into your hardware's builtin flash memory
433 on serveral ways (ordered by needed skills, increasing downwards):
434 \begin{itemize}
435 \item via the original firmware's web interface
436 (\autoref{sec:webinterface})
437 \item via \texttt{mtd} when reflashing or migrating from another third
438 party distribution (\autoref{sec:mtd})
439 \item via network using a TFTP client (\autoref{sec:tftp})
440 \end{itemize}
441
442 \section{Flashing The Firmware}
443
444 \subsection{Web Interface Method}\label{sec:webinterface}
445
446 The following text describes how to use the original firmware's web interface
447 to flash FreeWRT. The object of demonstration is an \term{Asus WL500gP}, but
448 this guide should fit more or less fine for other systems, too.
449
450 If you flash a router from \term{Linksys}, we strongly suggest to use the
451 popular \term{ping exploit} to allow recovery, if your image is broken or the
452 flash process was interrupted by a power shortage.
453
454 There are some things that you should have done previously:
455 \begin{itemize}
456 \item read the special documentation page about your hardware in our wiki, some
457 systems need special precaution before flashing
458 \item a firmware image has to be built (matching the used hardware, of course)
459 \item the router has to be powered on
460 \item your computer needs to be connected to one of the LAN ports
461 (using IP address \file{192.168.1.2})
462 \end{itemize}
463
464 \parbox{17em}{
465 After preparation is complete, open your favourite browser and type
466 \command{192.168.1.1} into the address bar. You should reach the web
467 interface's startup page:
468 }\hfill\parbox{20em}{
469 \includegraphics[width=20em]{pics/asus-startup.png}
470 } \\ [1em]
471 \parbox{17em}{
472 Then click on \code{System Setup}:
473 }\hfill\parbox{20em}{
474 \includegraphics[width=20em]{pics/asus-system_setup.png}
475 } \\ [1em]
476 \parbox{17em}{
477 In the new menu click on \code{Firmware Upgrade}, and enter the name of your
478 firmware image into the appropriate field:
479 }\hfill\parbox{20em}{
480 \includegraphics[width=20em]{pics/asus-fw_upgrade.png}
481 } \\ [1em]
482 Finally click on \code{Upload}. As the whole process of writing the image to
483 flash and rebooting (don't forget that it creates \app{ssh} hostkeys on first
484 boot) takes quite long (yes, a couple of minutes). Better go and get a coffee
485 or tea.
486
487 When everything went well, you can login using \app{ssh}. The default username
488 is "\code{admin}". The default password for images created via WIB or ADK is
489 "\code{FreeWRT}". It is possible to change this password in the ADK, before
490 image creation.
491
492 \subsection{\texttt{mtd} -- The Flash Utility}\label{sec:mtd}
493
494 For this method to work, you need to copy the file containing the firmware
495 image to the router, preferably into \file{/tmp/}, the memory filesystem should
496 be big enough to hold the full image. If not, use \app{wget} to get the image
497 via http or ftp and pipe the result into \app{mtd}.
498
499 Then the image is written to flash using \app{mtd}, optionally giving
500 additional options (see below).
501
502 The \app{mtd} utility was written with simplicity and code size in mind. It's
503 features were derived from the
504 \href{http://sources.redhat.com/jffs2/}{\app{mtd-utils}}, combining the needed
505 parts into a single small tool providing all the functionality necessary for
506 FreeWRT, and leaving everything out that's not.
507
508 \app{mtd} provides the following features:
509 \begin{description}
510 \item[unlock] some chips need unlocking before they can be written to
511 \item[erase] this is a filesystem independent method to delete all
512 contents on the flash. Basically this is like \app{format} in
513 MS--DOS.
514 \item[write] this is generally the same functionality as using \app{dd}
515 or \app{rawrite}, but \app{mtd} takes care of the quirks that
516 have to be paid attention to for correctly handling the type of
517 flash in use
518 \end{description}
519
520 Further it can request your system to reboot. Some of the features mentioned
521 here can also be combined, so it is e.g. possible to immediately reboot the
522 system after the flash has been written.
523
524 Mostly, similar to the sample usage shown in the help output should be all that
525 has to be done to write the firmware to flash:
526 \begin{Verbatim}[label=write a previously downloaded new firmware-file into flash]
527 # mtd -e linux -r write freewrt.bin linux &
528 \end{Verbatim}
529 Or via wget pipe:
530 \begin{Verbatim}[label=download and write a new firmware-file into flash]
531 # wget -O - http://www.yourserver.com/freewrt.bin | mtd -e linux -r write - linux &
532 \end{Verbatim}
533 The parameters explained in detail:
534 \begin{description}
535 \item[\command{-e linux}] erase existing data in flash
536 \item[\command{-r}] trigger rebooting right after finishing work
537 \item[\command{write}] write the firmware image contained in the file
538 given as next parameter to flash
539 \item[\command{freewrt.bin}] the actual image to write -- ignore the
540 suffix, it is detected at runtime
541 \item[\command{linux}] this is an abstract identifier for a certain
542 partition in flash, so don't change this
543 \item[\command{\&}] put the process into background, to prevent
544 accidentally stopping
545 \end{description}
546
547 \subsection{Installation using TFTP}\label{sec:tftp}
548
549 All supported target devices are shipped with a builtin bootloader, comparable
550 to the BIOS of \term{x86} machines. This bootloader is used to bootstrap the
551 system until it can boot a regular operating system. Besides the ability to
552 load the executable code from flash, it can be received from another node in
553 the local area network via the famous TFTP protocol.
554
555 For doing this, there are two ways:
556 \begin{itemize}
557 \item the device acts as a client, asks the local \app{dhcpd} for a
558 lease, the address of the next \app{tftpd} and the filename to
559 download
560 \item the device acts as a server, having a known IP address and
561 waiting for any TFTP client to connect and send the file
562 \end{itemize}
563
564 Most of the hardware supported by FreeWRT 1.0 uses the second method. Only the
565 device \term{Netgear WGT634u} is using the first method, the bootloader
566 provides a DHCP/TFTP client. Though this may be a little confusing to people
567 being familiar with netboot technologies, it is definitely the easier way of
568 doing it. Otherwise one had to setup both DHCP and TFTP servers and configure
569 them right.
570
571 The even quite simple task of sending the flash image to the target device is
572 made even more easy by providing a little shell script for the job. Invocation
573 is as follows:
574 \begin{Verbatim}[label=sending the new firmware via TFTP]
575 $ ./scripts/flash.sh firmware.bin [address]
576 \end{Verbatim}
577 The second Parameter \code{address} is used to specify a different IP address
578 of the target device than the default \file{192.168.1.1}.
579
580 \strong{Beware:} do not rename the firmware image before flashing it using the
581 script as the original name is parsed to guess what hardware is to be flashed.
582
583 To actually being able to flash the device, it has to wait for a tftp
584 connection when booting. To complicate installation of third vendor's firmware
585 images and to improve bootup time, of course, this feature is disabled by
586 default. The following list shows what has to be done for a certain device to
587 get it to wait at boot: \\
588 \begin{center}
589 \begin{tabular}{l|l|p{7cm}} % TODO: fill this table
590 \strong{Target Device} & \strong{Action to be taken} & \strong{Comments} \\
591 \hline
592 All supported Linksys models & Ping Exploit & nvram variable \code{boot\_wait}
593 needs to be on \\
594 All supported Asus models & Recovery mode & power off $\rightarrow$ push and
595 hold the reset button $\rightarrow$
596 power on $\rightarrow$ power led is
597 flashing \\
598 \end{tabular}
599 \end{center}
600
601 \chapter{FreeWRT Administration}\label{ch:administration}
602
603 After the FreeWRT firmware image has been built by the ADK and later flashed
604 onto the hardware, the resulting operating system has to be configured. This
605 section provides the necessary information to do that, including tips and
606 guides for using FreeWRT in general, of course.
607
608 \section{Network Configuration}
609
610 The device names for real network interfaces in Linux are named \code{ethx} (\code{x} is
611 \code{0--9}). If the device has a switch, the different ports are separated via VLAN
612 technology. The vlan interfaces are named \code{ethx.y}. The network configuration in
613 FreeWRT is managed via \app{Busybox}'s \app{ifupdown} implementation. \app{Busybox}'s builtin \app{ip}
614 command configures the network interfaces. There is no \app{ifconfig} or \app{route}, you can activate
615 it in the ADK menue, if you like.
616
617 To show all configured network interfaces use:
618 \begin{Verbatim}[label=show IP address]
619 $ ip addr show
620 \end{Verbatim}
621 To show the kernel routing table use:
622 \begin{Verbatim}[label=show routing table]
623 $ ip route show
624 \end{Verbatim}
625
626 All available network settings can be found in \file{/etc/network/interfaces}
627 which has the common form:
628 \begin{Verbatim}[label=common form of \file{/etc/network/interfaces}]
629 auto <iface-name>
630 iface <iface-name> inet <method>
631 <option-x> <value>
632 <option-y> <value>
633 <option-z> <value>
634 \end{Verbatim}
635
636 <b>ATTENTION: Be sure you have no whitespaces at the and of any value!</b>
637
638 \code{auto <iface-name>} is optional and, if set, tells the \app{ifup} script to
639 start this interface automatically on bootup.
640
641 Each interface needs a unique name which, depending on the method, represents
642 either a physical interface or a logical interface name like \code{eth0.1} for
643 a physical VLAN or \code{umts} as a logical name for a PPP interface.
644
645 Possible methods are:
646 \begin{description}
647 \item[static] use the given options to configure the interface
648 statically
649 \item[dhcp] just start a dhcp client using the interface
650 \code{iface-name}
651 \item[manual] don't configure the interface but start \code{pre-up.d}
652 hook scripts
653 \item[ppp] run \code{pon <provider>} where \code{<provider>} is given
654 as an interface option
655 \end{description}
656
657 \subsection{Switch/VLAN}
658 The switch built-in into the most routers is capable of separating each port
659 using VLAN tagging. You can configure the switch by simply adding the interface
660 to the config file and giving the desired switch-ports:
661 \begin{Verbatim}[label=\file{/etc/network/interfaces}]
662 auto eth0.0
663 iface eth0.0 inet static
664 switch-ports 1 2 5*
665 address 192.168.1.1
666 netmask 255.255.255.0
667
668 auto eth0.1
669 iface eth0.1 inet static
670 switch-ports 3 4 5
671 address 192.168.2.1
672 netmask 255.255.255.0
673
674 auto eth0.2
675 iface eth0.2 inet static
676 switch-ports 0 5
677 address 172.16.1.42
678 netmask 255.255.255.0
679 gateway 172.16.1.1
680 \end{Verbatim}
681
682 This configures three VLAN interfaces \code{eth0.0} on ports 1 and 2,
683 \code{eth0.1} on port 3 and 4 and \code{eth0.2} on port 0.
684
685
686 If you need to do some advanced settings, because you have for example a
687 powerful switch with a VLAN trunking port connected to one of your switch
688 ports, the configuration would look like this:
689
690 \begin{Verbatim}[label=\file{/etc/network/interfaces}]
691 auto eth0.1
692 iface eth0.1 inet static
693 switch-ports 2 3 4 5*
694 address 192.168.1.1
695 netmask 255.255.255.0
696
697 auto eth0.2
698 iface eth0.2 inet static
699 switch-ports 1t 5
700 address 10.2.0.1
701 netmask 255.255.255.0
702 broadcast +
703
704 auto eth0.3
705 iface eth0.3 inet static
706 switch-ports 1t 5
707 address 10.3.0.1
708 netmask 255.255.255.0
709 broadcast +
710
711 auto eth0.4
712 iface eth0.4 inet static
713 switch-ports 1t 5
714 address 10.4.0.1
715 netmask 255.255.255.0
716 broadcast +
717
718 \end{Verbatim}
719
720 This configures four VLAN interfaces, \code{eth0.1} on physical ports 2, 3 and
721 4. The interfaces \code{eth0.2}, \code{eth0.3} and \code{eth0.4} are three
722 different networks with VLAN ID 2--4. The physical port 1 needs to be connected
723 to a VLAN trunking port on a switch with knows the same VLAN IDs.
724
725
726 Explanation:
727 \begin{description}
728 \item[port 0] this is typically the port labeled as WAN
729 \item[port 1--4] these are typically the ports labeled as LAN
730 \item[port 5] this special port represents the port where the
731 router--board is connected to the switch
732 \item[*] one interface always need an asterisk behind port 5 which
733 means it is the default interface and gets all the packages
734 with unknown tags.
735 \end{description}
736
737 \subsection{Static IP configuration}
738 As you can see in the VLAN example three interfaces were configured with static
739 IP settings, so these are the commonly used options:
740 \begin{description}
741 \item[address] the IP address --- required
742 \item[netmask] the netmask --- required
743 \item[broadcast] broadcast address --- only required for legacy
744 applications (if using \code{+}, it will be calculated
745 automatically by the kernel)
746 \item[gateway] an IP address added as default gateway if present
747 \item[mac-address] if you need to change your MAC address (required for
748 some DSL providers)
749 \end{description}
750
751 \subsection{DHCP}
752 That's just as simple as:
753 \begin{Verbatim}[label=\file{/etc/network/interfaces}]
754 auto eth0.1
755 iface eth0.1 inet dhcp
756 switch-ports 0 5
757 \end{Verbatim}
758 Typically this configures the WAN-Port to start a DHCP request on bootup.
759
760 \subsection{WLAN}
761 A router containing a WLAN interface has an additional ethernet device
762 representing it. On Broad\-com-based hardware it is typically \code{eth1}
763 (\term{Linksys}),\code{eth2} (\term{Asus WL500gP}) or on \term{Netgear WGT634u}
764 which has a Madwifi WLAN chip, it is \code{ath0}, \code{ath1}, etc. You can use
765 these interfaces standalone or bridged with other devices, e.g. the internal
766 LAN.
767
768 \subsubsection{Basic Settings}
769
770 Mandatory options and default parameters are in bold font.
771
772 \begin{tabular}{l|l|p{10cm}}
773 \strong{Option} & \strong{Parameter} & \strong{Description} \\
774 \hline\hline
775 \code{\strong{type}} & \code{broadcom} & Broadcom based card \\
776 & \code{atheros} & Madwifi driver \\
777 \hline
778 \code{\strong{mode}} & \code{ap} & Access point mode \\
779 & \code{sta} & Client mode \\
780 & \code{adhoc} & Ad-Hoc mode \\
781 & \code{wds} & WDS point-to-point link over wireless\\
782 & \code{monitor} & The node acts as a passive monitor and
783 only receives packets \\
784 \hline
785 \code{\strong{ssid}} & \code{<String>} & Set the SSID (Network Name) \\
786 \hline
787 \code{country} & \code{\{ALL|DE|JP|US|\ldots\}} & The country code used
788 to determine the
789 regulatory settings. \\
790 \hline
791 \end{tabular}
792
793 \subsubsection{Security Settings}
794 \begin{longtable}{l|l|p{10cm}}
795 \strong{Option} & \strong{Parameter} & \strong{Description} \\
796 \hline\hline
797 \code{\strong{security}} & \code{none} & No authorization \\
798 & \code{wep} & WEP key \\
799 & \code{wpa-psk} & WPA with preshared key \\
800 & \code{8021x} & IEEE 802.1X authentication \\
801 \hline
802 \code{\strong{authorization}} & & \strong{wpa-psk} \\
803 & \code{psk} & WPA PSK \\
804 & \code{psk2} & WPA2 PSK \\
805 & \code{psk psk2} & WPA PSK and WPA2 PSK \\
806 & & \strong{8021x} \\
807 & \code{wpa} & WPA with RADIUS \\
808 & \code{wpa2} & WPA2 with RADIUS \\
809 & \code{wpa wpa2} & WPA and WPA2 \\
810 \hline
811 \code{\strong{encryption}} & & \strong{wep} \\
812 & --- & not needed, automatically by key size \\
813 & & \strong{wpa-psk} \\
814 & \code{tkip} & RC4 encryption \\
815 & \code{aes} & AES encryption \\
816 & \code{aes+tkip} & support both \\
817 & & \strong{8021x} \\
818 & \code{wep} & RC4 encryption (static) \\
819 & \code{tkip} & RC4 encryption \\
820 & \code{aes} & AES encryption \\
821 & \code{aes+tkip} & support both \\
822 \hline
823 \code{eap-type} & & \strong{8021x} \\
824 & \code{\strong{tls}} & Transport Layer Security \\
825 & \code{ttls} & Tunnelled TLS \\
826 & \code{peap} & Protected EAP \\
827 & \code{leap} & Cisco Wireless \\
828 \hline
829 \code{key} & & \strong{wep} \\
830 &\code{\{\strong{1}|2|3|4\}} & Select WEP key to use. \\
831 \hline
832 \code{key[1..4]} & & \strong{wep} \\
833 & \code{<String>} & WEP key. The key must be 5, 13 or 16
834 bytes long, or 10, 26, 32, or 64 hex
835 digits long. The encryption algorithm is
836 automatically selected based on the key
837 size. key1 is the key for WEP client mode.
838 \\
839 \hline
840 \code{wpa-key} & & \strong{wpa-psk} \\
841 & <String> & Password to use with WPA/WPA2 PSK (at least 8, up
842 to 63 chars) \\
843 \hline
844 \code{wpa-gtk-rekey} & & \strong{wpa-psk},
845 \strong{8021x} \\
846 & \code{<Int>} (\strong{3600}) & Rekeying interval in
847 seconds. \\
848 \hline
849 \code{\strong{radius-ipaddr}} & & \strong{8021x} \\
850 & \code{<a.b.c.d>} & IP to connect. \\
851 \hline
852 \code{radius-port} & & \strong{8021x} \\
853 & \code{<Int>} (\strong{1812}) & RADIUS-Port no. to connect
854 \\
855 \hline
856 \strong{radius-key} & & \strong{8021x} \\
857 & \code{<String>} & Shared Secret for connection to the
858 Radius server \\
859 \hline
860 \end{longtable}
861
862 \subsubsection{MAC filter}
863 \begin{tabular}{l|l|p{10cm}}
864 \strong{Option} & \strong{Parameter} & \strong{Description} \\
865 \hline\hline
866 \code{macmode} & \code{\{0|1|2\}} & 0: Disable MAC address matching. \\
867 & & 1: Deny association to stations on the MAC
868 list. \\
869 & & 2: Allow association to stations on the MAC
870 list. \\
871 \hline
872 \code{maclist} & \code{<MAC1> \ldots <MACn>} & List of space separated mac
873 addresses to allow/deny
874 according to \code{macmode}.
875 Addresses should be entered with
876 colons, e.g.:
877 "\code{00:02:2D:08:E2:1D
878 00:03:3E:05:E1:1B}"\\
879 \end{tabular}
880
881 \subsubsection{Wireless Distribution System (WDS)}
882 \begin{tabular}{l|l|p{10cm}}
883 \strong{Option} & \strong{Parameter} & \strong{Description} \\
884 \hline\hline
885 \code{lazywds} & \code{\{0|1\}} & Accept WDS connections
886 from anyone \\
887 \hline
888 \code{wds-bridge} & \code{br\{X\}} & Add WDS peers to bridge
889 brX \\
890 \hline
891 \code{wds-security} & \code{\{wpa-psk\}} & secure the wds bridge
892 with WPA (optional)\\
893 \hline
894 \code{wds-encryption} & \code{\{aes|tkip\}} & Use AES or TKIP as
895 cipher\\
896 \hline
897 \code{wds-wpa-key} & \code{<String>} & Password to use with WPA
898 PSK (at least 8, up to 63
899 chars) \\
900 \hline
901 \code{wds} & \code{<MAC1> \ldots <MACn>} & List of WDS peer mac
902 addresses
903 (\code{xx:xx:xx:xx:xx:xx},
904 space separated) \\
905 \hline
906 \end{tabular}
907
908 \subsubsection{Miscellaneous}
909 \begin{longtable}{l|l|p{10cm}}
910 \strong{Option} & \strong{Parameter} & \strong{Description} \\
911 \hline\hline
912 \code{channel} & \code{\{1--14\}} & The wifi channel \\
913 \hline
914 \code{maxassoc} & \code{\{1--255\}} & Maximum number of associated clients \\
915 \hline
916 % TODO: add descriptions to the different gmode settings
917 \code{gmode} & & Set the 54g Mode \\
918 & \code{\strong{Auto}} & default \\
919 & \code{LegacyB} & \\
920 & \code{GOnly} & \\
921 & \code{BDeferred} & \\
922 & \code{Performance} & \\
923 & \code{LRS} & \\
924 \hline
925 \code{frameburst} & \code{\{\strong{0}|1\}} & Disable/Enable frameburst mode. \\
926 \hline
927 \code{txpower} & \code{\{0--255|\strong{$-1$}\}} & Set the transmit power in dBm \\
928 \hline
929 \code{rate} & \code{<Int> (\strong{$-1$})} & force a fixed rate \\
930 & & valid values for 802.11a are (6,
931 9, 12, 18, 24, 36, 48, 54) \\
932 & & valid values for 802.11b are (1,
933 2, 5.5, 11) \\
934 & & valid values for 802.11g are (1,
935 2, 5.5, 6, 9, 11, 12, 18, 24, 36,
936 48, 54) \\
937 & & $-1$ means automatically determine
938 the best rate \\
939 \hline
940 \code{rts} & \code{\{0-2347\}} & Set the RTS threshhold. \\
941 \hline
942 \code{frag} & \code{\{256-2346\}} & Set the fragmentation
943 threshhold. \\
944 \hline
945 \code{afterburner} & \code{\{\strong{0}|1\}} & Enable Afterburner capability
946 \\
947 \hline
948 \code{isolate} & \code{\{\strong{0}|1\}} & Hide Clients from each other \\
949 \hline
950 \code{bridge-if} & \code{\{br0..brX\}} & The bridge interface (optional)
951 \\
952 \hline
953 \end{longtable}
954
955 \subsubsection{Examples for wireless configuration}
956
957 \paragraph{WLAN with WPA1/WPA2 AES+TKIP}
958
959 This combination works with any kind of WPA client implementation.
960
961 \begin{Verbatim}[label=\file{/etc/network/interfaces}]
962 auto eth1
963 iface eth1 inet static
964 address 192.168.10.1
965 netmask 255.255.255.0
966 broadcast +
967 wireless-type broadcom
968 wireless-country DE
969 wireless-mode ap
970 wireless-ssid FreeWRT
971 wireless-security wpa-psk
972 wireless-authorization psk psk2
973 wireless-encryption aes+tkip
974 wireless-wpa-key 12345678
975 wireless-channel 11
976 \end{Verbatim}
977
978 If you want to do MAC filtering, add the following to the sample above:
979 \begin{Verbatim}[label=\file{/etc/network/interfaces}]
980 wireless-macmode 2
981 wireless-mac 00:01:02:03:04:05 06:07:08:09:0a:0b
982 \end{Verbatim}
983 this enables the filter and defines the list to contain addresses that should be allowed.
984
985 \paragraph{WLAN without encryption}
986
987 If you already use VPN to secure your connection, you can just use an unencrypted setup
988 and setup the firewall on your embedded device.
989
990 \begin{Verbatim}[label=\file{/etc/network/interfaces}]
991 auto eth1
992 iface eth1 inet static
993 address 192.168.10.1
994 netmask 255.255.255.0
995 broadcast +
996 wireless-type broadcom
997 wireless-country DE
998 wireless-mode ap
999 wireless-ssid FreeWRT
1000 wireless-security none
1001 wireless-channel 11
1002 \end{Verbatim}
1003
1004 \paragraph{WLAN client with WPA2 (AES)}
1005
1006 This can only be used in routing mode, you can not bridge it with LAN or WAN interfaces.
1007
1008 \begin{Verbatim}[label=\file{/etc/network/interfaces}]
1009 auto eth1
1010 iface eth1 inet static
1011 address 192.168.10.1
1012 netmask 255.255.255.0
1013 broadcast +
1014 wireless-type broadcom
1015 wireless-country DE
1016 wireless-mode sta
1017 wireless-ssid FreeWRT
1018 wireless-security wpa-psk
1019 wireless-authorization psk2
1020 wireless-encryption aes
1021 wireless-wpa-key 12345678
1022 \end{Verbatim}
1023
1024 WLAN with WDS nodes, the WDS nodes need to have the same
1025 SSID, channel and encryption parameters. The WDS connection is separetely
1026 secured via WPA1 and AES. WPA2 for WDS connection security is \_not\_ working.
1027
1028 WDS node 1 (MAC of Wireless \code{06:05:04:03:02:01})
1029 \begin{Verbatim}[label=\file{/etc/network/interfaces}]
1030 auto br0
1031 iface br0 inet static
1032 bridge-ifaces eth1
1033 address 192.168.10.1
1034 netmask 255.255.255.0
1035 broadcast +
1036 wireless-type broadcom
1037 wireless-country DE
1038 wireless-mode wds
1039 wireless-ssid FreeWRT-WDS
1040 wireless-security wpa-psk
1041 wireless-authorization psk psk2
1042 wireless-encryption aes+tkip
1043 wireless-wpa-key apkey
1044 wireless-lazywds 1
1045 wireless-wds-security wpa-psk
1046 wireless-wds-encryption aes
1047 wireless-wds-wpa-key wdskey
1048 wireless-wds 01:02:03:04:05:06
1049 wireless-wds-bridge br0
1050 \end{Verbatim}
1051 WDS node 2 (MAC of Wireless \code{01:02:03:04:05:06})
1052 \begin{Verbatim}[label=\file{/etc/network/interfaces}]
1053 auto br0
1054 iface br0 inet static
1055 bridge-ifaces eth1
1056 address 192.168.10.2
1057 netmask 255.255.255.0
1058 broadcast +
1059 wireless-type broadcom
1060 wireless-country DE
1061 wireless-mode wds
1062 wireless-ssid FreeWRT-WDS
1063 wireless-security wpa-psk
1064 wireless-authorization psk psk2
1065 wireless-encryption aes+tkip
1066 wireless-wpa-key apkey
1067 wireless-lazywds 1
1068 wireless-wds-security wpa-psk
1069 wireless-wds-encryption aes
1070 wireless-wds-wpa-key wdskey
1071 wireless-wds 06:05:04:03:02:01
1072 wireless-wds-bridge br0
1073 \end{Verbatim}
1074
1075 \paragraph{Peer-to-Peer/AdHoc mode (no encryption, IP must be static)}
1076 \begin{Verbatim}[label=\file{/etc/network/interfaces}]
1077 auto eth1
1078 iface eth1 inet static
1079 address 192.168.10.1
1080 netmask 255.255.255.0
1081 broadcast +
1082 wireless-type broadcom
1083 wireless-country DE
1084 wireless-mode adhoc
1085 wireless-ssid FreeWRT
1086 wireless-security none
1087 wireless-channel 11
1088 \end{Verbatim}
1089
1090 \subsection{Bridging}
1091
1092 This is mostly needed to combine LAN and WLAN to a homogeneous network.
1093 Be sure you have installed the package \app{bridge-utils}.
1094 See the example for a bridging setup, WLAN is secured via WPA/WPA2.
1095
1096 \begin{Verbatim}[label=\file{/etc/network/interfaces}]
1097 auto eth0.0
1098 iface eth0.0 inet manual
1099 switch-ports 1 2 3 4 5*
1100
1101 auto eth1
1102 iface eth1 inet manual
1103 wireless-type broadcom
1104 wireless-country DE
1105 wireless-mode ap
1106 wireless-ssid FreeWRT
1107 wireless-channel 11
1108 wireless-security wpa-psk
1109 wireless-authorization psk psk2
1110 wireless-encryption aes+tkip
1111 wireless-wpa-key MyWlanSecret
1112 wireless-bridge-if br0
1113
1114 auto br0
1115 iface br0 inet static
1116 bridge-ifaces eth0.0 eth1
1117 address 192.168.1.1
1118 netmask 255.255.255.0
1119 broadcast +
1120 \end{Verbatim}
1121
1122 This creates a new bridging interface \code{br0} which combines the VLAN
1123 interface \code{eth0.0} (representing the LAN-ports 1--4) and the WLAN interface
1124 \code{eth1} (on some devices like \term{Asus WL500gP} this might be \code{eth2}).
1125 The bridge interface needs always be the last one, otherwise it can not find
1126 the interfaces in \code{bridge-ifaces}.
1127
1128 \subsection{PPP}
1129
1130 PPP comes in various flavours for different situations, the most commonly
1131 needed will likely be DSL and for \term{WRT54G3G} users UMTS. So there exists a
1132 hook-script that evaluates a \code{use-template} option and generates a
1133 ppp-peer. This way everything needed so far can be configured within the
1134 \code{interfaces} file. Be sure you have installed the packages \app{kmod-ppp},
1135 \app{ppp} and \app{ppp-mod-pppoe}. For providers using PPTP for authentication,
1136 instead of PPPoE, you need to install \app{pptp}.
1137
1138 \subsubsection{DSL with PPPoE}
1139 \begin{Verbatim}[label=\file{/etc/network/interfaces}]
1140 auto ppp0
1141 iface ppp0 inet ppp
1142 use-template dsl
1143 provider foobar
1144 ppp-username 1234567890121234567890120001@bar.de
1145 ppp-password bar
1146 ppp-device eth0.1
1147 \end{Verbatim}
1148
1149 Now your DSL connection will be started on boot (\code{auto ppp0}) and you can
1150 manually shut it down with \command{ifdown ppp0} or start it up with
1151 \command{ifup ppp0}. The template \code{dsl} will configure a typical PPPoE
1152 peer for you.
1153
1154 \subsubsection{DSL with PPTP}
1155 \begin{Verbatim}[label=\file{/etc/network/interfaces}]
1156 auto ppp0
1157 iface ppp0 inet ppp
1158 use-template pptp
1159 provider foobar
1160 ppp-username foo
1161 ppp-password bar
1162 ppp-modemip 10.0.0.1
1163 ppp-mtu 1480
1164 ppp-device eth0.1
1165 \end{Verbatim}
1166
1167 Now your DSL connection will be started on boot (\code{auto ppp0}) and you can
1168 manually shut it down with \command{ifdown ppp0} or start it up with
1169 \command{ifup ppp0}. The template \code{pptp} will configure a typical PPTP
1170 peer for you.
1171
1172 \subsubsection{UMTS}
1173 Same footprint different template and some specific options. That is all that
1174 is needed for an UMTS connection to Vodafone as it can be seen in this example.
1175 \begin{Verbatim}[label=\file{/etc/network/interfaces}]
1176 iface ppp0 inet ppp
1177 use-template umts
1178 provider umts
1179 #ppp-username ""
1180 #ppp-password ""
1181 ppp-device /dev/noz0
1182 umts-apn web.vodafone.de
1183 umts-pincode 1234
1184 umts-mode umts_first
1185 \end{Verbatim}
1186 As you can see: unneeded options like \code{ppp-username} or
1187 \code{ppp-password} can just be removed or commented out. Don't leave them
1188 without a value as that causes a failure in \app{ipup}. It does work if you
1189 give empty double quotes as value like \code{""}.
1190
1191 Note that you have to set the correct APN, username and password for your
1192 provider!
1193
1194 You may also remove the pin from your SIM-card and the configuration if you
1195 like.
1196
1197 For \term{Linksys WRT54G3G} a package called \app{broadcom-watchbutton} will be
1198 installed, this is a small daemon that monitors the UMTS-button of the router
1199 and executes \command{ifup umts} or \command{ifdown umts} on a button press.
1200 You have to set \code{watchbutton=YES} in /etc/rc.conf to have it start
1201 automatically.
1202
1203 This is totally independent from the \code{auto umts} setting. Even if you
1204 start the connection on bootup you can shut it down again with a button press.
1205
1206 \subsection{custom interface hooks}
1207 \subsubsection{per interface}
1208 You can execute various commands on interface startup or shutdown with special
1209 option:
1210 \begin{Verbatim}[label=\file{/etc/network/interfaces}]
1211 iface foobar inet static
1212 [...]
1213 pre-up <command>
1214 up <command>
1215 up <command>
1216 down <command>
1217 post-down <command>
1218 \end{Verbatim}
1219
1220 You can give each option multiple times and their commands will be executed in
1221 given order.
1222 \begin{description}
1223 \item[pre-up] before the interface will be started
1224 \item[up] after the interface was started successfully
1225 \item[down] before the interface goes down
1226 \item[post-down] after the interface shut down
1227 \end{description}
1228
1229 \subsubsection{general hooks}
1230 Additionally you can write scripts executed for each interface if you put them
1231 in
1232 \begin{itemize}
1233 \item \texttt{/etc/network/if-pre-up.d}
1234 \item \texttt{/etc/network/if-up.d}
1235 \item \texttt{/etc/network/if-down.d}
1236 \item \texttt{/etc/network/if-post-down.d}
1237 \end{itemize}
1238 Same semantics as above.
1239
1240
1241 \section{Traffic Control}
1242
1243 To aid in setting up Quality of Service and Traffic Shaping, FreeWRT provides a
1244 configurable script via the \app{fwrtc} package. Though this package will allow
1245 you to choose between different implementations of Queueing Disciplines, for
1246 now there exists only a single implementation using HTB.
1247
1248 \subsection{Concept}
1249
1250 In general, \app{fwrtc} allows classifying of network traffic into three classes:
1251 \begin{description}
1252 \item[REAL] high priority, mid bandwidth \\
1253 use this for low delay applications like \app{SSH}, \app{VoIP}
1254 or \app{DNS}
1255 \item[BULK] mid priority, high bandwidth \\
1256 this is a generic class for everything that doesn't fit above
1257 or below
1258 \item[P2P] low priority, low bandwidth \\
1259 use this class for all unwanted traffic disturbing normal use
1260 of the internet connection (\app{P2P} and other parasites)
1261 \end{description}
1262
1263 \paragraph{Note} that fwrtc does not actually classify the traffic, it just
1264 provides the classes above and allows comfortable configuration of the
1265 necessary values. For classifying traffic, use \app{iptables} (see below for
1266 more details).
1267
1268 \subsection{Installation}
1269
1270 This is done just like with any other FreeWRT package, so using the ADK to
1271 integrate it into the firmware image right from the start or by installing it
1272 afterwards using \app{ipkg}.
1273
1274 \subsection{Configuration}
1275
1276 \app{fwrtc} basically exists of two files:
1277 \begin{itemize}
1278 \item the script itself \file{/etc/hotplug.d/net/10-fwrtc}
1279 \item a configuration file \file{/etc/fwrtc.conf}
1280 \end{itemize}
1281 It should not be necessary to touch the hotplug script, so adjusting the
1282 configuration values should be enough to complete the first part of the setup
1283 process.
1284
1285 The second part consists of defining \app{iptables} rules for classifying
1286 traffic. \app{fwrtc} provides three \app{tc}-filters (one for each class),
1287 matching different firewall marks (see the \code{MARK} target of
1288 \app{iptables}).
1289
1290 See the example below to gather some inspiration on how to actually
1291 implementing the rules:
1292
1293 \begin{Verbatim}[label=sample set of iptables rules for fwrtc]
1294 iptables -t mangle -A POSTROUTING -o eth0 -j tc
1295
1296 ### match ip tos Minimum-Delay
1297 iptables -t mangle -A tc -m tos --tos 0x10 -j MARK --set-mark 0x1
1298 iptables -t mangle -A tc -m tos --tos 0x10 -j RETURN
1299
1300 ## fish out tcp syn, syn-ack and ack packets (no piggyback!)
1301 iptables -t mangle -A tc -p tcp -m length --length 44:84 \
1302 --tcp-flags SYN,FIN,RST SYN -j MARK --set-mark 0x1
1303 iptables -t mangle -A tc -p tcp -m length --length 44:84 \
1304 --tcp-flags SYN,FIN,RST SYN -j RETURN
1305 iptables -t mangle -A tc -p tcp -m length --length 44:84 \
1306 --tcp-flags SYN,ACK,FIN,RST ACK -j MARK --set-mark 0x1
1307 iptables -t mangle -A tc -p tcp -m length --length 44:84 \
1308 --tcp-flags SYN,ACK,FIN,RST ACK -j RETURN
1309
1310 ### prioritize icmp packets
1311 iptables -t mangle -A tc -p icmp -j MARK --set-mark 0x1
1312 iptables -t mangle -A tc -p icmp -j RETURN
1313
1314 ### dns traffic
1315 iptables -t mangle -A tc -p tcp --dport 53 -j MARK --set-mark 0x1
1316 iptables -t mangle -A tc -p tcp --dport 53 -j RETURN
1317 iptables -t mangle -A tc -p udp --dport 53 -j MARK --set-mark 0x1
1318 iptables -t mangle -A tc -p udp --dport 53 -j RETURN
1319
1320 ### games
1321 iptables -t mangle -A tc -m layer7 --l7proto quake-halflife -j MARK --set-mark 0x1
1322 iptables -t mangle -A tc -m layer7 --l7proto quake-halflife -j RETURN
1323 iptables -t mangle -A tc -m layer7 --l7proto battlefield1942 -j MARK --set-mark 0x1
1324 iptables -t mangle -A tc -m layer7 --l7proto battlefield1942 -j RETURN
1325 iptables -t mangle -A tc -m layer7 --l7proto battlefield2 -j MARK --set-mark 0x1
1326 iptables -t mangle -A tc -m layer7 --l7proto battlefield2 -j RETURN
1327
1328 ### voip
1329 iptables -t mangle -A tc -m layer7 --l7proto sip -j MARK --set-mark 0x1
1330 iptables -t mangle -A tc -m layer7 --l7proto sip -j RETURN
1331 iptables -t mangle -A tc -m layer7 --l7proto rtp -j MARK --set-mark 0x1
1332 iptables -t mangle -A tc -m layer7 --l7proto rtp -j RETURN
1333 iptables -t mangle -A tc -m layer7 --l7proto skypetoskype -j MARK --set-mark 0x1
1334 iptables -t mangle -A tc -m layer7 --l7proto skypetoskype -j RETURN
1335
1336 ### crappy p2p traffic
1337 iptables -t mangle -A tc -m layer7 --l7proto bittorrent -j MARK --set-mark 0x3
1338 iptables -t mangle -A tc -m layer7 --l7proto bittorrent -j RETURN
1339 iptables -t mangle -A tc -m layer7 --l7proto edonkey -j MARK --set-mark 0x3
1340 iptables -t mangle -A tc -m layer7 --l7proto edonkey -j RETURN
1341 iptables -t mangle -A tc -m layer7 --l7proto fasttrack -j MARK --set-mark 0x3
1342 iptables -t mangle -A tc -m layer7 --l7proto fasttrack -j RETURN
1343 iptables -t mangle -A tc -m layer7 --l7proto gnutella -j MARK --set-mark 0x3
1344 iptables -t mangle -A tc -m layer7 --l7proto gnutella -j RETURN
1345 iptables -t mangle -A tc -m layer7 --l7proto napster -j MARK --set-mark 0x3
1346 iptables -t mangle -A tc -m layer7 --l7proto napster -j RETURN
1347 \end{Verbatim}
1348
1349 \section{FWCF - FreeWRT Configuration Filesystem}
1350
1351 FWCF is a separate flash partition for all changes made to the \file{/etc/}
1352 directory. There is a small tool named \app{fwcf}, which is used to setup the
1353 system or to commit changes to the fwcf partition.
1354
1355 On bootup the script \file{/sbin/mount\_root} is executed, which calls
1356 \command{fwcf setup} to setup \file{/etc/} as memory filesystem and overlay the
1357 changes committed to the fwcf partition.
1358
1359 If you change anything in \file{/etc/} and like to keep the change, it is
1360 required to execute \command{fwcf commit}. This will compress all changed or
1361 new files in \file{/etc/} and write the result into the fwcf partition. The
1362 fwcf partition is 128 Kb in size. This size is not changeable at the moment.
1363
1364 If you need more detailed information, please read the specification of FWCF,
1365 which can be found at
1366 \url{http://www.freewrt.org/trac/wiki/Documentation/Specs/FwCf}
1367
1368 If you want to remove all your changes and start your configuration from
1369 scratch, use \command{fwcf erase}. This is also required if you switch between
1370 compression plugins. Right now LZO plugin is default.
1371
1372 \section{IPKG - Packagemanagement}
1373
1374 All software for FreeWRT is available as a IPKG package. IPKG is a package
1375 manager very similar to Debian's \app{dpkg/apt-get} utilities. It is specially
1376 designed for embedded systems and is widely used. The FreeWRT project use a
1377 special version, which is embedded to the busybox binary. Normally the command
1378 line tool \app{ipkg} is pre-installed.
1379
1380 IPKG uses a configuration file similar to \file{/etc/apt/sources.list}, which
1381 contains a list of software repositories available via HTTP or FTP. The
1382 configuration file \file{/etc/ipkg.conf} contains the official FreeWRT 1.0
1383 repository for your board and kernel version.
1384
1385 To update the list of available packages execute following command as root:
1386 \begin{Verbatim}[label=update list of available packages]
1387 # ipkg update
1388 \end{Verbatim}
1389
1390 This command requires a working internet connection, because it will fetch a
1391 package list from every repository declared in \file{/etc/ipkg.conf}.
1392
1393 To install a new package use following command:
1394 \begin{Verbatim}[label=example installation of \app{tcpdump}]
1395 # ipkg install tcpdump
1396 \end{Verbatim}
1397
1398 This will install the package \app{tcpdump} and all dependencies onto the
1399 flash. Where the data is saved depends on the root filesystem you decided to
1400 use while installing FreeWRT. If you use jffs2 as root filesystem, then the
1401 package is installed on the big linux partition. If you use squashfs-overlay,
1402 then the package is installed on the mini-fo overlay filesystem which writes
1403 its data to the jffs2 data partition. If you use a squashfs-symlinks
1404 filesystem, then the package data is directly install into the jffs2 data
1405 partition, containing symlinks to the read-only squashfs partition.
1406
1407 You can also remove packages, but this is only useful if you are using jffs2 as
1408 root filesystem:
1409 \begin{Verbatim}[label=example removal of \app{tcpdump}]
1410 # ipkg remove tcpdump
1411 \end{Verbatim}
1412
1413 This will not remove any dependencies, installed earlier. For example,
1414 \app{libpcap} is still installed after executing this command. On jffs2 root
1415 filesystem you should never remove any essential packages like \app{busybox},
1416 \app{fwcf} or \app{uclibc}, otherwise you make the embedded system unusable.
1417
1418 Nearly the same as for removing packages, counts for \command{ipkg upgrade}.
1419 Please \strong{never ever} use \command{ipkg upgrade} to update your embedded
1420 system. This command is only useful to upgrade single packages on a jffs2
1421 rootfilesystem or data partition.
1422
1423 \section{Startup scripts}
1424
1425 Some of the available packages containing software which start services at boot
1426 time. For that we provide simple startup scripts, which are installed into the
1427 directory \file{/etc/init.d}. See following example for the package
1428 \app{dnsmasq}, a combined dns and dhcp server daemon:
1429
1430 \begin{Verbatim}[label=\file{/etc/init.d/S50dnsmasq}]
1431 #!/bin/sh
1432
1433 . /etc/rc.conf
1434
1435 case $1 in
1436 autostart)
1437 test x"${dns_dhcp:-NO}" = x"NO" && exit 0
1438 exec $0 start
1439 ;;
1440 start)
1441 [ -f /etc/dnsmasq.conf ] || exit
1442 /usr/sbin/dnsmasq
1443 ;;
1444 stop)
1445 killall dnsmasq
1446 ;;
1447 restart)
1448 $0 stop
1449 $0 start
1450 ;;
1451 *)
1452 echo "Usage: $0 {start | stop | restart}"
1453 ;;
1454 esac
1455 exit 0
1456 \end{Verbatim}
1457
1458 After installation the package postinst script will add all needed changes to
1459 the \file{/etc/} directory. For example packages can add new user and groups,
1460 add new variables to \file{/etc/rc.conf} or just add new values to existing
1461 files as \file{/etc/services}. It is FreeWRT policy not to start any services
1462 after installation or in case of a new boot. To start services on bootup you
1463 need to set \code{\$servicename=YES} in \file{/etc/rc.conf} and commit your
1464 changes via \command{fwcf commit}. For every policy exists an exception, we
1465 start all essential services by default, like ssh daemon, syslog and network
1466 initialisation.
1467
1468 For some services you can control the startup behaviour by modifying the
1469 \code{\$servicename\_flags} variable in \file{/etc/rc.conf}.
1470
1471 For example the variable \code{\$ssh\_opts} is provided as an argument to the
1472 dropbear ssh daemon to control its behaviour.
1473
1474 Having this policy helps you to configure your FreeWRT embedded system without
1475 shooting yourself in the foot. For example if you try to realize a firewall
1476 system and trying to set the rules in \file{/etc/firewall.user}, which is read
1477 by \file{/etc/init.d/S45firewall}, if the iptables package is installed. You
1478 can just reload the changed ruleset via \code{/etc/init.d/S45firewall restart}.
1479 If you managed to kick you out of the system, you can just reboot the system
1480 and you gain access again. As soon as your are ready with the firewall
1481 configuration and you decide to activate the firewall rules on bootup, you set
1482 \code{firewall=YES} in \file{/etc/rc.conf}, commit your changes via
1483 \command{fwcf commit} and reboot. Now the firewall rules will be activated on
1484 bootup.
1485
1486 \section{Network Logging}
1487
1488 Administered networks often make use of a central Log Server to store the
1489 SysLog output of the local servers. This is also a good approach when setting
1490 up a Log Analyser or IDS.
1491
1492 To enable sending SysLog output via network for \command{syslogd}, simply alter
1493 it's flags in \file{/etc/rc.conf}. Use \code{-R Host[:Port]} to send all
1494 messages to \code{Host}, and \code{Port} (optional). To keep the messages
1495 locally also, give \code{-L} as additional flag.
1496
1497 \section{Accessing USB storage devices}
1498
1499 Many routers now ship with USB onboard, which makes them fine for dealing as a
1500 fileserver. If you have such a device and want to setup your own low--cost NAS,
1501 follow the instructions below.
1502
1503 \subsection{Firmware image preparation}
1504
1505 What you need is:
1506 \begin{itemize}
1507 \item kernel support for \code{usb-storage}
1508 \item kernel support for the filesystem(s) to be used, e.g. \code{xfs}
1509 \item optionally: \app{lsusb} to check for attached devices
1510 \end{itemize}
1511
1512 When all prerequisites are met, all that has to be done is to connect the USB
1513 mass storage device to the USB port of the router. FreeWRT provides a
1514 hotplugging script which mounts all connected partitions under
1515 \file{/mnt/discN\_Y} while \code{N} is the index of the connected disk (i.e.
1516 starting with 0) and \code{Y} is the number of the partition on the disk (i.e.
1517 starting with 1).
1518
1519 \subsection{Sharing storage via NFS}
1520
1521 There are two implementations available, one residing in kernel space and
1522 another one implemented purely in user space. If you wish to use the user space
1523 implementation of NFS, just enable \app{nfs-server}. To use the kernel
1524 implementation of NFS, activate \app{nfs-utils} for your target. Although
1525 kernel space is somewhat faster, this implementation has the drawback that only
1526 directory structures within a single mount point can be exported. So you have
1527 to supply at least a single entry for each mounted partition in
1528 \file{/etc/exports}. (Using the user space \app{nfsd}, you can also export the
1529 complete \file{/mnt} directory.
1530
1531 \begin{Verbatim}[label=sample /etc/exports]
1532 /mnt/disc0_1 *(ro,no_root_squash,insecure,no_subtree_check)
1533 /mnt/disc0_2 *(rw,root_squash,insecure,no_subtree_check)
1534 \end{Verbatim}
1535
1536 Finally, start \app{portmap} and \app{knfsd} (\app{nfsd} when using the user
1537 space implementation):
1538 \begin{Verbatim}[label=starting the daemons]
1539 # /etc/init.d/portmap start
1540 # /etc/init.d/knfsd start
1541 \end{Verbatim}
1542
1543 \chapter{Troubleshooting}\label{ch:troubleshooting}
1544
1545 \section{Failsafe Mode}
1546
1547 Failsafe mode is very useful if you misconfigured your embedded system, so that
1548 you can not access it anymore. E.g. if you accidentially disabled secure shell
1549 or misconfigured the firewall, so that you can not login any more.
1550
1551 When in failsafe mode, the device won't interpret any networking setup files.
1552 It stops even before the root filesystem gets mounted read--write, and fwcf is
1553 set up. It will just set the LAN interface up and give it the IP address
1554 \file{192.168.1.1} and netmask \file{255.255.255.0}. Then it will start a
1555 \app{telnet} daemon, so you get straight access (without depending on the
1556 installed SSH daemon).
1557
1558 \subsection{How It Works}
1559
1560 To get FreeWRT into failsafe mode you need physical access to the device and
1561 the failsafe utility. The failsafe utility is built inside our ADK and is
1562 available in the directory \file{bin/} after a successful build.
1563
1564 If you just want to compile the tool and not a complete firmware image, use
1565 following command:
1566
1567 \begin{Verbatim}[label=building the failsafe utility for the host system]
1568 $ make subdir=tools/failsafe install
1569 \end{Verbatim}
1570
1571 For some operating systems we provide ready to go binaries of failsafe.
1572 Take a look at \url{http://www.freewrt.org/downloads/tools/failsafe}
1573
1574 The tool just opens a network socket and waits for a special UDP packet
1575 from the embedded device. FreeWRT sends the UDP packet via the first
1576 recognized network interface (eth0).
1577
1578 \subsection{Enabling Failsafe Mode}
1579
1580 Connect your computer to the embedded system via direct or crossed network
1581 cable. Use the failsafe port (in most cases one of the LAN ports), see the
1582 device specific page for the exact network port.
1583
1584 Configure your network interface to the IP address \file{192.168.1.2} with
1585 network mask \file{255.255.255.0}. Now start the failsafe utility on your
1586 computer.
1587
1588 \begin{Verbatim}
1589 $ ./failsafe
1590 \end{Verbatim}
1591
1592 After that power on your embedded system and wait for the following message in
1593 your failsafe application running on your computer:
1594
1595 \begin{Verbatim}
1596 Press reset now to enter Failsafe!
1597 \end{Verbatim}
1598
1599 As soon as this message is displayed you should push the reset button of
1600 your embedded system. You have 2 seconds time to push the button. If you
1601 successfully enabled the failsafe mode, following message will be displayed:
1602
1603 \begin{Verbatim}
1604 Entering Failsafe!
1605 \end{Verbatim}
1606
1607 Now you should be able to login to your embedded system via a telnet
1608 application. Just use:
1609
1610 \begin{Verbatim}
1611 $ telnet 192.168.1.1
1612 \end{Verbatim}
1613
1614 \subsection{Repairing Your FreeWRT Configuration}
1615
1616 If you want to repair your configuration, you first need to mount the root
1617 filesystem read--writeable. This is best done via:
1618
1619 \begin{Verbatim}
1620 # mount_root
1621 \end{Verbatim}
1622
1623 After that you need to enable the FreeWRT configuration filesystem:
1624
1625 \begin{Verbatim}
1626 # fwcf setup
1627 \end{Verbatim}
1628
1629 Now you can change files in \file{/etc/} and repair your broken configuration.
1630 Do not forget to commit your changes afterwards.
1631
1632 \begin{Verbatim}
1633 # fwcf commit
1634 \end{Verbatim}
1635
1636 If you want to start over with the default \file{/etc/} directory, just remove
1637 the fwcf partition content with following command:
1638
1639 \begin{Verbatim}
1640 mtd erase fwcf
1641 \end{Verbatim}
1642
1643 You can either use \command{reboot -f} or the option \command{-r} for \app{mtd}
1644 to reboot the system.
1645
1646 %\section{Serial Console}
1647
1648 %\section{JTAG}
1649
1650 % Erstmal auskommentieren. Sind ja paar Seiten die erstmal keiner braucht
1651 %\begin{appendix}
1652 %\include{A-blaetter}
1653 %\end{appendix}
1654
1655 %\cleardoublepage
1656 %\addcontentsline{toc}{chapter}{\glossaryname}
1657 \end{document}

Properties

Name Value
svn:keywords Id

root@freewrt.org:443
ViewVC Help
Powered by ViewVC 1.1.20