netsniff-ng: ring: Fix build if tp_vlan_tpid is not available in kernel header
[netsniff-ng.git] / curvetun.8
blob555908d064c29563772c4dabfa378defa9b49a14
1 .\" netsniff-ng - the packet sniffing beast
2 .\" Copyright 2013 Daniel Borkmann.
3 .\" Subject to the GPL, version 2.
4 .TH CURVETUN 8 "03 March 2013" "Linux" "netsniff-ng toolkit"
5 .SH NAME
6 curvetun \- a lightweight curve25519 ip4/6 tunnel
7 .PP
8 .SH SYNOPSIS
9 .PP
10 \fBcurvetun\fR [\fIoptions\fR]
11 .PP
12 .SH DESCRIPTION
13 curvetun is a lightweight, high-speed ECDH multiuser IP tunnel for Linux
14 that is based on epoll(2). curvetun uses the Linux TUN/TAP interface and
15 supports {IPv4, IPv6} over {IPv4, IPv6} with UDP or TCP as carrier protocols.
16 .PP
17 It has an integrated packet forwarding tree, thus multiple users with
18 different IPs can be handled via a single tunnel device on the server side,
19 and flows are scheduled for processing in a CPU efficient way, at least in the
20 case of TCP as the carrier protocol.
21 .PP
22 For key management, public-key cryptography based on elliptic curves are
23 used and packets are encrypted end-to-end by the symmetric stream cipher
24 Salsa20 and authenticated by the MAC Poly1305, where keys have previously
25 been computed with the ECDH key agreement protocol Curve25519.
26 .PP
27 Cryptography is based on Daniel J. Bernstein's networking and cryptography
28 library \[lq]NaCl\[rq]. By design, curvetun does not provide any particular
29 pattern or default port numbers that gives certainty that the connection from
30 a particular flow is actually running curvetun.
31 .PP
32 However, if you have a further need to bypass censorship, you can try using
33 curvetun in combination with Tor's obfsproxy or Telex. Furthermore, curvetun
34 also protects you against replay attacks and DH man-in-the-middle attacks.
35 Additionally, server-side syslog event logging can also be disabled to avoid
36 revealing critical user connection data.
37 .PP
38 .IP " 1." 4
39 obfsproxy from the TOR project
40 .RS 4
41 \%https://www.torproject.org/projects/obfsproxy.html.en
42 .RE
43 .PP
44 .IP " 2." 4
45 Telex, anti-censorship in the network infrastructure
46 .RS 4
47 \%https://telex.cc/
48 .RE
49 .PP
50 .SH OPTIONS
51 .PP
52 .SS -d <tundev>, --dev <tundev>
53 Defines the name of the tunnel device that is being created. If this option
54 is not set, then the default names, curves{0,1,2,..} for a curvetun server,
55 and curvec{0,1,2,...} for a curvetun client are used.
56 .PP
57 .SS -p <num>, --port <num>
58 Defines the port the curvetun server should listen on. There is no default port
59 for curvetun, so setting this option for server bootstrap is mandatory. This
60 option is for servers only.
61 .PP
62 .SS -t <server>, --stun <server>
63 If needed, this options enables an STUN lookup in order to show public IP to port
64 mapping and to punch a hole into the firewall. In case you are unsure what STUN
65 server to use, simply use ''\-\-stun stunserver.org''.
66 .PP
67 .SS -c[=alias], --client[=alias]
68 Starts curvetun in client mode and connects to the given connection alias that is
69 defined in the configuration file.
70 .PP
71 .SS -k, --keygen
72 Generate private and public keypair. This must be done initially.
73 .PP
74 .SS -x, --export
75 Export user and key combination to stdout as a one-liner.
76 .PP
77 .SS -C, --dumpc
78 Dump all known clients that may connect to the local curvetun server and exit.
79 .PP
80 .SS -S, --dumps
81 Dump all known servers curvetun as a client can connect to, and exit.
82 .PP
83 .SS -D, --nofork
84 Do not fork off as a client or server on startup.
85 .PP
86 .SS -s, --server
87 Start curvetun in server mode. Additional parameters are needed, at least
88 the definition of the port that clients can connect to is required.
89 .PP
90 .SS -N, --no-logging
91 Disable all curvetun logging of user information. This option can be used to
92 enable curvetun users to connect more anonymously. This option is for servers
93 only.
94 .PP
95 .SS -u, --udp
96 Use UDP as a carrier protocol instead of TCP. By default, TCP is the
97 carrier protocol. This option is for servers only.
98 .PP
99 .SS -4, --ipv4
100 Defines IPv4 as the underlying network protocol to be used on the tunnel
101 device. IPv4 is the default. This option is for servers only.
103 .SS -6, --ipv6
104 Defines IPv6 as the underlying network protocol to be used on the tunnel
105 device. This option is for servers only.
107 .SS -v, --version
108 Show version information and exit.
110 .SS -h, --help
111 Show user help and exit.
113 .SH USAGE EXAMPLE
115 .SS curvetun --server -4 -u -N --port 6666 --stun stunserver.org
116 Starts curvetun in server mode with IPv4 as network protocol and UDP as a transport
117 carrier protocol. The curvetun server listens for incoming connections on port 6666
118 and performs an STUN lookup on startup to stunserver.org.
120 .SS curvetun --client=ethz
121 Starts curvetun in client mode and connects to the defined connection alias ''ethz''
122 that is defined in the curvetun ~/.curvetun/servers configuration file.
124 .SS curvetun --keygen
125 Generates initial keypairs and stores them in the ~/.curvetun/ directory.
127 .SS curvetun --export
128 Export user data to stdout for configuration of a curvetun server.
130 .SH CRYPTOGRAPHY
131 Encrypted IP tunnels are often used to create virtual private networks (VPN),
132 where parts of the network can only be reached via an insecure or untrusted medium
133 such as the Internet. Only a few software utilities exist to create such tunnels,
134 or, VPNs. Two popular representatives of such software are OpenVPN and VTUN.
136 The latter also introduced the TUN/TAP interfaces into the Linux kernel. VTUN
137 only has a rather basic encryption module, that does not fit todays
138 cryptographic needs. By default, MD5 is used to create 128-Bit wide keys for
139 the symmetric BlowFish cipher in ECB mode [1].
141 Although OpenSSL is used in both VTUN and OpenVPN, OpenVPN is much more
142 feature rich regarding ciphers and user authentication. Nevertheless, letting
143 people choose ciphers or authentication methods is not necessarily a
144 good thing: administrators could either prefer speed over security and
145 therefore choose weak ciphers, so that the communication system will be as
146 good as without any cipher; they could choose weak passwords for symmetric
147 encryption or they could misconfigure the communication system by having too
148 much choice of ciphers and too little experience for picking the right one.
150 Next to the administration issues, there are also software development issues.
151 Cryptographic libraries like OpenSSL are a huge mess and too low-level and
152 complex to fully understand or correctly apply, so that they form further
153 ground for vulnerabilities of such software.
155 In 2010, the cryptographers Tanja Lange and Daniel J. Bernstein have therefore
156 created and published a cryptographic library for networking, which is named
157 NaCl (pronounced ''salt''). NaCl addresses such problems as mentioned in
158 OpenSSL and, in contrast to the rather generic use of OpenSSL, was created
159 with a strong focus on public-key authenticated encryption based on elliptic
160 curve cryptography, which is used in curvetun. Partially quoting Daniel J.
161 Bernstein:
163 "RSA is somewhat older than elliptic-curve cryptography: RSA was introduced
164 in 1977, while elliptic-curve cryptography was introduced in 1985. However,
165 RSA has shown many more weaknesses than elliptic-curve cryptography. RSA's
166 effective security level was dramatically reduced by the linear sieve in the
167 late 1970s, by the quadratic sieve and ECM in the 1980s, and by the
168 number-field sieve in the 1990s. For comparison, a few attacks have been
169 developed against some rare elliptic curves having special algebraic
170 structures, and the amount of computer power available to attackers has
171 predictably increased, but typical elliptic curves require just as much
172 computer power to break today as they required twenty years ago.
174 IEEE P1363 standardized elliptic-curve cryptography in the late 1990s,
175 including a stringent list of security criteria for elliptic curves. NIST
176 used the IEEE P1363 criteria to select fifteen specific elliptic curves at
177 five different security levels. In 2005, NSA issued a new ''Suite B''
178 standard, recommending the NIST elliptic curves (at two specific security
179 levels) for all public-key cryptography and withdrawing previous
180 recommendations of RSA."
182 curvetun uses a particular elliptic curve, Curve25519, introduced in the
183 following paper: Daniel J. Bernstein, ''Curve25519: new Diffie-Hellman speed
184 records,'' pages 207-228 in Proceedings of PKC 2006, edited by Moti Yung,
185 Yevgeniy Dodis, Aggelos Kiayias, and Tal Malkin, Lecture Notes in Computer
186 Science 3958, Springer, 2006, ISBN 3-540-33851-9.
188 This elliptic curve follows all of the standard IEEE P1363 security criteria.
189 It also follows new recommendations that achieve ''side-channel immunity''
190 and ''twist security'' while improving speed. What this means is that secure
191 implementations of Curve25519 are considerably simpler and faster than secure
192 implementations of, for example, NIST P-256; there are fewer opportunities for
193 implementors to make mistakes that compromise security, and mistakes are
194 more easily caught by reviewers.
196 An attacker who spends a billion dollars on special-purpose chips to attack
197 Curve25519, using the best attacks available today, has about 1 chance in
198 1000000000000000000000000000 of breaking Curve25519 after a year of computation.
199 One could achieve similar levels of security with 3000-bit RSA, but
200 encryption and authentication with 3000-bit RSA are not nearly fast enough
201 to handle tunnel traffic and would require much more space in network
202 packets.
204 .IP " 1." 4
205 Security analysis of VTun
206 .RS 4
207 \%http://www.off.net/~jme/vtun_secu.html
210 .IP " 2." 4
211 NaCl: Networking and Cryptography library
212 .RS 4
213 \%http://nacl.cr.yp.to/
216 .SH SETUP HOWTO
217 If you have not run curvetun before, you need to do an initial setup once.
219 First, make sure that the servers and clients clocks are periodically
220 synced, for example, by running an NTP daemon. This is necessary to protect
221 against replay attacks. Also, make sure you have read and write access to
222 /dev/net/tun. You should not run curvetun as root! Then, after you have assured
223 this, the first step is to generate keys and config files. On both the client
224 and server do:
226 .B curvetun -k
228 You are asked for a user name. You can use an email address or whatever suits
229 you. Here, we assume you have entered 'mysrv1' on the server and 'myclient1'
230 on the client side.
232 Now, all necessary files have been created under ~/.curvetun. Files include
233 \[lq]priv.key\[rq], \[lq]pub.key\[rq], \[lq]username\[rq], \[lq]clients\[rq]
234 and \[lq]servers\[rq].
236 \[lq]clients\[rq] and \[lq]servers\[rq] are empty at the beginning and need
237 to be filled. The \[lq]clients\[rq] file is meant for the server, so that it
238 knows what clients are allowed to connect. The \[lq]servers\[rq] file is for
239 the client, where it can select curvetun servers to connect to. Both files are
240 kept very simple, so that a single configuration line per client or server
241 is sufficient.
243 The client needs to export its public key data for the server
245 .B curvetun -x
247 where it prints a string in the following format:
249   myclient1;11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11
250   \\_______/ \\_____________________________________________________________________________________________/
251    username  32 byte public key for 'myclient1'
253 This line is transferred to the server admin (yes, we assume a manual on-site
254 key exchange scenario where, for example, the admin sets up server and clients), where
255 the admin then adds this entry into his ''clients'' file like:
257   server$ echo "myclient1;11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:" \\
258                "11:11:11:11:11:11:11:11:11:11:11:11:11:11:11" >> ~/.curvetun/clients
260 The server admin can check if the server has registered it properly as follows:
262   server$ curvetun \-C
264 which prints all parsed clients from ''~/.curvetun/clients''. This process could
265 easily be automated or scripted with, for example, Perl and LDAP.
267 Now, the client ''myclient1'' is known to the server; that completes the server
268 configuration. The next step is to tell the client where it needs to connect to
269 the server.
271 We assume in this example that the tunnel server has a public IP address, e.g. 1.2.3.4,
272 runs on port 6666 and uses UDP as a carrier protocol. In case you are behind
273 NAT, you can use curvetun's ''\-\-stun'' option for starting the server, to
274 obtain your mapping. However, in this example we continue with 1.2.3.4 and 6666,
275 UDP.
277 First, the server needs to export its key to the client, as follows:
279   server$ curvetun \-x
281 where it prints a string in the following format:
283   mysrv1;22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22
284   \\____/ \\_____________________________________________________________________________________________/
285  username  32 byte public key for 'mysrv1'
286            ^-- you need this public key
288 Thus, you now have the server IP address, server port, server transport protocol and the
289 server's public key at hand. On the client side it can be put all together
290 in the config as follows:
292   client$ echo "myfirstserver;1.2.3.4;6666;udp;22:22:22:22:22:22:22:22:22:22:" \\
293                "22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:"  \\
294                "22:22" >> ~/.curvetun/servers
296 The client can check its config using:
298   client$ curvetun \-S
300 Then we start the server with:
302   server$ curvetun \-s \-p 6666 \-u
303   server# ifconfig curves0 up
304   server# ifconfig curves0 10.0.0.1/24
306 Then, we start the client with:
308   client$ curvetun \-c=myfirstserver
309   client# ifconfig curvec0 up
310   client# ifconfig curvec0 10.0.0.2/24
312 Also, client-side information, errors, or warnings will appear in syslog! By now
313 we should be able to ping the server:
315   client$ ping 10.0.0.1
317 That's it! Routing example:
319 Server side's public IP on eth0 is, for example, 1.2.3.4:
321   server$ ... start curvetun server ...
322   server# ifconfig curves0 up
323   server# ifconfig curves0 10.0.0.1/24
324   server# echo 1 > /proc/sys/net/ipv4/ip_forward
325   server# iptables \-t nat \-A POSTROUTING \-o eth0 \-j MASQUERADE
326   server# iptables \-A FORWARD \-i eth0 \-o curves0 \-m state \-\-state RELATED,ESTABLISHED \-j ACCEPT
327   server# iptables \-A FORWARD \-i curves0 \-o eth0 \-j ACCEPT
329 Client side's IP on eth0 is, for example, 5.6.7.8:
331   client$ ... start curvetun client ...
332   client# ... lookup your default gateway (e.g. via route, here: 5.6.7.9) ...
333   client# ifconfig curvec0 up
334   client# ifconfig curvec0 10.0.0.2/24
335   client# route add \-net 1.2.3.0 netmask 255.255.255.0 gw 5.6.7.9 dev eth0
336   client# route add default gw 10.0.0.1
337   client# route del default gw 5.6.7.9
339 That should be it, happy browsing and emailing via curvetun tunnels!
341 .SH NOTE
342 This software is an experimental prototype intended for researchers. It will most
343 likely mature over time, but it is currently not advised to use this software
344 when life is put at risk.
346 .SH BUGS
347 Blackhole tunneling is currently not supported.
349 .SH LEGAL
350 curvetun is licensed under the GNU GPL version 2.0.
352 .SH HISTORY
353 .B curvetun
354 was originally written for the netsniff-ng toolkit by Daniel Borkmann. It is
355 currently maintained by Tobias Klauser <tklauser@distanz.ch> and Daniel
356 Borkmann <dborkma@tik.ee.ethz.ch>.
358 .SH SEE ALSO
359 .BR netsniff-ng (8),
360 .BR trafgen (8),
361 .BR mausezahn (8),
362 .BR bpfc (8),
363 .BR ifpps (8),
364 .BR flowtop (8),
365 .BR astraceroute (8)
367 .SH AUTHOR
368 Manpage was written by Daniel Borkmann.
370 .SH COLOPHON
371 This page is part of the Linux netsniff-ng toolkit project. A description of the project,
372 and information about reporting bugs, can be found at http://netsniff-ng.org/.