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