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 3806 - (show annotations) (download) (as text)
Tue Oct 7 15:16:18 2008 UTC (5 years, 4 months ago) by tg
File MIME type: application/x-tex
File size: 65330 byte(s)
ok, svn:// does not work, svn+ssh:// does work (dev only),
https:// and http:// work, but I don’t know if https is public

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

Properties

Name Value
svn:keywords Id

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