netsniff-ng: Remove locally declared labels
[netsniff-ng.git] / INSTALL
blobd828f39f1179889bd68e0dbd9b1ce373d013d16d
1 Currently only operating systems running on Linux kernels with the option
2 CONFIG_PACKET_MMAP enabled. This feature can be found even back to the days of
3 2.4 kernels. Most operating systems ship pre-compiled kernels that have this
4 config option enabled and even the latest kernel versions got rid of this
5 option and have this functionality already built-in. However, we recommend a
6 kernel >= 2.6.31, because the TX_RING is officially integrated since then. In
7 any case, if you have the possibility, consider getting the latest kernel from
8 Linus' Git repository, tweak and compile it, and run this one!
10 A note for distribution package maintainers can be found at the end of the file.
12 What additional tools next to your build-chain are required?
14  - ccache (optional)
15  - gpg (optional)
17  - pkg-config:             all
18  - flex, bison:            bpfc, trafgen
20 What libraries are required?
22  - libncurses:             ifpps, flowtop
23  - libGeoIP >=1.4.8:       astraceroute, flowtop, netsniff-ng
24  - libz:                   astraceroute, flowtop, netsniff-ng
25  - libnacl or libsodium:   curvetun
26  - libnetfilter-conntrack: flowtop
27  - libpcap:                mausezahn, netsniff-ng (tcpdump-like filters)
28  - liburcu:                flowtop
29  - libnl3:                 netsniff-ng, trafgen
30  - libcli:                 mausezahn
31  - libnet:                 mausezahn
33 What additional tools are recommended, but not mandatory after the build?
35  - cpp:                    trafgen
36  - ntpd:                   curvetun
37  - gnuplot:                ifpps
38  - setcap:                 all
40 It is common, that these libraries are shipped as distribution packages
41 for an easy installation. We try to keep this as minimal as possible.
43 One-liner installation for *all* dependencies on Debian:
45   $ sudo apt-get install ccache flex bison libnl-3-dev \
46   libnl-genl-3-dev libgeoip-dev libnetfilter-conntrack-dev \
47   libncurses5-dev liburcu-dev libnacl-dev libpcap-dev \
48   zlib1g-dev libcli-dev libnet1-dev
50 One-liner installation for *all* dependencies on Fedora:
52   $ sudo yum install ccache flex bison ccache libnl3-devel \
53   GeoIP-devel libnetfilter_conntrack-devel ncurses-devel \
54   userspace-rcu-devel nacl-devel libpcap-devel zlib-devel \
55   libcli-devel libnet-devel
57 After downloading the netsniff-ng toolkit, you should change to the
58 repository root directory:
60   $ cd netsniff-ng/
62 The installation (deinstallation) process is fairly simple:
64   $ ./configure
65   $ make
66   # make install
68   (# make uninstall)
70 In order to remove all build files from the source tree:
72   $ make clean
74 In any case "make help" will give you some pointers of what can be done.
75 To bring the source tree into a pristine state, there are two options.
76 The first one will remove all build and build config file, the latter will
77 also remove any manually added files:
79   $ make distclean
80   ($ make mrproper)
82 You can also build/install/uninstall only a particular tool, e.g.:
84   $ make trafgen
85   # make trafgen_install
87   (# make trafgen_uninstall)
89 If you want to build all tools, but {curvetun,mausezahn} (i.e. because you
90 don't need the tunneling software and the NaCl build process lasts quite long):
92   $ make allbutcurvetun               (allbutmausezahn)
93   # make install_allbutcurvetun       (install_allbutmausezahn)
95   (# make uninstall)
97 In order to build curvetun, libnacl must be built first. A helper script
98 called nacl_build.sh is there to facilitate this process. If you want to
99 build NaCl in the directory ~/nacl, the script should be called this way:
101   $ cd curvetun
102   $ ./nacl_build.sh ~/nacl
104 There's also an abbreviation for this by simply typing:
106   $ make nacl
108 This gives an initial output such as "Building NaCl for arch amd64 on host
109 fuuubar (grab a coffee, this takes a while) ...". If the automatically
110 detected architecture (such as amd64) is not the one you intend to compile
111 for, then edit the (cc="gcc") variable within the nacl_build.sh script to
112 your cross compiler. Yes, we know, the build system of NaCl is a bit of a
113 pain, so you might check for a pre-built package from your distribution in
114 case you are not cross compiling.
116 If NaCl already has been built on the target, it is quicker to use
117 nacl_path.sh this way:
119   $ cd curvetun
120   $ ./nacl_path.sh ~/nacl/build/include/x86 ~/nacl/build/lib/x86
122 Instead of libnacl you can also use libsodium which itself is a portable,
123 cross-compilable, API compatible drop-in replacement for libnacl.
125 In order to use libsodium you need to provide some little help when running
126 the configure script, so it will be able to detect the needed header files.
127 Additionally you need to configure the build to not link against libnacl
128 but against libsodium.
130 In the case libsodium was installed into /usr/local you run the netsniff-ng
131 configure script this way:
133   $ NACL_INC_DIR=/usr/local/include/sodium NACL_LIB=sodium ./configure
135 Alternatively you can use pkg-config for determining the include dir by
136 setting the NACL_INC_DIR variable for the configure script like this:
138   $ NACL_INC_DIR=$(pkg-config --variable=includedir libsodium )/sodium
140 When done, netsniff-ng's build infrastructure will read those evironment
141 variables in order to get the needed paths to NaCl.
143 If you're unsure with any make targets, check out: make help
145 In order to run the toolkit as a normal user, set the following privilege
146 separation after the build/installation:
148   $ sudo setcap cap_net_raw,cap_ipc_lock,cap_sys_admin,cap_net_admin=eip {toolname}
150 For cross-compiling netsniff-ng, the process is fairly simple. Assuming you
151 want to build netsniff-ng for the Microblaze architecture, update the PATH
152 variable first, e.g.:
154   $ export PATH=<cc-tools-path>/microblazeel-unknown-linux-gnu/bin:$PATH
156 And then, build the toolkit like this:
158   $ make CROSS_COMPILE=microblazeel-unknown-linux-gnu- \
159          CROSS_LD_LIBRARY_PATH=<cc-lib-search-path>
161 Note that some adaptations might be necessary regarding the CFLAGS, since not
162 all might be supported by a different architecture. Probably the most simple
163 way would be to run make CFLAGS="-O2 -Wall".
165 For power users we have a set of zsh auto completion files, have a look at all
166 file with ending *.zsh. There's also a BPF vim syntax highlighting file in the
167 tree called bpf.vim.
169 For doing a debug build of the toolkit with less optimizations and non-stripped
170 symbols, do:
172   $ make DEBUG=1
174 For debugging the build system, actual commands are verbosly shown if every
175 make target is executed with:
177   $ make Q=
179 Concerning packaging the toolkit for a Linux distribution, by default,
180 netsniff-ng has some architecture-specific tuning options enabled that don't
181 belong into a package binary of a distribution. Hence, you might want to build
182 the toolkit with:
184   $ make DISTRO=1
186 A hardening option is also available via HARDENING=1 if needed. You can then
187 build and install the toolkit into prefixed path like:
189   $ make PREFIX=<path-prefix-for-package>
190   $ make PREFIX=<path-prefix-for-package> install
192 Additionally to setting the PREFIX you can set DESTDIR if you want to install
193 the toolkit outside of your current root filesystem but into an alternative
194 path. This is particularly useful when cross-compiling because most likely
195 you want to install into a dedicated sandbox or into a mounted root filesystem
196 for the target architecture and not into the build hosts root filesystem.
198   $ make PREFIX=<path-prefix-for-package> DESTDIR=<alternative-rootfs> install
200 Thanks for maintaining netsniff-ng in your distribution. Further questions will
201 be answered on the public mailing list.
203 Last but not least, there is one small utility for advanced users that we have
204 not integrated into the main build process. This is a minimal BPF JIT image
205 disassembler for the Linux kernel. You can also find this tool in the Linux
206 kernel Git tree under 'tools/net/bpf_jit_disasm.c' or within the netsniff-ng
207 Git tree simply under 'bpf_jit_disasm.c'. To build it, execute:
209     $ gcc -Wall -O2 bpf_jit_disasm.c -o bpf_jit_disasm -lopcodes -lbfd -ldl
211 The rest is described in the file header comment itself, i.e. how to get to the
212 BPF JIT code.