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