gnunet-arm -s is required as normal user too
[oweals/gnunet.git] / doc / handbook / chapters / installation.texi
1 @node Installing GNUnet
2 @chapter Installing GNUnet
3
4 This guide is intended for those who want to install Gnunet from
5 source. For instructions on how to install GNUnet as a binary package
6 please refer to the official documentation of your operating system or
7 package manager.
8
9 For understanding this guide properly it is important to know that
10 there are two different ways of running GNUnet:
11
12 @itemize @bullet
13 @item the @emph{single-user setup}
14 @item the @emph{multi-user setup}
15 @end itemize
16
17 The latter variant has a better security model and requires extra preparation
18 before running @code{make install} and a different configuration. Beginners who want to
19 quickly try out GNUnet can use the @emph{single-user setup}.
20
21 @menu
22 * Installing dependencies::
23 * Getting the Source Code::
24 * Create user and groups for the system services::
25 * Preparing and Compiling the Source Code::
26 * Installation::
27 * Minimal configuration::
28 * Checking the Installation::
29 * The graphical configuration interface::
30 * Config Leftovers::
31 @end menu
32
33 @c -----------------------------------------------------------------------
34 @node Installing dependencies
35 @section Installing dependencies
36 GNUnet needs few libraries and applications for being able to run and
37 another few optional ones for using certain features. Preferably they
38 should be installed with a package manager. Just in case we include a
39 link to the project websites.
40
41 The mandatory libraries and applications are
42 @itemize @bullet
43 @item autoconf 2.59 or above
44 @item automake 1.11.1 or above
45 @item gettext
46 @item glibc (read below, other libcs should work)
47 @item gnutls 3.2.12 or above, recommended to be linked against libunbound
48 @item iptables (on Linux systems)
49 @item libtool 2.2 or above
50 @item libltdl (part of libtool)
51 @item libgcrypt 1.6 or above
52 @item libextractor
53 @item libidn2 or libidn
54 @item libmicrohttpd 0.9.63 or above
55 @item libunistring
56 @item libgmp
57 @item libgnurl or libcurl (libcurl has to be linked to GnuTLS) 7.35.0 or above
58 @item Texinfo 5.2 or above (for building the documentation)
59 @item Texlive 2012 or above (for building the documentation, and for gnunet-bcd)
60 @item makeinfo 4.8 or above
61 @item zlib
62 @end itemize
63
64 Glibc is required for certain NSS features:
65
66 @example
67 One mechanism of integrating GNS with legacy applications via NSS is
68 not available if this is disabled. But applications that don't use the
69 glibc for NS resolution won't work anyway with this, so little is lost
70 on BSD systems.
71 GNS via direct use or via the HTTP or DNS proxies is unaffected.
72 @end example
73
74 Other libcs should work, the resulting builds just don't include the
75 glibc NSS specific code. One example is the build against NetBSD's libc
76 as detailed in @uref{https://bugs.gnunet.org/view.php?id=5605}.
77
78 In addition GNUnet needs one of of these three databases
79 @itemize @bullet
80 @item sqlite + libsqlite 3.8 or above (the default, requires no further configuration)
81 @item postgres + libpq
82 @item mysql + libmysqlclient
83 @end itemize
84
85 These are the dependencies only required for certain features
86 @itemize @bullet
87 @item guile 1.6.4 for gnunet-download-manager
88 @item miniupnpc (for traversing NAT boxes more reliably)
89 @item libnss
90 @item libglpk 4.45 or above for experimental code
91 @item libopus (for running the GNUnet conversation telephony application)
92 @item libpulse (for running the GNUnet conversation telephony application)
93 @item libogg (for running the GNUnet conversation telephony application)
94 @item bluez (for bluetooth support)
95 @item libpbc
96 (for attribute-based encryption and the identity provider subsystem)
97 @item libgabe
98 (for attribute-based encryption and the identity provider subsystem)
99 @item texi2mdoc (for automatic mdoc generation)
100 @item perl5 for some utilities
101 @end itemize
102
103 These are the test suite requirements:
104 @itemize @bullet
105 @item python3.7
106 @item gnunet (installation first)
107 @item which(1)
108 @item a shell (possibly Bash, maybe just POSIX sh)
109 @end itemize
110
111 These are runtime requirements:
112 @itemize @bullet
113 @item nss (the certutil binary, for gnunet-gns-proxy-setup-ca)
114 @item openssl (openssl binary, for gnunet-gns-proxy-setup-ca)
115 @item python2.7 for gnunet-qr (at the moment only python2.7 supported)
116 @item python-zbar 0.10 or above for gnunet-qr
117 @end itemize
118
119 @c -----------------------------------------------------------------------
120 @node Getting the Source Code
121 @section Getting the Source Code
122 You can either download the source code using git (you obviously need
123 git installed) or as an archive.
124
125 Using git type
126 @example
127 git clone https://git.gnunet.org/gnunet.git
128 @end example
129
130 The archive can be found at
131 @uref{https://ftpmirror.gnu.org/gnu/gnunet/}. Extract it using a graphical
132 archive tool or @code{tar}:
133 @example
134 tar xzvf gnunet-@value{VERSION}.tar.gz
135 @end example
136
137 In the next chapter we will assume that the source code is available
138 in the home directory at @code{~/gnunet}.
139
140 @c -----------------------------------------------------------------------
141 @node Create user and groups for the system services
142 @section Create user and groups for the system services
143
144 @cartouche
145 For the single-user setup this section can be skipped.
146 @end cartouche
147
148 The multi-user setup means that there are @emph{system services}, which are
149 run once per machine as a dedicated system user (called @code{gnunet}) and
150 @emph{user services} which can be started by every user who wants to use
151 GNUnet applications. The user services communicate with the system services
152 over unix domain sockets. To gain permissions to read and write those sockets
153 the users running GNUnet applications will need to be in the @code{gnunet}
154 group. In addition the group @code{gnunetdns} may be needed (see below).
155
156 Create user @code{gnunet} who is member of the group @code{gnunet}
157 (automatically created) and specify a home directory where the GNUnet
158 services will store persistant data such as information about peers.
159 @example
160 $ sudo useradd --system --home-dir /var/lib/gnunet --create-home gnunet
161 @end example
162
163 Now add your own user to the @code{gnunet} group.
164
165 @example
166 $ sudo usermod -aG gnunet alice
167 @end example
168
169 Create a group @code{gnunetdns}. This allows using @code{setgid} in a way
170 that only the DNS service can run the @code{gnunet-helper-dns} binary. This 
171 is only needed if @emph{system-wide DNS interception} will be used. For more
172 information see @xref{Configuring system-wide DNS interception}.
173
174 @example
175 $ sudo groupadd gnunetdns
176 @end example
177
178 @c -----------------------------------------------------------------------
179 @node Preparing and Compiling the Source Code
180 @section Preparing and Compiling the Source Code
181 For preparing the source code for compilation a bootstrap script and
182 @code{configure} has to be run from the source code directory. When
183 running @code{configure} the following options can be specified to
184 customize the compilation and installation process:
185
186 @itemize @bullet
187 @item @code{--disable-documentation} - don't build the documentation
188 @item @code{--enable-looging=[LOGLEVEL]} - choose a loglevel (@code{debug}, @code{info}, @code{warning} or @code{error})
189 @item @code{--prefix=[PATH]} - the directory where the GNUnet libraries and binaries will be installed
190 @item @code{--with-extractor=[PATH]} - the path to libextractor
191 @item @code{--with-libidn=[PATH]} - the path to libidn
192 @item @code{--with-libidn2=[PATH]} - the path to libidn2 (takes priority over libidn if both are found)
193 @item @code{--with-microhttpd=[PATH]} - the path to libmicrohttpd
194 @item @code{--with-sqlite=[PATH]} - the path to libsqlite
195 @item @code{--with-zlib=[PATH]} - the path to zlib
196 @item @code{--with-sudo=[PATH]} - path to the sudo binary (no need to run @code{make install} as root if specified)
197 @end itemize
198
199 Note that the list above is not always up to date and you
200 should check the output of @code{./configure --help}, read
201 the @file{configure.ac} or send an email asking for assistance
202 if you are in doubt of any configure options or require fixes
203 for your operating system.
204
205 The following example configures the installation prefix
206 @code{/usr/lib} and disables building the documentation
207 @example
208 $ cd ~/gnunet
209 $ ./bootstrap
210 $ configure --prefix=/usr/lib --disable-documentation
211 @end example
212
213 After running the bootstrap script and @code{configure} successfully
214 the source code can be compiled with make. Here @code{-j5} specifies
215 that 5 threads should be used.
216 @example
217 $ make -j5
218 @end example
219
220 @c -----------------------------------------------------------------------
221 @node Installation
222 @section Installation
223 The compiled binaries can be installed using @code{make install}. It
224 needs to be run as root (or with sudo) because some binaries need the
225 @code{suid} bit set. Without that some features (e.g. the VPN service,
226 system-wide DNS interception, NAT traversal using ICMP) will not work.
227
228 @example
229 $ sudo make install
230 @end example
231
232 @node Extra installation step: NSS plugin
233 @subsection Extra installation step: NSS plugin
234
235 @cartouche
236 The installation of the NSS plugin is only necessary if GNS
237 resolution shall be used with legacy applications (that only
238 support DNS).
239 @end cartouche
240
241 One important library is the GNS plugin for NSS (the name services
242 switch) which allows using GNS (the GNU name system) in the normal DNS
243 resolution process. Unfortunately NSS expects it in a specific
244 location (probably @code{/lib}) which may differ from the installation
245 prefix (see @code{--prefix} option in the previous section). This is
246 why the pugin has to be installed manually.
247
248 Find the directory where nss plugins are installed on your system, e.g.
249
250 @example
251 $ ls -l /lib/libnss_*
252 /lib/libnss_mymachines.so.2
253 /lib/libnss_resolve.so.2
254 /lib/libnss_myhostname.so.2
255 /lib/libnss_systemd.so.2
256 @end example
257
258 Copy the GNS NSS plugin to that directory:
259
260 @example
261 cp ~/gnunet/src/gns/nss/.libs/libnss_gns.so.2 /lib
262 @end example
263
264 Now, to activate the plugin, you need to edit your
265 @code{/etc/nsswitch.conf} where you should find a line like this:
266
267 @example
268 hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
269 @end example
270
271 The exact details may differ a bit, which is fine. Add the text
272 @code{"gns [NOTFOUND=return]"} after @code{"files"}.
273
274 @example
275 hosts: files gns [NOTFOUND=return] mdns4_minimal [NOTFOUND=return] dns mdns4
276 @end example
277
278 @node Extra installation step: installing the GNS Certificate Authority
279 @subsection Extra installation step: installing the GNS Certificate Authority
280
281 @cartouche
282 Installing the GNS certificate authority is only necessary if GNS shall
283 be used in a browser.
284 @end cartouche
285
286 The GNS Certificate authority can provide TLS certificates for GNS names while
287 downloading webpages from legacy webservers. This allows browsers to use HTTPS
288 in combinations with GNS name resolution. 
289
290 To install it execute the GNS CA-setup script. So far Firefox and Chromium are
291 supported.
292
293 @example
294 $ gnunet-gns-proxy-setup-ca
295 @end example
296
297 A local proxy server, that takes care of the name resolution and provides
298 certificates on-the-fly needs to be started:
299
300 @example
301 $ /usr/lib/gnunet/libexec/gnunet-gns-proxy
302 @end example
303
304 Now GNS should work in browsers that are configured to use a SOCKS proxy on
305 @code{localhost:7777}.
306
307
308 @node Minimal configuration
309 @section Minimal configuration
310 GNUnet needs a configuration file to start. For the @emph{single-user setup}
311 an empty file is sufficient:
312
313 @example
314 $ touch ~/.config/gnunet.conf
315 @end example
316
317 For the @emph{multi-user setup} we need an extra config file for the system
318 services. The default location is @code{/etc/gnunet.conf}. The minimal
319 content of that file which activates the system services roll is:
320
321 @example
322 [arm]
323 START_SYSTEM_SERVICES = YES
324 START_USER_SERVICES = NO
325 @end example
326
327 The config file for the user services (@code{~/.config/gnunet.conf}) needs
328 the opposite configuration to activate the user services roll:
329
330 @example
331 [arm]
332 START_SYSTEM_SERVICES = NO
333 START_USER_SERVICES = YES
334 @end example
335
336
337 @node Checking the Installation
338 @section Checking the Installation
339
340
341 This section describes a quick, casual way to check if your GNUnet
342 installation works. However, if it does not, we do not cover
343 steps for recovery --- for this, please study the instructions
344 provided in the developer handbook as well as the system-specific
345 instruction in the source code repository.
346 Please note that the system specific instructions are not provided
347 as part of this handbook!
348
349
350 @menu
351 * Starting GNUnet::
352 * gnunet-gtk::
353 * Statistics::
354 * Peer Information::
355 @end menu
356
357 @cindex Starting GNUnet
358 @cindex GNUnet GTK
359 @cindex GTK
360 @cindex GTK user interface
361
362 @node Starting GNUnet
363 @subsection Starting GNUnet
364 The GNUnet services are started and stopped by the ARM service (Automatic
365 Restart Manager). For the @emph{single-user setup} a simple 
366
367 @example
368 $ gnunet-arm -s
369 @end example
370
371 starts a default set of services. Later GNUnet applications can request more
372 services to start without additional user interaction. GNUnet can be stopped
373 again using the @code{-e} option:
374
375 @example
376 $ gnunet-arm -e
377 @end example
378
379 The list of running services can be displayed using the @code{-I} option.
380 It should look similar to this example:
381
382 @example
383 $ gnunet-arm -I
384 Running services:
385 topology (gnunet-daemon-topology)
386 nat (gnunet-service-nat)
387 vpn (gnunet-service-vpn)
388 gns (gnunet-service-gns)
389 cadet (gnunet-service-cadet)
390 namecache (gnunet-service-namecache)
391 hostlist (gnunet-daemon-hostlist)
392 revocation (gnunet-service-revocation)
393 ats (gnunet-service-ats)
394 peerinfo (gnunet-service-peerinfo)
395 zonemaster (gnunet-service-zonemaster)
396 zonemaster-monitor (gnunet-service-zonemaster-monitor)
397 dht (gnunet-service-dht)
398 namestore (gnunet-service-namestore)
399 set (gnunet-service-set)
400 statistics (gnunet-service-statistics)
401 nse (gnunet-service-nse)
402 fs (gnunet-service-fs)
403 peerstore (gnunet-service-peerstore)
404 core (gnunet-service-core)
405 rest (gnunet-rest-server)
406 transport (gnunet-service-transport)
407 datastore (gnunet-service-datastore)
408 @end example
409
410 For the @emph{multi-user setup} first the system services need to be started
411 as the system user, i.e. the user @code{gnunet} needs to execute
412 @code{gnunet-arm -s}. This should be done by the system's init system.
413 Then the user who wants to start GNUnet applications has to run
414 @code{gnunet-arm -s} too. It is recommented to automate this, e.g. using
415 the user's crontab.
416
417 @node gnunet-gtk
418 @subsection gnunet-gtk
419
420
421 The @command{gnunet-gtk} package contains several graphical
422 user interfaces for the respective GNUnet applications.
423 Currently these interfaces cover:
424
425 @itemize @bullet
426 @item Statistics
427 @item Peer Information
428 @item GNU Name System
429 @item File Sharing
430 @item Conversation
431 @item Setup
432 @end itemize
433
434 Previously, many of these interfaces were combined into one application
435 called @command{gnunet-gtk}, with different tabs for each interface. This
436 combined application has been removed in version 0.11.0, but each of the
437 interfaces is still available as a standalone application
438 (@command{gnunet-statistics-gtk} for statistics, @command{gnunet-fs-gtk}
439 for filesharing, etc).
440
441 @node Statistics
442 @subsection Statistics
443
444
445 We assume that you have started gnunet via @code{gnunet-arm} or via your
446 system-provided method for starting services.
447 First, you should launch GNUnet's graphical statistics interface.
448 You can do this from the command-line by typing
449
450 @example
451 gnunet-statistics-gtk
452 @end example
453
454 If your peer is running correctly, you should see a bunch
455 of lines, all of which should be ``significantly'' above zero (at
456 least if your peer has been running for more than a few seconds). The
457 lines indicate how many other peers your peer is connected to (via
458 different mechanisms) and how large the entire overlay network is
459 currently estimated to be. The X-axis represents time (in seconds
460 since the start of @command{gnunet-statistics-gtk}).
461
462 You can click on "Traffic" to see information about the amount of
463 bandwidth your peer has consumed, and on "Storage" to check the amount
464 of storage available and used by your peer. Note that "Traffic" is
465 plotted cumulatively, so you should see a strict upwards trend in the
466 traffic.
467
468 The term ``peer'' is a common word used in
469 federated and distributed networks to describe a participating device
470 which is connected to the network. Thus, your Personal Computer or
471 whatever it is you are looking at the Gtk+ interface describes a
472 ``Peer'' or a ``Node''.
473
474 @node Peer Information
475 @subsection Peer Information
476
477
478 First, you should launch the peer information graphical user interface.
479 You can do this from the command-line by typing
480
481 @example
482 $ gnunet-peerinfo-gtk
483 @end example
484
485 Once you have done this, you will see a list of known peers (by the
486 first four characters of their public key), their friend status (all
487 should be marked as not-friends initially), their connectivity (green
488 is connected, red is disconnected), assigned bandwidth, country of
489 origin (if determined) and address information. If hardly any peers
490 are listed and/or if there are very few peers with a green light for
491 connectivity, there is likely a problem with your network
492 configuration.
493
494 @c NOTE: Inserted from Installation Handbook in original ``order'':
495 @c FIXME: Move this to User Handbook.
496 @node The graphical configuration interface
497 @section The graphical configuration interface
498
499 If you also would like to use @command{gnunet-gtk} and
500 @command{gnunet-setup} (highly recommended for beginners), do:
501
502 @menu
503 * Configuring your peer::
504 * Configuring the Friend-to-Friend (F2F) mode::
505 * Configuring the hostlist to bootstrap::
506 * Configuration of the HOSTLIST proxy settings::
507 * Configuring your peer to provide a hostlist ::
508 * Configuring the datastore::
509 * Configuring the MySQL database::
510 * Reasons for using MySQL::
511 * Reasons for not using MySQL::
512 * Setup Instructions::
513 * Testing::
514 * Performance Tuning::
515 * Setup for running Testcases::
516 * Configuring the Postgres database::
517 * Reasons to use Postgres::
518 * Reasons not to use Postgres::
519 * Manual setup instructions::
520 * Testing the setup manually::
521 * Configuring the datacache::
522 * Configuring the file-sharing service::
523 * Configuring logging::
524 * Configuring the transport service and plugins::
525 * Configuring the WLAN transport plugin::
526 * Configuring HTTP(S) reverse proxy functionality using Apache or nginx::
527 * Blacklisting peers::
528 * Configuration of the HTTP and HTTPS transport plugins::
529 * Configuring the GNU Name System::
530 * Configuring the GNUnet VPN::
531 * Bandwidth Configuration::
532 * Configuring NAT::
533 * Peer configuration for distributors (e.g. Operating Systems)::
534 @end menu
535
536 @node Configuring your peer
537 @subsection Configuring your peer
538
539 This chapter will describe the various configuration options in GNUnet.
540
541 The easiest way to configure your peer is to use the
542 @command{gnunet-setup} tool.
543 @command{gnunet-setup} is part of the @command{gnunet-gtk}
544 package. You might have to install it separately.
545
546 Many of the specific sections from this chapter actually are linked from
547 within @command{gnunet-setup} to help you while using the setup tool.
548
549 While you can also configure your peer by editing the configuration
550 file by hand, this is not recommended for anyone except for developers
551 as it requires a more in-depth understanding of the configuration files
552 and internal dependencies of GNUnet.
553
554 @node Configuring the Friend-to-Friend (F2F) mode
555 @subsection Configuring the Friend-to-Friend (F2F) mode
556
557 GNUnet knows three basic modes of operation:
558 @itemize @bullet
559 @item In standard "peer-to-peer" mode,
560 your peer will connect to any peer.
561 @item In the pure "friend-to-friend"
562 mode, your peer will ONLY connect to peers from a list of friends
563 specified in the configuration.
564 @item Finally, in mixed mode,
565 GNUnet will only connect to arbitrary peers if it
566 has at least a specified number of connections to friends.
567 @end itemize
568
569 When configuring any of the F2F ("friend-to-friend") modes,
570 you first need to create a file with the peer identities
571 of your friends. Ask your friends to run
572
573 @example
574 $ gnunet-peerinfo -sq
575 @end example
576
577 @noindent
578 The resulting output of this command needs to be added to your
579 @file{friends} file, which is simply a plain text file with one line
580 per friend with the output from the above command.
581
582 You then specify the location of your @file{friends} file in the
583 @code{FRIENDS} option of the "topology" section.
584
585 Once you have created the @file{friends} file, you can tell GNUnet to only
586 connect to your friends by setting the @code{FRIENDS-ONLY} option
587 (again in the "topology" section) to YES.
588
589 If you want to run in mixed-mode, set "FRIENDS-ONLY" to NO and configure a
590 minimum number of friends to have (before connecting to arbitrary peers)
591 under the "MINIMUM-FRIENDS" option.
592
593 If you want to operate in normal P2P-only mode, simply set
594 @code{MINIMUM-FRIENDS} to zero and @code{FRIENDS_ONLY} to NO.
595 This is the default.
596
597 @node Configuring the hostlist to bootstrap
598 @subsection Configuring the hostlist to bootstrap
599
600 After installing the software you need to get connected to the GNUnet
601 network. The configuration file included in your download is already
602 configured to connect you to the GNUnet network.
603 In this section the relevant configuration settings are explained.
604
605 To get an initial connection to the GNUnet network and to get to know
606 peers already connected to the network you can use the so called
607 "bootstrap servers".
608 These servers can give you a list of peers connected to the network.
609 To use these bootstrap servers you have to configure the hostlist daemon
610 to activate bootstrapping.
611
612 To activate bootstrapping, edit the @code{[hostlist]}-section in your
613 configuration file. You have to set the argument @command{-b} in the
614 options line:
615
616 @example
617 [hostlist]
618 OPTIONS = -b
619 @end example
620
621 Additionally you have to specify which server you want to use.
622 The default bootstrapping server is
623 "@uref{http://v10.gnunet.org/hostlist, http://v10.gnunet.org/hostlist}".
624 [^] To set the server you have to edit the line "SERVERS" in the hostlist
625 section. To use the default server you should set the lines to
626
627 @example
628 SERVERS = http://v10.gnunet.org/hostlist [^]
629 @end example
630
631 @noindent
632 To use bootstrapping your configuration file should include these lines:
633
634 @example
635 [hostlist]
636 OPTIONS = -b
637 SERVERS = http://v10.gnunet.org/hostlist [^]
638 @end example
639
640 @noindent
641 Besides using bootstrap servers you can configure your GNUnet peer to
642 receive hostlist advertisements.
643 Peers offering hostlists to other peers can send advertisement messages
644 to peers that connect to them. If you configure your peer to receive these
645 messages, your peer can download these lists and connect to the peers
646 included. These lists are persistent, which means that they are saved to
647 your hard disk regularly and are loaded during startup.
648
649 To activate hostlist learning you have to add the @command{-e}
650 switch to the @code{OPTIONS} line in the hostlist section:
651
652 @example
653 [hostlist]
654 OPTIONS = -b -e
655 @end example
656
657 @noindent
658 Furthermore you can specify in which file the lists are saved.
659 To save the lists in the file @file{hostlists.file} just add the line:
660
661 @example
662 HOSTLISTFILE = hostlists.file
663 @end example
664
665 @noindent
666 Best practice is to activate both bootstrapping and hostlist learning.
667 So your configuration file should include these lines:
668
669 @example
670 [hostlist]
671 OPTIONS = -b -e
672 HTTPPORT = 8080
673 SERVERS = http://v10.gnunet.org/hostlist [^]
674 HOSTLISTFILE = $SERVICEHOME/hostlists.file
675 @end example
676
677 @node Configuration of the HOSTLIST proxy settings
678 @subsection Configuration of the HOSTLIST proxy settings
679
680 The hostlist client can be configured to use a proxy to connect to the
681 hostlist server.
682 This functionality can be configured in the configuration file directly
683 or using the @command{gnunet-setup} tool.
684
685 The hostlist client supports the following proxy types at the moment:
686
687 @itemize @bullet
688 @item HTTP and HTTP 1.0 only proxy
689 @item SOCKS 4/4a/5/5 with hostname
690 @end itemize
691
692 In addition authentication at the proxy with username and password can be
693 configured.
694
695 To configure proxy support for the hostlist client in the
696 @command{gnunet-setup} tool, select the "hostlist" tab and select
697 the appropriate proxy type.
698 The hostname or IP address (including port if required) has to be entered
699 in the "Proxy hostname" textbox. If required, enter username and password
700 in the "Proxy username" and "Proxy password" boxes.
701 Be aware that this information will be stored in the configuration in
702 plain text (TODO: Add explanation and generalize the part in Chapter 3.6
703 about the encrypted home).
704
705 To provide these options directly in the configuration, you can
706 enter the following settings in the @code{[hostlist]} section of
707 the configuration:
708
709 @example
710 # Type of proxy server,
711 # Valid values: HTTP, HTTP_1_0, SOCKS4, SOCKS5, SOCKS4A, SOCKS5_HOSTNAME
712 # Default: HTTP
713 # PROXY_TYPE = HTTP
714
715 # Hostname or IP of proxy server
716 # PROXY =
717 # User name for proxy server
718 # PROXY_USERNAME =
719 # User password for proxy server
720 # PROXY_PASSWORD =
721 @end example
722
723 @node Configuring your peer to provide a hostlist
724 @subsection Configuring your peer to provide a hostlist
725
726 If you operate a peer permanently connected to GNUnet you can configure
727 your peer to act as a hostlist server, providing other peers the list of
728 peers known to him.
729
730 Your server can act as a bootstrap server and peers needing to obtain a
731 list of peers can contact it to download this list.
732 To download this hostlist the peer uses HTTP.
733 For this reason you have to build your peer with libgnurl (or libcurl)
734 and microhttpd support.
735
736 To configure your peer to act as a bootstrap server you have to add the
737 @command{-p} option to @code{OPTIONS} in the @code{[hostlist]} section
738 of your configuration file.
739 Besides that you have to specify a port number for the http server.
740 In conclusion you have to add the following lines:
741
742 @example
743 [hostlist]
744 HTTPPORT = 12980
745 OPTIONS = -p
746 @end example
747
748 @noindent
749 If your peer acts as a bootstrap server other peers should know about
750 that. You can advertise the hostlist your are providing to other peers.
751 Peers connecting to your peer will get a message containing an
752 advertisement for your hostlist and the URL where it can be downloaded.
753 If this peer is in learning mode, it will test the hostlist and, in the
754 case it can obtain the list successfully, it will save it for
755 bootstrapping.
756
757 To activate hostlist advertisement on your peer, you have to set the
758 following lines in your configuration file:
759
760 @example
761 [hostlist]
762 EXTERNAL_DNS_NAME = example.org
763 HTTPPORT = 12981
764 OPTIONS = -p -a
765 @end example
766
767 @noindent
768 With this configuration your peer will a act as a bootstrap server and
769 advertise this hostlist to other peers connecting to it.
770 The URL used to download the list will be
771 @code{@uref{http://example.org:12981/, http://example.org:12981/}}.
772
773 Please notice:
774
775 @itemize @bullet
776 @item The hostlist is @b{not} human readable, so you should not try to
777 download it using your webbrowser. Just point your GNUnet peer to the
778 address!
779 @item Advertising without providing a hostlist does not make sense and
780 will not work.
781 @end itemize
782
783 @node Configuring the datastore
784 @subsection Configuring the datastore
785
786 The datastore is what GNUnet uses for long-term storage of file-sharing
787 data. Note that long-term does not mean 'forever' since content does have
788 an expiration date, and of course storage space is finite (and hence
789 sometimes content may have to be discarded).
790
791 Use the @code{QUOTA} option to specify how many bytes of storage space
792 you are willing to dedicate to GNUnet.
793
794 In addition to specifying the maximum space GNUnet is allowed to use for
795 the datastore, you need to specify which database GNUnet should use to do
796 so. Currently, you have the choice between sqLite, MySQL and Postgres.
797
798 @node Configuring the MySQL database
799 @subsection Configuring the MySQL database
800
801 This section describes how to setup the MySQL database for GNUnet.
802
803 Note that the mysql plugin does NOT work with mysql before 4.1 since we
804 need prepared statements.
805 We are generally testing the code against MySQL 5.1 at this point.
806
807 @node Reasons for using MySQL
808 @subsection Reasons for using MySQL
809
810 @itemize @bullet
811
812 @item On up-to-date hardware wher
813 mysql can be used comfortably, this module
814 will have better performance than the other database choices (according
815 to our tests).
816
817 @item Its often possible to recover the mysql database from internal
818 inconsistencies. Some of the other databases do not support repair.
819 @end itemize
820
821 @node Reasons for not using MySQL
822 @subsection Reasons for not using MySQL
823
824 @itemize @bullet
825 @item Memory usage (likely not an issue if you have more than 1 GB)
826 @item Complex manual setup
827 @end itemize
828
829 @node Setup Instructions
830 @subsection Setup Instructions
831
832 @itemize @bullet
833
834 @item In @file{gnunet.conf} set in section @code{DATASTORE} the value for
835 @code{DATABASE} to @code{mysql}.
836
837 @item Access mysql as root:
838
839 @example
840 $ mysql -u root -p
841 @end example
842
843 @noindent
844 and issue the following commands, replacing $USER with the username
845 that will be running @command{gnunet-arm} (so typically "gnunet"):
846
847 @example
848 CREATE DATABASE gnunet;
849 GRANT select,insert,update,delete,create,alter,drop,create \
850 temporary tables ON gnunet.* TO $USER@@localhost;
851 SET PASSWORD FOR $USER@@localhost=PASSWORD('$the_password_you_like');
852 FLUSH PRIVILEGES;
853 @end example
854
855 @item
856 In the $HOME directory of $USER, create a @file{.my.cnf} file with the
857 following lines
858
859 @example
860 [client]
861 user=$USER
862 password=$the_password_you_like
863 @end example
864
865 @end itemize
866
867 That's it. Note that @file{.my.cnf} file is a slight security risk unless
868 its on a safe partition. The @file{$HOME/.my.cnf} can of course be
869 a symbolic link.
870 Luckily $USER has only privileges to mess up GNUnet's tables,
871 which should be pretty harmless.
872
873 @node Testing
874 @subsection Testing
875
876 You should briefly try if the database connection works. First, login
877 as $USER. Then use:
878
879 @example
880 $ mysql -u $USER
881 mysql> use gnunet;
882 @end example
883
884 @noindent
885 If you get the message
886
887 @example
888 Database changed
889 @end example
890
891 @noindent
892 it probably works.
893
894 If you get
895
896 @example
897 ERROR 2002: Can't connect to local MySQL server
898 through socket '/tmp/mysql.sock' (2)
899 @end example
900
901 @noindent
902 it may be resolvable by
903
904 @example
905 ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
906 @end example
907
908 @noindent
909 so there may be some additional trouble depending on your mysql setup.
910
911 @node Performance Tuning
912 @subsection Performance Tuning
913
914 For GNUnet, you probably want to set the option
915
916 @example
917 innodb_flush_log_at_trx_commit = 0
918 @end example
919
920 @noindent
921 for a rather dramatic boost in MySQL performance. However, this reduces
922 the "safety" of your database as with this options you may loose
923 transactions during a power outage.
924 While this is totally harmless for GNUnet, the option applies to all
925 applications using MySQL. So you should set it if (and only if) GNUnet is
926 the only application on your system using MySQL.
927
928 @node Setup for running Testcases
929 @subsection Setup for running Testcases
930
931 If you want to run the testcases, you must create a second database
932 "gnunetcheck" with the same username and password. This database will
933 then be used for testing (@command{make check}).
934
935 @node Configuring the Postgres database
936 @subsection Configuring the Postgres database
937
938 This text describes how to setup the Postgres database for GNUnet.
939
940 This Postgres plugin was developed for Postgres 8.3 but might work for
941 earlier versions as well.
942
943 @node Reasons to use Postgres
944 @subsection Reasons to use Postgres
945
946 @itemize @bullet
947 @item Easier to setup than MySQL
948 @item Real database
949 @end itemize
950
951 @node Reasons not to use Postgres
952 @subsection Reasons not to use Postgres
953
954 @itemize @bullet
955 @item Quite slow
956 @item Still some manual setup required
957 @end itemize
958
959 @node Manual setup instructions
960 @subsection Manual setup instructions
961
962 @itemize @bullet
963 @item In @file{gnunet.conf} set in section @code{DATASTORE} the value for
964 @code{DATABASE} to @code{postgres}.
965 @item Access Postgres to create a user:
966
967 @table @asis
968 @item with Postgres 8.x, use:
969
970 @example
971 # su - postgres
972 $ createuser
973 @end example
974
975 @noindent
976 and enter the name of the user running GNUnet for the role interactively.
977 Then, when prompted, do not set it to superuser, allow the creation of
978 databases, and do not allow the creation of new roles.
979
980 @item with Postgres 9.x, use:
981
982 @example
983 # su - postgres
984 $ createuser -d $GNUNET_USER
985 @end example
986
987 @noindent
988 where $GNUNET_USER is the name of the user running GNUnet.
989
990 @end table
991
992
993 @item
994 As that user (so typically as user "gnunet"), create a database (or two):
995
996 @example
997 $ createdb gnunet
998 # this way you can run "make check"
999 $ createdb gnunetcheck
1000 @end example
1001
1002 @end itemize
1003
1004 Now you should be able to start @code{gnunet-arm}.
1005
1006 @node Testing the setup manually
1007 @subsection Testing the setup manually
1008
1009 You may want to try if the database connection works. First, again login
1010 as the user who will run @command{gnunet-arm}. Then use:
1011
1012 @example
1013 $ psql gnunet # or gnunetcheck
1014 gnunet=> \dt
1015 @end example
1016
1017 @noindent
1018 If, after you have started @command{gnunet-arm} at least once, you get
1019 a @code{gn090} table here, it probably works.
1020
1021 @node Configuring the datacache
1022 @subsection Configuring the datacache
1023
1024
1025 The datacache is what GNUnet uses for storing temporary data. This data is
1026 expected to be wiped completely each time GNUnet is restarted (or the
1027 system is rebooted).
1028
1029 You need to specify how many bytes GNUnet is allowed to use for the
1030 datacache using the @code{QUOTA} option in the section @code{[dhtcache]}.
1031 Furthermore, you need to specify which database backend should be used to
1032 store the data. Currently, you have the choice between
1033 sqLite, MySQL and Postgres.
1034
1035 @node Configuring the file-sharing service
1036 @subsection Configuring the file-sharing service
1037
1038 In order to use GNUnet for file-sharing, you first need to make sure
1039 that the file-sharing service is loaded.
1040 This is done by setting the @code{START_ON_DEMAND} option in
1041 section @code{[fs]} to "YES". Alternatively, you can run
1042
1043 @example
1044 $ gnunet-arm -i fs
1045 @end example
1046
1047 @noindent
1048 to start the file-sharing service by hand.
1049
1050 Except for configuring the database and the datacache the only important
1051 option for file-sharing is content migration.
1052
1053 Content migration allows your peer to cache content from other peers as
1054 well as send out content stored on your system without explicit requests.
1055 This content replication has positive and negative impacts on both system
1056 performance and privacy.
1057
1058 FIXME: discuss the trade-offs. Here is some older text about it...
1059
1060 Setting this option to YES allows gnunetd to migrate data to the local
1061 machine. Setting this option to YES is highly recommended for efficiency.
1062 Its also the default. If you set this value to YES, GNUnet will store
1063 content on your machine that you cannot decrypt.
1064 While this may protect you from liability if the judge is sane, it may
1065 not (IANAL). If you put illegal content on your machine yourself, setting
1066 this option to YES will probably increase your chances to get away with it
1067 since you can plausibly deny that you inserted the content.
1068 Note that in either case, your anonymity would have to be broken first
1069 (which may be possible depending on the size of the GNUnet network and the
1070 strength of the adversary).
1071
1072 @node Configuring logging
1073 @subsection Configuring logging
1074
1075 Since version 0.9.0, logging in GNUnet is controlled via the
1076 @code{-L} and @code{-l} options.
1077 Using @code{-L}, a log level can be specified. With log level
1078 @code{ERROR} only serious errors are logged.
1079 The default log level is @code{WARNING} which causes anything of
1080 concern to be logged.
1081 Log level @code{INFO} can be used to log anything that might be
1082 interesting information whereas
1083 @code{DEBUG} can be used by developers to log debugging messages
1084 (but you need to run @code{./configure} with
1085 @code{--enable-logging=verbose} to get them compiled).
1086 The @code{-l} option is used to specify the log file.
1087
1088 Since most GNUnet services are managed by @code{gnunet-arm}, using the
1089 @code{-l} or @code{-L} options directly is not possible.
1090 Instead, they can be specified using the @code{OPTIONS} configuration
1091 value in the respective section for the respective service.
1092 In order to enable logging globally without editing the @code{OPTIONS}
1093 values for each service, @command{gnunet-arm} supports a
1094 @code{GLOBAL_POSTFIX} option.
1095 The value specified here is given as an extra option to all services for
1096 which the configuration does contain a service-specific @code{OPTIONS}
1097 field.
1098
1099 @code{GLOBAL_POSTFIX} can contain the special sequence "@{@}" which
1100 is replaced by the name of the service that is being started.
1101 Furthermore, @code{GLOBAL_POSTFIX} is special in that sequences
1102 starting with "$" anywhere in the string are expanded (according
1103 to options in @code{PATHS}); this expansion otherwise is
1104 only happening for filenames and then the "$" must be the
1105 first character in the option. Both of these restrictions do
1106 not apply to @code{GLOBAL_POSTFIX}.
1107 Note that specifying @code{%} anywhere in the @code{GLOBAL_POSTFIX}
1108 disables both of these features.
1109
1110 In summary, in order to get all services to log at level
1111 @code{INFO} to log-files called @code{SERVICENAME-logs}, the
1112 following global prefix should be used:
1113
1114 @example
1115 GLOBAL_POSTFIX = -l $SERVICEHOME/@{@}-logs -L INFO
1116 @end example
1117
1118 @node Configuring the transport service and plugins
1119 @subsection Configuring the transport service and plugins
1120
1121 The transport service in GNUnet is responsible to maintain basic
1122 connectivity to other peers.
1123 Besides initiating and keeping connections alive it is also responsible
1124 for address validation.
1125
1126 The GNUnet transport supports more than one transport protocol.
1127 These protocols are configured together with the transport service.
1128
1129 The configuration section for the transport service itself is quite
1130 similar to all the other services
1131
1132 @example
1133 START_ON_DEMAND = YES
1134 @@UNIXONLY@@ PORT = 2091
1135 HOSTNAME = localhost
1136 HOME = $SERVICEHOME
1137 CONFIG = $DEFAULTCONFIG
1138 BINARY = gnunet-service-transport
1139 #PREFIX = valgrind
1140 NEIGHBOUR_LIMIT = 50
1141 ACCEPT_FROM = 127.0.0.1;
1142 ACCEPT_FROM6 = ::1;
1143 PLUGINS = tcp udp
1144 UNIXPATH = /tmp/gnunet-service-transport.sock
1145 @end example
1146
1147 Different are the settings for the plugins to load @code{PLUGINS}.
1148 The first setting specifies which transport plugins to load.
1149
1150 @itemize @bullet
1151 @item transport-unix
1152 A plugin for local only communication with UNIX domain sockets. Used for
1153 testing and available on unix systems only. Just set the port
1154
1155 @example
1156 [transport-unix]
1157 PORT = 22086
1158 TESTING_IGNORE_KEYS = ACCEPT_FROM;
1159 @end example
1160
1161 @item transport-tcp
1162 A plugin for communication with TCP. Set port to 0 for client mode with
1163 outbound only connections
1164
1165 @example
1166 [transport-tcp]
1167 # Use 0 to ONLY advertise as a peer behind NAT (no port binding)
1168 PORT = 2086
1169 ADVERTISED_PORT = 2086
1170 TESTING_IGNORE_KEYS = ACCEPT_FROM;
1171 # Maximum number of open TCP connections allowed
1172 MAX_CONNECTIONS = 128
1173 @end example
1174
1175 @item transport-udp
1176 A plugin for communication with UDP. Supports peer discovery using
1177 broadcasts.
1178
1179 @example
1180 [transport-udp]
1181 PORT = 2086
1182 BROADCAST = YES
1183 BROADCAST_INTERVAL = 30 s
1184 MAX_BPS = 1000000
1185 TESTING_IGNORE_KEYS = ACCEPT_FROM;
1186 @end example
1187
1188 @item transport-http
1189 HTTP and HTTPS support is split in two part: a client plugin initiating
1190 outbound connections and a server part accepting connections from the
1191 client. The client plugin just takes the maximum number of connections as
1192 an argument.
1193
1194 @example
1195 [transport-http_client]
1196 MAX_CONNECTIONS = 128
1197 TESTING_IGNORE_KEYS = ACCEPT_FROM;
1198 @end example
1199
1200 @example
1201 [transport-https_client]
1202 MAX_CONNECTIONS = 128
1203 TESTING_IGNORE_KEYS = ACCEPT_FROM;
1204 @end example
1205
1206 @noindent
1207 The server has a port configured and the maximum number of connections.
1208 The HTTPS part has two files with the certificate key and the certificate
1209 file.
1210
1211 The server plugin supports reverse proxies, so a external hostname can be
1212 set using the @code{EXTERNAL_HOSTNAME} setting.
1213 The webserver under this address should forward the request to the peer
1214 and the configure port.
1215
1216 @example
1217 [transport-http_server]
1218 EXTERNAL_HOSTNAME = fulcrum.net.in.tum.de/gnunet
1219 PORT = 1080
1220 MAX_CONNECTIONS = 128
1221 TESTING_IGNORE_KEYS = ACCEPT_FROM;
1222 @end example
1223
1224 @example
1225 [transport-https_server]
1226 PORT = 4433
1227 CRYPTO_INIT = NORMAL
1228 KEY_FILE = https.key
1229 CERT_FILE = https.cert
1230 MAX_CONNECTIONS = 128
1231 TESTING_IGNORE_KEYS = ACCEPT_FROM;
1232 @end example
1233
1234 @item transport-wlan
1235
1236 The next section describes how to setup the WLAN plugin,
1237 so here only the settings. Just specify the interface to use:
1238
1239 @example
1240 [transport-wlan]
1241 # Name of the interface in monitor mode (typically monX)
1242 INTERFACE = mon0
1243 # Real hardware, no testing
1244 TESTMODE = 0
1245 TESTING_IGNORE_KEYS = ACCEPT_FROM;
1246 @end example
1247 @end itemize
1248
1249 @node Configuring the WLAN transport plugin
1250 @subsection Configuring the WLAN transport plugin
1251
1252 The wlan transport plugin enables GNUnet to send and to receive data on a
1253 wlan interface.
1254 It has not to be connected to a wlan network as long as sender and
1255 receiver are on the same channel. This enables you to get connection to
1256 GNUnet where no internet access is possible, for example during
1257 catastrophes or when censorship cuts you off from the internet.
1258
1259
1260 @menu
1261 * Requirements for the WLAN plugin::
1262 * Configuration::
1263 * Before starting GNUnet::
1264 * Limitations and known bugs::
1265 @end menu
1266
1267
1268 @node Requirements for the WLAN plugin
1269 @subsubsection Requirements for the WLAN plugin
1270
1271 @itemize @bullet
1272
1273 @item wlan network card with monitor support and packet injection
1274 (see @uref{http://www.aircrack-ng.org/, aircrack-ng.org})
1275
1276 @item Linux kernel with mac80211 stack, introduced in 2.6.22, tested with
1277 2.6.35 and 2.6.38
1278
1279 @item Wlantools to create the a monitor interface, tested with airmon-ng
1280 of the aircrack-ng package
1281 @end itemize
1282
1283 @node Configuration
1284 @subsubsection Configuration
1285
1286 There are the following options for the wlan plugin (they should be like
1287 this in your default config file, you only need to adjust them if the
1288 values are incorrect for your system)
1289
1290 @example
1291 # section for the wlan transport plugin
1292 [transport-wlan]
1293 # interface to use, more information in the
1294 # "Before starting GNUnet" section of the handbook.
1295 INTERFACE = mon0
1296 # testmode for developers:
1297 # 0 use wlan interface,
1298 #1 or 2 use loopback driver for tests 1 = server, 2 = client
1299 TESTMODE = 0
1300 @end example
1301
1302 @node Before starting GNUnet
1303 @subsubsection Before starting GNUnet
1304
1305 Before starting GNUnet, you have to make sure that your wlan interface is
1306 in monitor mode.
1307 One way to put the wlan interface into monitor mode (if your interface
1308 name is wlan0) is by executing:
1309
1310 @example
1311 sudo airmon-ng start wlan0
1312 @end example
1313
1314 @noindent
1315 Here is an example what the result should look like:
1316
1317 @example
1318 Interface Chipset Driver
1319 wlan0 Intel 4965 a/b/g/n iwl4965 - [phy0]
1320 (monitor mode enabled on mon0)
1321 @end example
1322
1323 @noindent
1324 The monitor interface is mon0 is the one that you have to put into the
1325 configuration file.
1326
1327 @node Limitations and known bugs
1328 @subsubsection Limitations and known bugs
1329
1330 Wlan speed is at the maximum of 1 Mbit/s because support for choosing the
1331 wlan speed with packet injection was removed in newer kernels.
1332 Please pester the kernel developers about fixing this.
1333
1334 The interface channel depends on the wlan network that the card is
1335 connected to. If no connection has been made since the start of the
1336 computer, it is usually the first channel of the card.
1337 Peers will only find each other and communicate if they are on the same
1338 channel. Channels must be set manually, i.e. using:
1339
1340 @example
1341 iwconfig wlan0 channel 1
1342 @end example
1343
1344 @node Configuring HTTP(S) reverse proxy functionality using Apache or nginx
1345 @subsection Configuring HTTP(S) reverse proxy functionality using Apache or nginx
1346
1347 The HTTP plugin supports data transfer using reverse proxies. A reverse
1348 proxy forwards the HTTP request he receives with a certain URL to another
1349 webserver, here a GNUnet peer.
1350
1351 So if you have a running Apache or nginx webserver you can configure it to
1352 be a GNUnet reverse proxy. Especially if you have a well-known webiste
1353 this improves censorship resistance since it looks as normal surfing
1354 behaviour.
1355
1356 To do so, you have to do two things:
1357
1358 @itemize @bullet
1359 @item Configure your webserver to forward the GNUnet HTTP traffic
1360 @item Configure your GNUnet peer to announce the respective address
1361 @end itemize
1362
1363 As an example we want to use GNUnet peer running:
1364
1365 @itemize @bullet
1366
1367 @item HTTP server plugin on @code{gnunet.foo.org:1080}
1368
1369 @item HTTPS server plugin on @code{gnunet.foo.org:4433}
1370
1371 @item A apache or nginx webserver on
1372 @uref{http://www.foo.org/, http://www.foo.org:80/}
1373
1374 @item A apache or nginx webserver on https://www.foo.org:443/
1375 @end itemize
1376
1377 And we want the webserver to accept GNUnet traffic under
1378 @code{http://www.foo.org/bar/}. The required steps are described here:
1379
1380 @menu
1381 * Reverse Proxy - Configure your Apache2 HTTP webserver::
1382 * Reverse Proxy - Configure your Apache2 HTTPS webserver::
1383 * Reverse Proxy - Configure your nginx HTTPS webserver::
1384 * Reverse Proxy - Configure your nginx HTTP webserver::
1385 * Reverse Proxy - Configure your GNUnet peer::
1386 @end menu
1387
1388 @node Reverse Proxy - Configure your Apache2 HTTP webserver
1389 @subsubsection Reverse Proxy - Configure your Apache2 HTTP webserver
1390
1391 First of all you need mod_proxy installed.
1392
1393 Edit your webserver configuration. Edit
1394 @code{/etc/apache2/apache2.conf} or the site-specific configuration file.
1395
1396 In the respective @code{server config},@code{virtual host} or
1397 @code{directory} section add the following lines:
1398
1399 @example
1400 ProxyTimeout 300
1401 ProxyRequests Off
1402 <Location /bar/ >
1403 ProxyPass http://gnunet.foo.org:1080/
1404 ProxyPassReverse http://gnunet.foo.org:1080/
1405 </Location>
1406 @end example
1407
1408 @node Reverse Proxy - Configure your Apache2 HTTPS webserver
1409 @subsubsection Reverse Proxy - Configure your Apache2 HTTPS webserver
1410
1411 We assume that you already have an HTTPS server running, if not please
1412 check how to configure a HTTPS host. An uncomplicated to use example
1413 is the example configuration file for Apache2/HTTPD provided in
1414 @file{apache2/sites-available/default-ssl}.
1415
1416 In the respective HTTPS @code{server config},@code{virtual host} or
1417 @code{directory} section add the following lines:
1418
1419 @example
1420 SSLProxyEngine On
1421 ProxyTimeout 300
1422 ProxyRequests Off
1423 <Location /bar/ >
1424 ProxyPass https://gnunet.foo.org:4433/
1425 ProxyPassReverse https://gnunet.foo.org:4433/
1426 </Location>
1427 @end example
1428
1429 @noindent
1430 More information about the apache mod_proxy configuration can be found
1431 in the
1432 @uref{http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass, Apache documentation}.
1433
1434 @node Reverse Proxy - Configure your nginx HTTPS webserver
1435 @subsubsection Reverse Proxy - Configure your nginx HTTPS webserver
1436
1437 Since nginx does not support chunked encoding, you first of all have to
1438 install the @code{chunkin}
1439 @uref{http://wiki.nginx.org/HttpChunkinModule, module}.
1440
1441 To enable chunkin add:
1442
1443 @example
1444 chunkin on;
1445 error_page 411 = @@my_411_error;
1446 location @@my_411_error @{
1447 chunkin_resume;
1448 @}
1449 @end example
1450
1451 @noindent
1452 Edit your webserver configuration. Edit @file{/etc/nginx/nginx.conf} or
1453 the site-specific configuration file.
1454
1455 In the @code{server} section add:
1456
1457 @example
1458 location /bar/ @{
1459 proxy_pass http://gnunet.foo.org:1080/;
1460 proxy_buffering off;
1461 proxy_connect_timeout 5; # more than http_server
1462 proxy_read_timeout 350; # 60 default, 300s is GNUnet's idle timeout
1463 proxy_http_version 1.1; # 1.0 default
1464 proxy_next_upstream error timeout invalid_header http_500 http_503 http_502 http_504;
1465 @}
1466 @end example
1467
1468 @node Reverse Proxy - Configure your nginx HTTP webserver
1469 @subsubsection Reverse Proxy - Configure your nginx HTTP webserver
1470
1471 Edit your webserver configuration. Edit @file{/etc/nginx/nginx.conf} or
1472 the site-specific configuration file.
1473
1474 In the @code{server} section add:
1475
1476 @example
1477 ssl_session_timeout 6m;
1478 location /bar/
1479 @{
1480 proxy_pass https://gnunet.foo.org:4433/;
1481 proxy_buffering off;
1482 proxy_connect_timeout 5; # more than http_server
1483 proxy_read_timeout 350; # 60 default, 300s is GNUnet's idle timeout
1484 proxy_http_version 1.1; # 1.0 default
1485 proxy_next_upstream error timeout invalid_header http_500 http_503 http_502 http_504;
1486 @}
1487 @end example
1488
1489 @node Reverse Proxy - Configure your GNUnet peer
1490 @subsubsection Reverse Proxy - Configure your GNUnet peer
1491
1492 To have your GNUnet peer announce the address, you have to specify the
1493 @code{EXTERNAL_HOSTNAME} option in the @code{[transport-http_server]}
1494 section:
1495
1496 @example
1497 [transport-http_server]
1498 EXTERNAL_HOSTNAME = http://www.foo.org/bar/
1499 @end example
1500
1501 @noindent
1502 and/or @code{[transport-https_server]} section:
1503
1504 @example
1505 [transport-https_server]
1506 EXTERNAL_HOSTNAME = https://www.foo.org/bar/
1507 @end example
1508
1509 @noindent
1510 Now restart your webserver and your peer...
1511
1512 @node Blacklisting peers
1513 @subsection Blacklisting peers
1514
1515 Transport service supports to deny connecting to a specific peer of to a
1516 specific peer with a specific transport plugin using te blacklisting
1517 component of transport service. With@ blacklisting it is possible to deny
1518 connections to specific peers of@ to use a specific plugin to a specific
1519 peer. Peers can be blacklisted using@ the configuration or a blacklist
1520 client can be asked.
1521
1522 To blacklist peers using the configuration you have to add a section to
1523 your configuration containing the peer id of the peer to blacklist and
1524 the plugin@ if required.
1525
1526 Examples:
1527
1528 To blacklist connections to P565... on peer AG2P... using tcp add:
1529
1530 @c FIXME: This is too long and produces errors in the pdf.
1531 @example
1532 [transport-blacklist AG2PHES1BARB9IJCPAMJTFPVJ5V3A72S3F2A8SBUB8DAQ2V0O3V8G6G2JU56FHGFOHMQVKBSQFV98TCGTC3RJ1NINP82G0RC00N1520]
1533 P565723JO1C2HSN6J29TAQ22MN6CI8HTMUU55T0FUQG4CMDGGEQ8UCNBKUMB94GC8R9G4FB2SF9LDOBAJ6AMINBP4JHHDD6L7VD801G = tcp
1534 @end example
1535
1536 To blacklist connections to P565... on peer AG2P... using all plugins add:
1537
1538 @example
1539 [transport-blacklist-AG2PHES1BARB9IJCPAMJTFPVJ5V3A72S3F2A8SBUB8DAQ2V0O3V8G6G2JU56FHGFOHMQVKBSQFV98TCGTC3RJ1NINP82G0RC00N1520]
1540 P565723JO1C2HSN6J29TAQ22MN6CI8HTMUU55T0FUQG4CMDGGEQ8UCNBKUMB94GC8R9G4FB2SF9LDOBAJ6AMINBP4JHHDD6L7VD801G =
1541 @end example
1542
1543 You can also add a blacklist client usign the blacklist API. On a
1544 blacklist check, blacklisting first checks internally if the peer is
1545 blacklisted and if not, it asks the blacklisting clients. Clients are
1546 asked if it is OK to connect to a peer ID, the plugin is omitted.
1547
1548 On blacklist check for (peer, plugin)
1549
1550 @itemize @bullet
1551 @item Do we have a local blacklist entry for this peer and this plugin?
1552 @item YES: disallow connection
1553 @item Do we have a local blacklist entry for this peer and all plugins?
1554 @item YES: disallow connection
1555 @item Does one of the clients disallow?
1556 @item YES: disallow connection
1557 @end itemize
1558
1559 @node Configuration of the HTTP and HTTPS transport plugins
1560 @subsection Configuration of the HTTP and HTTPS transport plugins
1561
1562 The client parts of the http and https transport plugins can be configured
1563 to use a proxy to connect to the hostlist server. This functionality can
1564 be configured in the configuration file directly or using the
1565 gnunet-setup tool.
1566
1567 Both the HTTP and HTTPS clients support the following proxy types at
1568 the moment:
1569
1570 @itemize @bullet
1571 @item HTTP 1.1 proxy
1572 @item SOCKS 4/4a/5/5 with hostname
1573 @end itemize
1574
1575 In addition authentication at the proxy with username and password can be
1576 configured.
1577
1578 To configure proxy support for the clients in the gnunet-setup tool,
1579 select the "transport" tab and activate the respective plugin. Now you
1580 can select the appropriate proxy type. The hostname or IP address
1581 (including port if required) has to be entered in the "Proxy hostname"
1582 textbox. If required, enter username and password in the "Proxy username"
1583 and "Proxy password" boxes. Be aware that these information will be stored
1584 in the configuration in plain text.
1585
1586 To configure these options directly in the configuration, you can
1587 configure the following settings in the @code{[transport-http_client]}
1588 and @code{[transport-https_client]} section of the configuration:
1589
1590 @example
1591 # Type of proxy server,
1592 # Valid values: HTTP, SOCKS4, SOCKS5, SOCKS4A, SOCKS5_HOSTNAME
1593 # Default: HTTP
1594 # PROXY_TYPE = HTTP
1595
1596 # Hostname or IP of proxy server
1597 # PROXY =
1598 # User name for proxy server
1599 # PROXY_USERNAME =
1600 # User password for proxy server
1601 # PROXY_PASSWORD =
1602 @end example
1603
1604 @node Configuring the GNU Name System
1605 @subsection Configuring the GNU Name System
1606
1607 @menu
1608 * Configuring system-wide DNS interception::
1609 * Configuring the GNS nsswitch plugin::
1610 * Configuring GNS on W32::
1611 * GNS Proxy Setup::
1612 * Setup of the GNS CA::
1613 * Testing the GNS setup::
1614 * Migrating existing DNS zones into GNS::
1615 @end menu
1616
1617
1618 @node Configuring system-wide DNS interception
1619 @subsubsection Configuring system-wide DNS interception
1620
1621 Before you install GNUnet, make sure you have a user and group 'gnunet'
1622 as well as an empty group 'gnunetdns'.
1623
1624 When using GNUnet with system-wide DNS interception, it is absolutely
1625 necessary for all GNUnet service processes to be started by
1626 @code{gnunet-service-arm} as user and group 'gnunet'. You also need to be
1627 sure to run @code{make install} as root (or use the @code{sudo} option to
1628 configure) to grant GNUnet sufficient privileges.
1629
1630 With this setup, all that is required for enabling system-wide DNS
1631 interception is for some GNUnet component (VPN or GNS) to request it.
1632 The @code{gnunet-service-dns} will then start helper programs that will
1633 make the necessary changes to your firewall (@code{iptables}) rules.
1634
1635 Note that this will NOT work if your system sends out DNS traffic to a
1636 link-local IPv6 address, as in this case GNUnet can intercept the traffic,
1637 but not inject the responses from the link-local IPv6 address. Hence you
1638 cannot use system-wide DNS interception in conjunction with link-local
1639 IPv6-based DNS servers. If such a DNS server is used, it will bypass
1640 GNUnet's DNS traffic interception.
1641
1642 Using the GNU Name System (GNS) requires two different configuration
1643 steps.
1644 First of all, GNS needs to be integrated with the operating system. Most
1645 of this section is about the operating system level integration.
1646
1647 The remainder of this chapter will detail the various methods for
1648 configuring the use of GNS with your operating system.
1649
1650 At this point in time you have different options depending on your OS:
1651
1652 @itemize @bullet
1653 @item Use the gnunet-gns-proxy@*
1654 This approach works for all operating systems and is likely the
1655 easiest. However, it enables GNS only for browsers, not for other
1656 applications that might be using DNS, such as SSH.  Still, using the
1657 proxy is required for using HTTP with GNS and is thus recommended for
1658 all users. To do this, you simply have to run the
1659 @code{gnunet-gns-proxy-setup-ca} script as the user who will run the
1660 browser (this will create a GNS certificate authority (CA) on your
1661 system and import its key into your browser), then start
1662 @code{gnunet-gns-proxy} and inform your browser to use the Socks5
1663 proxy which @code{gnunet-gns-proxy} makes available by default on port
1664 7777.
1665 @item Use a nsswitch plugin (recommended on GNU systems)@*
1666 This approach has the advantage of offering fully personalized
1667 resolution even on multi-user systems. A potential disadvantage is
1668 that some applications might be able to bypass GNS.
1669 @item Use a W32 resolver plugin (recommended on W32)@*
1670 This is currently the only option on W32 systems.
1671 @item Use system-wide DNS packet interception@*
1672 This approach is recommended for the GNUnet VPN. It can be used to
1673 handle GNS at the same time; however, if you only use this method, you
1674 will only get one root zone per machine (not so great for multi-user
1675 systems).
1676 @end itemize
1677
1678 You can combine system-wide DNS packet interception with the nsswitch
1679 plugin.
1680 The setup of the system-wide DNS interception is described here. All of
1681 the other GNS-specific configuration steps are described in the following
1682 sections.
1683
1684 @node Configuring the GNS nsswitch plugin
1685 @subsubsection Configuring the GNS nsswitch plugin
1686
1687 The Name Service Switch (NSS) is a facility in Unix-like operating systems
1688 (in most cases provided by the GNU C Library)
1689 that provides a variety of sources for common configuration databases and
1690 name resolution mechanisms.
1691 A superuser (system administrator) usually configures the
1692 operating system's name services using the file
1693 @file{/etc/nsswitch.conf}.
1694
1695 GNS provides a NSS plugin to integrate GNS name resolution with the
1696 operating system's name resolution process.
1697 To use the GNS NSS plugin you have to either
1698
1699 @itemize @bullet
1700 @item install GNUnet as root or
1701 @item compile GNUnet with the @code{--with-sudo=yes} switch.
1702 @end itemize
1703
1704 Name resolution is controlled by the @emph{hosts} section in the NSS
1705 configuration. By default this section first performs a lookup in the
1706 @file{/etc/hosts} file and then in DNS.
1707 The nsswitch file should contain a line similar to:
1708
1709 @example
1710 hosts: files dns [NOTFOUND=return] mdns4_minimal mdns4
1711 @end example
1712
1713 @noindent
1714 Here the GNS NSS plugin can be added to perform a GNS lookup before
1715 performing a DNS lookup.
1716 The GNS NSS plugin has to be added to the "hosts" section in
1717 @file{/etc/nsswitch.conf} file before DNS related plugins:
1718
1719 @example
1720 ...
1721 hosts: files gns [NOTFOUND=return] dns mdns4_minimal mdns4
1722 ...
1723 @end example
1724
1725 @noindent
1726 The @code{NOTFOUND=return} will ensure that if a @code{.gnu} name is not
1727 found in GNS it will not be queried in DNS.
1728
1729 @node Configuring GNS on W32
1730 @subsubsection Configuring GNS on W32
1731
1732 This document is a guide to configuring GNU Name System on W32-compatible
1733 platforms.
1734
1735 After GNUnet is installed, run the w32nsp-install tool:
1736
1737 @example
1738 w32nsp-install.exe libw32nsp-0.dll
1739 @end example
1740
1741 @noindent
1742 ('0' is the library version of W32 NSP; it might increase in the future,
1743 change the invocation accordingly).
1744
1745 This will install GNS namespace provider into the system and allow other
1746 applications to resolve names that end in '@strong{gnu}'
1747 and '@strong{zkey}'. Note that namespace provider requires
1748 gnunet-gns-helper-service-w32 to be running, as well as gns service
1749 itself (and its usual dependencies).
1750
1751 Namespace provider is hardcoded to connect to @strong{127.0.0.1:5353},
1752 and this is where gnunet-gns-helper-service-w32 should be listening to
1753 (and is configured to listen to by default).
1754
1755 To uninstall the provider, run:
1756
1757 @example
1758 w32nsp-uninstall.exe
1759 @end example
1760
1761 @noindent
1762 (uses provider GUID to uninstall it, does not need a dll name).
1763
1764 Note that while MSDN claims that other applications will only be able to
1765 use the new namespace provider after re-starting, in reality they might
1766 stat to use it without that. Conversely, they might stop using the
1767 provider after it's been uninstalled, even if they were not re-started.
1768 W32 will not permit namespace provider library to be deleted or
1769 overwritten while the provider is installed, and while there is at least
1770 one process still using it (even after it was uninstalled).
1771
1772 @node GNS Proxy Setup
1773 @subsubsection GNS Proxy Setup
1774
1775 When using the GNU Name System (GNS) to browse the WWW, there are several
1776 issues that can be solved by adding the GNS Proxy to your setup:
1777
1778 @itemize @bullet
1779
1780 @item If the target website does not support GNS, it might assume that it
1781 is operating under some name in the legacy DNS system (such as
1782 example.com). It may then attempt to set cookies for that domain, and the
1783 web server might expect a @code{Host: example.com} header in the request
1784 from your browser.
1785 However, your browser might be using @code{example.gnu} for the
1786 @code{Host} header and might only accept (and send) cookies for
1787 @code{example.gnu}. The GNS Proxy will perform the necessary translations
1788 of the hostnames for cookies and HTTP headers (using the LEHO record for
1789 the target domain as the desired substitute).
1790
1791 @item If using HTTPS, the target site might include an SSL certificate
1792 which is either only valid for the LEHO domain or might match a TLSA
1793 record in GNS. However, your browser would expect a valid certificate for
1794 @code{example.gnu}, not for some legacy domain name. The proxy will
1795 validate the certificate (either against LEHO or TLSA) and then
1796 on-the-fly produce a valid certificate for the exchange, signed by your
1797 own CA. Assuming you installed the CA of your proxy in your browser's
1798 certificate authority list, your browser will then trust the
1799 HTTPS/SSL/TLS connection, as the hostname mismatch is hidden by the proxy.
1800
1801 @item Finally, the proxy will in the future indicate to the server that it
1802 speaks GNS, which will enable server operators to deliver GNS-enabled web
1803 sites to your browser (and continue to deliver legacy links to legacy
1804 browsers)
1805 @end itemize
1806
1807 @node Setup of the GNS CA
1808 @subsubsection Setup of the GNS CA
1809
1810 First you need to create a CA certificate that the proxy can use.
1811 To do so use the provided script gnunet-gns-proxy-ca:
1812
1813 @example
1814 $ gnunet-gns-proxy-setup-ca
1815 @end example
1816
1817 @noindent
1818 This will create a personal certification authority for you and add this
1819 authority to the firefox and chrome database. The proxy will use the this
1820 CA certificate to generate @code{*.gnu} client certificates on the fly.
1821
1822 Note that the proxy uses libcurl. Make sure your version of libcurl uses
1823 GnuTLS and NOT OpenSSL. The proxy will @b{not} work with libcurl compiled
1824 against OpenSSL.
1825
1826 You can check the configuration your libcurl was build with by
1827 running:
1828
1829 @example
1830 curl --version
1831 @end example
1832
1833 the output will look like this (without the linebreaks):
1834
1835 @example
1836 gnurl --version
1837 curl 7.56.0 (x86_64-unknown-linux-gnu) libcurl/7.56.0 \
1838 GnuTLS/3.5.13 zlib/1.2.11 libidn2/2.0.4
1839 Release-Date: 2017-10-08
1840 Protocols: http https
1841 Features: AsynchDNS IDN IPv6 Largefile NTLM SSL libz \
1842 TLS-SRP UnixSockets HTTPS-proxy
1843 @end example
1844
1845 @node Testing the GNS setup
1846 @subsubsection Testing the GNS setup
1847
1848 Now for testing purposes we can create some records in our zone to test
1849 the SSL functionality of the proxy:
1850
1851 @example
1852 $ gnunet-identity -C test
1853 $ gnunet-namestore -a -e "1 d" -n "homepage" \
1854   -t A -V 131.159.74.67 -z test
1855 $ gnunet-namestore -a -e "1 d" -n "homepage" \
1856   -t LEHO -V "gnunet.org" -z test
1857 @end example
1858
1859 @noindent
1860 At this point we can start the proxy. Simply execute
1861
1862 @example
1863 $ gnunet-arm -i gns-proxy
1864 @end example
1865
1866 To run the proxy at all times in the future, you should
1867 change your configuration as follows:
1868
1869 @example
1870 $ gnunet-config -s gns-proxy -o AUTOSTART -V YES
1871 @end example
1872
1873 @noindent
1874 Configure your browser to use this SOCKSv5 proxy using
1875 @code{localhost} on port 7777.
1876 If you use @command{Firefox} (or one of its derivatives/forks such as
1877 Icecat) you also have to go to @code{about:config} and set the key
1878 @code{network.proxy.socks_remote_dns} to @code{true}.
1879
1880 When you visit @code{https://homepage.test/}, you should get to the
1881 @code{https://gnunet.org/} frontpage and the browser (with the correctly
1882 configured proxy) should give you a valid SSL certificate for
1883 @code{homepage.gnu} and no warnings. It should look like this:
1884
1885 @c FIXME: Image does not exist, create it or save it from Drupal?
1886 @c @image{images/gnunethpgns.png,5in,, picture of homepage.gnu in Webbrowser}
1887
1888 @node Migrating existing DNS zones into GNS
1889 @subsubsection Migrating existing DNS zones into GNS
1890
1891 To migrate an existing zone into GNS use the Ascension tool.
1892
1893 Ascension transfers entire zones into GNS by doing incremental zone transfers
1894 and then adding the records to GNS.
1895
1896 Compared to the gnunet-zoneimport tool it strictly uses AXFR or IXFR depending
1897 on whether or not there exists a SOA record for the zone. If that is the case it
1898 will take the serial as a reference point and request the zone. The server will
1899 either answer the IXFR request with a correct incremental zone or with the
1900 entire zone, which depends on the server configuration.
1901
1902 You can find the source code here: @code{https://git.gnunet.org/ascension.git/}
1903
1904 The software can be installed into a Python virtual environment like this:
1905 @example
1906 $ python3 -m venv .venv
1907 $ source .venv/bin/activate
1908 $ python3 setup.py install
1909 @end example
1910
1911 Or installed globally like this:
1912 @example
1913 $ sudo python3 setup.py install
1914 @end example
1915
1916 Pip will then install all the necessary requirements that are needed to run
1917 Ascension. For development purposes a virtual environment should suffice.
1918 Keeping a virtual environment helps with keeping things tidy and prevents
1919 breaking of Ascension through a future Python update.
1920
1921 The advantage of using a virtual environment is, that all the dependencies can
1922 be installed separately in different versions without touching your systems
1923 Python installation and its dependencies.
1924
1925 Another way to install Ascension on Debian is to install the python3-ascension
1926 package. It can be found within the above mentioned Ascension git repository.
1927 This also adds a system user ascension and runs a GNUnet peer in the
1928 background. Attention: This only works if a recent version of GNUnet is
1929 installed on your system. The version number of Ascension is chosen according
1930 to the required feature level of GNUnet. I.e. Ascension 0.11.5 is only
1931 compatible with GNUnet 0.11.5 and upwards. As Debian's packages for GNUnet are
1932 outdated even in experimental, you will need to install GNUnet manually.
1933 @xref{Installing GNUnet}
1934
1935 Please check @xref{Migrating an existing DNS zone into GNS}, for usage manual
1936 of the tool.
1937
1938 @node Configuring the GNUnet VPN
1939 @subsection Configuring the GNUnet VPN
1940
1941 @menu
1942 * IPv4 address for interface::
1943 * IPv6 address for interface::
1944 * Configuring the GNUnet VPN DNS::
1945 * Configuring the GNUnet VPN Exit Service::
1946 * IP Address of external DNS resolver::
1947 * IPv4 address for Exit interface::
1948 * IPv6 address for Exit interface::
1949 @end menu
1950
1951 Before configuring the GNUnet VPN, please make sure that system-wide DNS
1952 interception is configured properly as described in the section on the
1953 GNUnet DNS setup. @pxref{Configuring the GNU Name System},
1954 if you haven't done so already.
1955
1956 The default options for the GNUnet VPN are usually sufficient to use
1957 GNUnet as a Layer 2 for your Internet connection.
1958 However, what you always have to specify is which IP protocol you want
1959 to tunnel: IPv4, IPv6 or both.
1960 Furthermore, if you tunnel both, you most likely should also tunnel
1961 all of your DNS requests.
1962 You theoretically can tunnel "only" your DNS traffic, but that usually
1963 makes little sense.
1964
1965 The other options as shown on the gnunet-setup tool are:
1966
1967 @node IPv4 address for interface
1968 @subsubsection IPv4 address for interface
1969
1970 This is the IPv4 address the VPN interface will get. You should pick a
1971 'private' IPv4 network that is not yet in use for you system. For example,
1972 if you use @code{10.0.0.1/255.255.0.0} already, you might use
1973 @code{10.1.0.1/255.255.0.0}.
1974 If you use @code{10.0.0.1/255.0.0.0} already, then you might use
1975 @code{192.168.0.1/255.255.0.0}.
1976 If your system is not in a private IP-network, using any of the above will
1977 work fine.
1978 You should try to make the mask of the address big enough
1979 (@code{255.255.0.0} or, even better, @code{255.0.0.0}) to allow more
1980 mappings of remote IP Addresses into this range.
1981 However, even a @code{255.255.255.0} mask will suffice for most users.
1982
1983 @node IPv6 address for interface
1984 @subsubsection IPv6 address for interface
1985
1986 The IPv6 address the VPN interface will get. Here you can specify any
1987 non-link-local address (the address should not begin with @code{fe80:}).
1988 A subnet Unique Local Unicast (@code{fd00::/8} prefix) that you are
1989 currently not using would be a good choice.
1990
1991 @node Configuring the GNUnet VPN DNS
1992 @subsubsection Configuring the GNUnet VPN DNS
1993
1994 To resolve names for remote nodes, activate the DNS exit option.
1995
1996 @node Configuring the GNUnet VPN Exit Service
1997 @subsubsection Configuring the GNUnet VPN Exit Service
1998
1999 If you want to allow other users to share your Internet connection (yes,
2000 this may be dangerous, just as running a Tor exit node) or want to
2001 provide access to services on your host (this should be less dangerous,
2002 as long as those services are secure), you have to enable the GNUnet exit
2003 daemon.
2004
2005 You then get to specify which exit functions you want to provide. By
2006 enabling the exit daemon, you will always automatically provide exit
2007 functions for manually configured local services (this component of the
2008 system is under
2009 development and not documented further at this time). As for those
2010 services you explicitly specify the target IP address and port, there is
2011 no significant security risk in doing so.
2012
2013 Furthermore, you can serve as a DNS, IPv4 or IPv6 exit to the Internet.
2014 Being a DNS exit is usually pretty harmless. However, enabling IPv4 or
2015 IPv6-exit without further precautions may enable adversaries to access
2016 your local network, send spam, attack other systems from your Internet
2017 connection and to other mischief that will appear to come from your
2018 machine. This may or may not get you into legal trouble.
2019 If you want to allow IPv4 or IPv6-exit functionality, you should strongly
2020 consider adding additional firewall rules manually to protect your local
2021 network and to restrict outgoing TCP traffic (i.e. by not allowing access
2022 to port 25). While we plan to improve exit-filtering in the future,
2023 you're currently on your own here.
2024 Essentially, be prepared for any kind of IP-traffic to exit the respective
2025 TUN interface (and GNUnet will enable IP-forwarding and NAT for the
2026 interface automatically).
2027
2028 Additional configuration options of the exit as shown by the gnunet-setup
2029 tool are:
2030
2031 @node IP Address of external DNS resolver
2032 @subsubsection IP Address of external DNS resolver
2033
2034 If DNS traffic is to exit your machine, it will be send to this DNS
2035 resolver. You can specify an IPv4 or IPv6 address.
2036
2037 @node IPv4 address for Exit interface
2038 @subsubsection IPv4 address for Exit interface
2039
2040 This is the IPv4 address the Interface will get. Make the mask of the
2041 address big enough (255.255.0.0 or, even better, 255.0.0.0) to allow more
2042 mappings of IP addresses into this range. As for the VPN interface, any
2043 unused, private IPv4 address range will do.
2044
2045 @node IPv6 address for Exit interface
2046 @subsubsection IPv6 address for Exit interface
2047
2048 The public IPv6 address the interface will get. If your kernel is not a
2049 very recent kernel and you are willing to manually enable IPv6-NAT, the
2050 IPv6 address you specify here must be a globally routed IPv6 address of
2051 your host.
2052
2053 Suppose your host has the address @code{2001:4ca0::1234/64}, then
2054 using @code{2001:4ca0::1:0/112} would be fine (keep the first 64 bits,
2055 then change at least one bit in the range before the bitmask, in the
2056 example above we changed bit 111 from 0 to 1).
2057
2058 You may also have to configure your router to route traffic for the entire
2059 subnet (@code{2001:4ca0::1:0/112} for example) through your computer (this
2060 should be automatic with IPv6, but obviously anything can be
2061 disabled).
2062
2063 @node Bandwidth Configuration
2064 @subsection Bandwidth Configuration
2065
2066 You can specify how many bandwidth GNUnet is allowed to use to receive
2067 and send data. This is important for users with limited bandwidth or
2068 traffic volume.
2069
2070 @node Configuring NAT
2071 @subsection Configuring NAT
2072
2073 Most hosts today do not have a normal global IP address but instead are
2074 behind a router performing Network Address Translation (NAT) which assigns
2075 each host in the local network a private IP address.
2076 As a result, these machines cannot trivially receive inbound connections
2077 from the Internet. GNUnet supports NAT traversal to enable these machines
2078 to receive incoming connections from other peers despite their
2079 limitations.
2080
2081 In an ideal world, you can press the "Attempt automatic configuration"
2082 button in gnunet-setup to automatically configure your peer correctly.
2083 Alternatively, your distribution might have already triggered this
2084 automatic configuration during the installation process.
2085 However, automatic configuration can fail to determine the optimal
2086 settings, resulting in your peer either not receiving as many connections
2087 as possible, or in the worst case it not connecting to the network at all.
2088
2089 To manually configure the peer, you need to know a few things about your
2090 network setup. First, determine if you are behind a NAT in the first
2091 place.
2092 This is always the case if your IP address starts with "10.*" or
2093 "192.168.*". Next, if you have control over your NAT router, you may
2094 choose to manually configure it to allow GNUnet traffic to your host.
2095 If you have configured your NAT to forward traffic on ports 2086 (and
2096 possibly 1080) to your host, you can check the "NAT ports have been opened
2097 manually" option, which corresponds to the "PUNCHED_NAT" option in the
2098 configuration file. If you did not punch your NAT box, it may still be
2099 configured to support UPnP, which allows GNUnet to automatically
2100 configure it. In that case, you need to install the "upnpc" command,
2101 enable UPnP (or PMP) on your NAT box and set the "Enable NAT traversal
2102 via UPnP or PMP" option (corresponding to "ENABLE_UPNP" in the
2103 configuration file).
2104
2105 Some NAT boxes can be traversed using the autonomous NAT traversal method.
2106 This requires certain GNUnet components to be installed with "SUID"
2107 privileges on your system (so if you're installing on a system you do
2108 not have administrative rights to, this will not work).
2109 If you installed as 'root', you can enable autonomous NAT traversal by
2110 checking the "Enable NAT traversal using ICMP method".
2111 The ICMP method requires a way to determine your NAT's external (global)
2112 IP address. This can be done using either UPnP, DynDNS, or by manual
2113 configuration. If you have a DynDNS name or know your external IP address,
2114 you should enter that name under "External (public) IPv4 address" (which
2115 corresponds to the "EXTERNAL_ADDRESS" option in the configuration file).
2116 If you leave the option empty, GNUnet will try to determine your external
2117 IP address automatically (which may fail, in which case autonomous
2118 NAT traversal will then not work).
2119
2120 Finally, if you yourself are not behind NAT but want to be able to
2121 connect to NATed peers using autonomous NAT traversal, you need to check
2122 the "Enable connecting to NATed peers using ICMP method" box.
2123
2124
2125 @node Peer configuration for distributors (e.g. Operating Systems)
2126 @subsection Peer configuration for distributors (e.g. Operating Systems)
2127
2128 The "GNUNET_DATA_HOME" in "[path]" in @file{/etc/gnunet.conf} should be
2129 manually set to "/var/lib/gnunet/data/" as the default
2130 "~/.local/share/gnunet/" is probably not that appropriate in this case.
2131 Similarly, distributors may consider pointing "GNUNET_RUNTIME_DIR" to
2132 "/var/run/gnunet/" and "GNUNET_HOME" to "/var/lib/gnunet/". Also, should a
2133 distributor decide to override system defaults, all of these changes
2134 should be done in a custom @file{/etc/gnunet.conf} and not in the files
2135 in the @file{config.d/} directory.
2136
2137 Given the proposed access permissions, the "gnunet-setup" tool must be
2138 run as use "gnunet" (and with option "-c /etc/gnunet.conf" so that it
2139 modifies the system configuration). As always, gnunet-setup should be run
2140 after the GNUnet peer was stopped using "gnunet-arm -e". Distributors
2141 might want to include a wrapper for gnunet-setup that allows the
2142 desktop-user to "sudo" (i.e. using gtksudo) to the "gnunet" user account
2143 and then runs "gnunet-arm -e", "gnunet-setup" and "gnunet-arm -s" in
2144 sequence.
2145
2146 @node Config Leftovers
2147 @section Config Leftovers
2148
2149 This section describes how to start a GNUnet peer. It assumes that you
2150 have already compiled and installed GNUnet and its' dependencies.
2151 Before you start a GNUnet peer, you may want to create a configuration
2152 file using gnunet-setup (but you do not have to).
2153 Sane defaults should exist in your
2154 @file{$GNUNET_PREFIX/share/gnunet/config.d/} directory, so in practice
2155 you could simply start without any configuration. If you want to
2156 configure your peer later, you need to stop it before invoking the
2157 @code{gnunet-setup} tool to customize further and to test your
2158 configuration (@code{gnunet-setup} has build-in test functions).
2159
2160 The most important option you might have to still set by hand is in
2161 [PATHS]. Here, you use the option "GNUNET_HOME" to specify the path where
2162 GNUnet should store its data.
2163 It defaults to @code{$HOME/}, which again should work for most users.
2164 Make sure that the directory specified as GNUNET_HOME is writable to
2165 the user that you will use to run GNUnet (note that you can run frontends
2166 using other users, GNUNET_HOME must only be accessible to the user used to
2167 run the background processes).
2168
2169 You will also need to make one central decision: should all of GNUnet be
2170 run under your normal UID, or do you want distinguish between system-wide
2171 (user-independent) GNUnet services and personal GNUnet services. The
2172 multi-user setup is slightly more complicated, but also more secure and
2173 generally recommended.
2174
2175 @menu
2176 * The Single-User Setup::
2177 * The Multi-User Setup::
2178 * Killing GNUnet services::
2179 * Access Control for GNUnet::
2180 @end menu
2181
2182 @node The Single-User Setup
2183 @subsection The Single-User Setup
2184
2185 For the single-user setup, you do not need to do anything special and can
2186 just start the GNUnet background processes using @code{gnunet-arm}.
2187 By default, GNUnet looks in @file{~/.config/gnunet.conf} for a
2188 configuration (or @code{$XDG_CONFIG_HOME/gnunet.conf} if@
2189 @code{$XDG_CONFIG_HOME} is defined). If your configuration lives
2190 elsewhere, you need to pass the @code{-c FILENAME} option to all GNUnet
2191 commands.
2192
2193 Assuming the configuration file is called @file{~/.config/gnunet.conf},
2194 you start your peer using the @code{gnunet-arm} command (say as user
2195 @code{gnunet}) using:
2196
2197 @example
2198 gnunet-arm -c ~/.config/gnunet.conf -s
2199 @end example
2200
2201 @noindent
2202 The "-s" option here is for "start". The command should return almost
2203 instantly. If you want to stop GNUnet, you can use:
2204
2205 @example
2206 gnunet-arm -c ~/.config/gnunet.conf -e
2207 @end example
2208
2209 @noindent
2210 The "-e" option here is for "end".
2211
2212 Note that this will only start the basic peer, no actual applications
2213 will be available.
2214 If you want to start the file-sharing service, use (after starting
2215 GNUnet):
2216
2217 @example
2218 gnunet-arm -c ~/.config/gnunet.conf -i fs
2219 @end example
2220
2221 @noindent
2222 The "-i fs" option here is for "initialize" the "fs" (file-sharing)
2223 application. You can also selectively kill only file-sharing support using
2224
2225 @example
2226 gnunet-arm -c ~/.config/gnunet.conf -k fs
2227 @end example
2228
2229 @noindent
2230 Assuming that you want certain services (like file-sharing) to be always
2231 automatically started whenever you start GNUnet, you can activate them by
2232 setting "IMMEDIATE_START=YES" in the respective section of the configuration
2233 file (for example, "[fs]"). Then GNUnet with file-sharing support would
2234 be started whenever you@ enter:
2235
2236 @example
2237 gnunet-arm -c ~/.config/gnunet.conf -s
2238 @end example
2239
2240 @noindent
2241 Alternatively, you can combine the two options:
2242
2243 @example
2244 gnunet-arm -c ~/.config/gnunet.conf -s -i fs
2245 @end example
2246
2247 @noindent
2248 Using @code{gnunet-arm} is also the preferred method for initializing
2249 GNUnet from @code{init}.
2250
2251 Finally, you should edit your @code{crontab} (using the @code{crontab}
2252 command) and insert a line@
2253
2254 @example
2255 @@reboot gnunet-arm -c ~/.config/gnunet.conf -s
2256 @end example
2257
2258 to automatically start your peer whenever your system boots.
2259
2260 @node The Multi-User Setup
2261 @subsection The Multi-User Setup
2262
2263 This requires you to create a user @code{gnunet} and an additional group
2264 @code{gnunetdns}, prior to running @code{make install} during
2265 installation.
2266 Then, you create a configuration file @file{/etc/gnunet.conf} which should
2267 contain the lines:@
2268
2269 @example
2270 [arm]
2271 START_SYSTEM_SERVICES = YES
2272 START_USER_SERVICES = NO
2273 @end example
2274
2275 @noindent
2276 Then, perform the same steps to run GNUnet as in the per-user
2277 configuration, except as user @code{gnunet} (including the
2278 @code{crontab} installation).
2279 You may also want to run @code{gnunet-setup} to configure your peer
2280 (databases, etc.).
2281 Make sure to pass @code{-c /etc/gnunet.conf} to all commands. If you
2282 run @code{gnunet-setup} as user @code{gnunet}, you might need to change
2283 permissions on @file{/etc/gnunet.conf} so that the @code{gnunet} user can
2284 write to the file (during setup).
2285
2286 Afterwards, you need to perform another setup step for each normal user
2287 account from which you want to access GNUnet. First, grant the normal user
2288 (@code{$USER}) permission to the group gnunet:
2289
2290 @example
2291 # adduser $USER gnunet
2292 @end example
2293
2294 @noindent
2295 Then, create a configuration file in @file{~/.config/gnunet.conf} for the
2296 $USER with the lines:
2297
2298 @example
2299 [arm]
2300 START_SYSTEM_SERVICES = NO
2301 START_USER_SERVICES = YES
2302 @end example
2303
2304 @noindent
2305 This will ensure that @code{gnunet-arm} when started by the normal user
2306 will only run services that are per-user, and otherwise rely on the
2307 system-wide services.
2308 Note that the normal user may run gnunet-setup, but the
2309 configuration would be ineffective as the system-wide services will use
2310 @file{/etc/gnunet.conf} and ignore options set by individual users.
2311
2312 Again, each user should then start the peer using
2313 @file{gnunet-arm -s} --- and strongly consider adding logic to start
2314 the peer automatically to their crontab.
2315
2316 Afterwards, you should see two (or more, if you have more than one USER)
2317 @code{gnunet-service-arm} processes running in your system.
2318
2319 @node Killing GNUnet services
2320 @subsection Killing GNUnet services
2321
2322 It is not necessary to stop GNUnet services explicitly when shutting
2323 down your computer.
2324
2325 It should be noted that manually killing "most" of the
2326 @code{gnunet-service} processes is generally not a successful method for
2327 stopping a peer (since @code{gnunet-service-arm} will instantly restart
2328 them). The best way to explicitly stop a peer is using
2329 @code{gnunet-arm -e}; note that the per-user services may need to be
2330 terminated before the system-wide services will terminate normally.
2331
2332 @node Access Control for GNUnet
2333 @subsection Access Control for GNUnet
2334
2335 This chapter documents how we plan to make access control work within the
2336 GNUnet system for a typical peer. It should be read as a best-practice
2337 installation guide for advanced users and builders of binary
2338 distributions. The recommendations in this guide apply to POSIX-systems
2339 with full support for UNIX domain sockets only.
2340
2341 Note that this is an advanced topic. The discussion presumes a very good
2342 understanding of users, groups and file permissions. Normal users on
2343 hosts with just a single user can just install GNUnet under their own
2344 account (and possibly allow the installer to use SUDO to grant additional
2345 permissions for special GNUnet tools that need additional rights).
2346 The discussion below largely applies to installations where multiple users
2347 share a system and to installations where the best possible security is
2348 paramount.
2349
2350 A typical GNUnet system consists of components that fall into four
2351 categories:
2352
2353 @table @asis
2354
2355 @item User interfaces
2356 User interfaces are not security sensitive and are supposed to be run and
2357 used by normal system users.
2358 The GTK GUIs and most command-line programs fall into this category.
2359 Some command-line tools (like gnunet-transport) should be excluded as they
2360 offer low-level access that normal users should not need.
2361 @item System services and support tools
2362 System services should always run and offer services that can then be
2363 accessed by the normal users.
2364 System services do not require special permissions, but as they are not
2365 specific to a particular user, they probably should not run as a
2366 particular user. Also, there should typically only be one GNUnet peer per
2367 host. System services include the gnunet-service and gnunet-daemon
2368 programs; support tools include command-line programs such as gnunet-arm.
2369 @item Privileged helpers
2370 Some GNUnet components require root rights to open raw sockets or perform
2371 other special operations. These gnunet-helper binaries are typically
2372 installed SUID and run from services or daemons.
2373 @item Critical services
2374 Some GNUnet services (such as the DNS service) can manipulate the service
2375 in deep and possibly highly security sensitive ways. For example, the DNS
2376 service can be used to intercept and alter any DNS query originating from
2377 the local machine. Access to the APIs of these critical services and their
2378 privileged helpers must be tightly controlled.
2379 @end table
2380
2381 @c FIXME: The titles of these chapters are too long in the index.
2382
2383 @menu
2384 * Recommendation - Disable access to services via TCP::
2385 * Recommendation - Run most services as system user "gnunet"::
2386 * Recommendation - Control access to services using group "gnunet"::
2387 * Recommendation - Limit access to certain SUID binaries by group "gnunet"::
2388 * Recommendation - Limit access to critical gnunet-helper-dns to group "gnunetdns"::
2389 * Differences between "make install" and these recommendations::
2390 @end menu
2391
2392 @node Recommendation - Disable access to services via TCP
2393 @subsubsection Recommendation - Disable access to services via TCP
2394
2395 GNUnet services allow two types of access: via TCP socket or via UNIX
2396 domain socket.
2397 If the service is available via TCP, access control can only be
2398 implemented by restricting connections to a particular range of IP
2399 addresses.
2400 This is acceptable for non-critical services that are supposed to be
2401 available to all users on the local system or local network.
2402 However, as TCP is generally less efficient and it is rarely the case
2403 that a single GNUnet peer is supposed to serve an entire local network,
2404 the default configuration should disable TCP access to all GNUnet
2405 services on systems with support for UNIX domain sockets.
2406 Since GNUnet 0.9.2, configuration files with TCP access disabled should be
2407 generated by default. Users can re-enable TCP access to particular
2408 services simply by specifying a non-zero port number in the section of
2409 the respective service.
2410
2411
2412 @node Recommendation - Run most services as system user "gnunet"
2413 @subsubsection Recommendation - Run most services as system user "gnunet"
2414
2415 GNUnet's main services should be run as a separate user "gnunet" in a
2416 special group "gnunet".
2417 The user "gnunet" should start the peer using "gnunet-arm -s" during
2418 system startup. The home directory for this user should be
2419 @file{/var/lib/gnunet} and the configuration file should be
2420 @file{/etc/gnunet.conf}.
2421 Only the @code{gnunet} user should have the right to access
2422 @file{/var/lib/gnunet} (@emph{mode: 700}).
2423
2424 @node Recommendation - Control access to services using group "gnunet"
2425 @subsubsection Recommendation - Control access to services using group "gnunet"
2426
2427 Users that should be allowed to use the GNUnet peer should be added to the
2428 group "gnunet". Using GNUnet's access control mechanism for UNIX domain
2429 sockets, those services that are considered useful to ordinary users
2430 should be made available by setting "UNIX_MATCH_GID=YES" for those
2431 services.
2432 Again, as shipped, GNUnet provides reasonable defaults.
2433 Permissions to access the transport and core subsystems might additionally
2434 be granted without necessarily causing security concerns.
2435 Some services, such as DNS, must NOT be made accessible to the "gnunet"
2436 group (and should thus only be accessible to the "gnunet" user and
2437 services running with this UID).
2438
2439 @node Recommendation - Limit access to certain SUID binaries by group "gnunet"
2440 @subsubsection Recommendation - Limit access to certain SUID binaries by group "gnunet"
2441
2442 Most of GNUnet's SUID binaries should be safe even if executed by normal
2443 users. However, it is possible to reduce the risk a little bit more by
2444 making these binaries owned by the group "gnunet" and restricting their
2445 execution to user of the group "gnunet" as well (4750).
2446
2447 @node Recommendation - Limit access to critical gnunet-helper-dns to group "gnunetdns"
2448 @subsubsection Recommendation - Limit access to critical gnunet-helper-dns to group "gnunetdns"
2449
2450 A special group "gnunetdns" should be created for controlling access to
2451 the "gnunet-helper-dns".
2452 The binary should then be owned by root and be in group "gnunetdns" and
2453 be installed SUID and only be group-executable (2750).
2454 @b{Note that the group "gnunetdns" should have no users in it at all,
2455 ever.}
2456 The "gnunet-service-dns" program should be executed by user "gnunet" (via
2457 gnunet-service-arm) with the binary owned by the user "root" and the group
2458 "gnunetdns" and be SGID (2700). This way, @strong{only}
2459 "gnunet-service-dns" can change its group to "gnunetdns" and execute the
2460 helper, and the helper can then run as root (as per SUID).
2461 Access to the API offered by "gnunet-service-dns" is in turn restricted
2462 to the user "gnunet" (not the group!), which means that only
2463 "benign" services can manipulate DNS queries using "gnunet-service-dns".
2464
2465 @node Differences between "make install" and these recommendations
2466 @subsubsection Differences between "make install" and these recommendations
2467
2468 The current build system does not set all permissions automatically based
2469 on the recommendations above. In particular, it does not use the group
2470 "gnunet" at all (so setting gnunet-helpers other than the
2471 gnunet-helper-dns to be owned by group "gnunet" must be done manually).
2472 Furthermore, 'make install' will silently fail to set the DNS binaries to
2473 be owned by group "gnunetdns" unless that group already exists (!).
2474 An alternative name for the "gnunetdns" group can be specified using the
2475 @code{--with-gnunetdns=GRPNAME} configure option.
2476