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