up.sh
Code: Select all
#!/bin/sh
BR=$1
DEV=$2
MTU=$3
/sbin/ifconfig $DEV mtu $MTU promisc up
/sbin/brctl addif $BR $DEV
Code: Select all
#!/bin/sh
BR=$1
DEV=$2
/sbin/brctl delif $BR $DEV
/sbin/ifconfig $DEV down
server.config
1
#################################################
2
3
# Sample OpenVPN 2.0 config file for #
4
5
# multi-client server. #
6
7
# #
8
9
# This file is for the server side #
10
11
# of a many-clients <-> one-server #
12
13
# OpenVPN configuration. #
14
15
# #
16
17
# OpenVPN also supports #
18
19
# single-machine <-> single-machine #
20
21
# configurations (See the Examples page #
22
23
# on the web site for more info). #
24
25
# #
26
27
# This config should work on Windows #
28
29
# or Linux/BSD systems. Remember on #
30
31
# Windows to quote pathnames and use #
32
33
# double backslashes, e.g.: #
34
35
# "C:\\Program Files\\OpenVPN\\config\\foo.key" #
36
37
# #
38
39
# Comments are preceded with '#' or ';' #
40
41
#################################################
42
43
44
45
# Which local IP address should OpenVPN
46
47
# listen on? (optional)
48
49
;local a.b.c.d
50
51
52
53
# Which TCP/UDP port should OpenVPN listen on?
54
55
# If you want to run multiple OpenVPN instances
56
57
# on the same machine, use a different port
58
59
# number for each one. You will need to
60
61
# open up this port on your firewall.
62
63
port 1194
64
65
66
67
# TCP or UDP server?
68
69
proto tcp
70
71
proto udp
72
73
74
75
# "dev tun" will create a routed IP tunnel,
76
77
# "dev tap" will create an ethernet tunnel.
78
79
# Use "dev tap0" if you are ethernet bridging
80
81
# and have precreated a tap0 virtual interface
82
83
# and bridged it with your ethernet interface.
84
85
# If you want to control access policies
86
87
# over the VPN, you must create firewall
88
89
# rules for the the TUN/TAP interface.
90
91
# On non-Windows systems, you can give
92
93
# an explicit unit number, such as tun0.
94
95
# On Windows, use "dev-node" for this.
96
97
# On most systems, the VPN will not function
98
99
# unless you partially or fully disable
100
101
# the firewall for the TUN/TAP interface.
102
103
dev tap0
104
105
;dev tun
106
107
108
109
# Windows needs the TAP-Win32 adapter name
110
111
# from the Network Connections panel if you
112
113
# have more than one. On XP SP2 or higher,
114
115
# you may need to selectively disable the
116
117
# Windows firewall for the TAP adapter.
118
119
# Non-Windows systems usually don't need this.
120
121
;dev-node MyTap
122
123
124
125
# SSL/TLS root certificate (ca), certificate
126
127
# (cert), and private key (key). Each client
128
129
# and the server must have their own cert and
130
131
# key file. The server and all clients will
132
133
# use the same ca file.
134
135
#
136
137
# See the "easy-rsa" directory for a series
138
139
# of scripts for generating RSA certificates
140
141
# and private keys. Remember to use
142
143
# a unique Common Name for the server
144
145
# and each of the client certificates.
146
147
#
148
149
# Any X509 key management system can be used.
150
151
# OpenVPN can also use a PKCS #12 formatted key file
152
153
# (see "pkcs12" directive in man page).
154
155
ca /home/pi/pki/ca.crt
156
157
cert /home/pi/pki/issued/rpi0.crt
158
159
key /home/pi/pki/private/rpi0.key # This file should be kept secret
160
161
162
163
# Diffie hellman parameters.
164
165
# Generate your own with:
166
167
# openssl dhparam -out dh1024.pem 1024
168
169
# Substitute 2048 for 1024 if you are using
170
171
# 2048 bit keys.
172
173
dh "/home/pi/pki/dh.pem"
174
175
176
177
# Configure server mode and supply a VPN subnet
178
179
# for OpenVPN to draw client addresses from.
180
181
# The server will take 10.8.0.1 for itself,
182
183
# the rest will be made available to clients.
184
185
# Each client will be able to reach the server
186
187
# on 10.8.0.1. Comment this line out if you are
188
189
# ethernet bridging. See the man page for more info.
190
191
;server 192.168.1.73 255.255.255.0
192
193
server-bridge 192.168.1.73 255.255.255.0 192.168.1.90 192.168.1.99
194
195
196
197
# Maintain a record of client <-> virtual IP address
198
199
# associations in this file. If OpenVPN goes down or
200
201
# is restarted, reconnecting clients can be assigned
202
203
# the same virtual IP address from the pool that was
204
205
# previously assigned.
206
207
ifconfig-pool-persist ipp.txt
208
209
210
211
# Configure server mode for ethernet bridging.
212
213
# You must first use your OS's bridging capability
214
215
# to bridge the TAP interface with the ethernet
216
217
# NIC interface. Then you must manually set the
218
219
# IP/netmask on the bridge interface, here we
220
221
# assume 10.8.0.4/255.255.255.0. Finally we
222
223
# must set aside an IP range in this subnet
224
225
# (start=10.8.0.50 end=10.8.0.100) to allocate
226
227
# to connecting clients. Leave this line commented
228
229
# out unless you are ethernet bridging.
230
231
;server-bridge 10.8.0.4 255.255.255.0 10.8.0.50 10.8.0.100
232
233
234
235
# Configure server mode for ethernet bridging
236
237
# using a DHCP-proxy, where clients talk
238
239
# to the OpenVPN server-side DHCP server
240
241
# to receive their IP address allocation
242
243
# and DNS server addresses. You must first use
244
245
# your OS's bridging capability to bridge the TAP
246
247
# interface with the ethernet NIC interface.
248
249
# Note: this mode only works on clients (such as
250
251
# Windows), where the client-side TAP adapter is
252
253
# bound to a DHCP client.
254
255
;server-bridge
256
257
258
259
# Push routes to the client to allow it
260
261
# to reach other private subnets behind
262
263
# the server. Remember that these
264
265
# private subnets will also need
266
267
# to know to route the OpenVPN client
268
269
# address pool (10.8.0.0/255.255.255.0)
270
271
# back to the OpenVPN server.
272
273
push "route 192.168.1.254 255.255.255.0"
274
275
;push "route 192.168.20.0 255.255.255.0"
276
277
278
279
# To assign specific IP addresses to specific
280
281
# clients or if a connecting client has a private
282
283
# subnet behind it that should also have VPN access,
284
285
# use the subdirectory "ccd" for client-specific
286
287
# configuration files (see man page for more info).
288
289
290
291
# EXAMPLE: Suppose the client
292
293
# having the certificate common name "Thelonious"
294
295
# also has a small subnet behind his connecting
296
297
# machine, such as 192.168.40.128/255.255.255.248.
298
299
# First, uncomment out these lines:
300
301
;client-config-dir ccd
302
303
;route 192.168.40.128 255.255.255.248
304
305
# Then create a file ccd/Thelonious with this line:
306
307
# iroute 192.168.40.128 255.255.255.248
308
309
# This will allow Thelonious' private subnet to
310
311
# access the VPN. This example will only work
312
313
# if you are routing, not bridging, i.e. you are
314
315
# using "dev tun" and "server" directives.
316
317
318
319
# EXAMPLE: Suppose you want to give
320
321
# Thelonious a fixed VPN IP address of 10.9.0.1.
322
323
# First uncomment out these lines:
324
325
;client-config-dir ccd
326
327
;route 10.9.0.0 255.255.255.252
328
329
# Then add this line to ccd/Thelonious:
330
331
# ifconfig-push 10.9.0.1 10.9.0.2
332
333
334
335
# Suppose that you want to enable different
336
337
# firewall access policies for different groups
338
339
# of clients. There are two methods:
340
341
# (1) Run multiple OpenVPN daemons, one for each
342
343
# group, and firewall the TUN/TAP interface
344
345
# for each group/daemon appropriately.
346
347
# (2) (Advanced) Create a script to dynamically
348
349
# modify the firewall in response to access
350
351
# from different clients. See man
352
353
# page for more info on learn-address script.
354
355
;learn-address ./script
356
357
358
359
# If enabled, this directive will configure
360
361
# all clients to redirect their default
362
363
# network gateway through the VPN, causing
364
365
# all IP traffic such as web browsing and
366
367
# and DNS lookups to go through the VPN
368
369
# (The OpenVPN server machine may need to NAT
370
371
# or bridge the TUN/TAP interface to the internet
372
373
# in order for this to work properly).
374
375
push "redirect-gateway def1 bypass-dhcp"
376
377
378
379
# Certain Windows-specific network settings
380
381
# can be pushed to clients, such as DNS
382
383
# or WINS server addresses. CAVEAT:
384
386
387
# The addresses below refer to the public
388
389
# DNS servers provided by opendns.com.
390
391
push "dhcp-option DNS 208.67.222.222"
392
393
push "dhcp-option DNS 208.67.220.220"
394
395
396
397
# Uncomment this directive to allow different
398
399
# clients to be able to "see" each other.
400
401
# By default, clients will only see the server.
402
403
# To force clients to only see the server, you
404
405
# will also need to appropriately firewall the
406
407
# server's TUN/TAP interface.
408
409
;client-to-client
410
411
412
413
# Uncomment this directive if multiple clients
414
415
# might connect with the same certificate/key
416
417
# files or common names. This is recommended
418
419
# only for testing purposes. For production use,
420
421
# each client should have its own certificate/key
422
423
# pair.
424
425
#
426
427
# IF YOU HAVE NOT GENERATED INDIVIDUAL
428
429
# CERTIFICATE/KEY PAIRS FOR EACH CLIENT,
430
431
# EACH HAVING ITS OWN UNIQUE "COMMON NAME",
432
433
# UNCOMMENT THIS LINE OUT.
434
435
;duplicate-cn
436
437
438
439
# The keepalive directive causes ping-like
440
441
# messages to be sent back and forth over
442
443
# the link so that each side knows when
444
445
# the other side has gone down.
446
447
# Ping every 10 seconds, assume that remote
448
449
# peer is down if no ping received during
450
451
# a 120 second time period.
452
453
keepalive 10 120
454
455
456
457
# For extra security beyond that provided
458
459
# by SSL/TLS, create an "HMAC firewall"
460
461
# to help block DoS attacks and UDP port flooding.
462
463
#
464
465
# Generate with:
466
467
# openvpn --genkey --secret ta.key
468
469
#
470
471
# The server and each client must have
472
473
# a copy of this key.
474
475
# The second parameter should be '0'
476
477
# on the server and '1' on the clients.
478
479
tls-auth /home/pi/pki/private/ta.key 0 # This file is secret
480
481
482
483
# Select a cryptographic cipher.
484
485
# This config item must be copied to
486
487
# the client config file as well.
488
489
;cipher BF-CBC # Blowfish (default)
490
491
cipher AES-128-CBC # AES
492
493
;cipher DES-EDE3-CBC # Triple-DES
494
495
496
497
# Enable compression on the VPN link.
498
499
# If you enable it here, you must also
500
501
# enable it in the client config file.
502
503
comp-lzo
504
505
506
507
# The maximum number of concurrently connected
508
509
# clients we want to allow.
510
511
;max-clients 100
512
513
514
515
# It's a good idea to reduce the OpenVPN
516
517
# daemon's privileges after initialization.
518
519
#
520
521
# You can uncomment this out on
522
523
# non-Windows systems.
524
525
user nobody
526
527
group nogroup
528
529
530
531
# The persist options will try to avoid
532
533
# accessing certain resources on restart
534
535
# that may no longer be accessible because
536
537
# of the privilege downgrade.
538
539
persist-key
540
541
persist-tun
542
543
544
545
# Output a short status file showing
546
547
# current connections, truncated
548
549
# and rewritten every minute.
550
551
status /home/pi/Documents/openvpn-status.log
552
553
554
555
# By default, log messages will go to the syslog (or
556
557
# on Windows, if running as a service, they will go to
558
559
# the "\Program Files\OpenVPN\log" directory).
560
561
# Use log or log-append to override this default.
562
563
# "log" will truncate the log file on OpenVPN startup,
564
565
# while "log-append" will append to it. Use one
566
567
# or the other (but not both).
568
569
log /home/pi/Documents/openvpn.log
570
571
log-append /home/pi/Documents/openvpnappend.log
572
573
574
575
# Set the appropriate level of log
576
577
# file verbosity.
578
579
#
580
581
# 0 is silent, except for fatal errors
582
583
# 4 is reasonable for general usage
584
585
# 5 and 6 can help to debug connection problems
586
587
# 9 is extremely verbose
588
589
verb 9
590
591
592
593
# Silence repeating messages. At most 20
594
595
# sequential messages of the same message
596
597
# category will be output to the log.
598
599
;mute 20
600
601
602
603
up "/etc/openvpn/up.sh br0"
604
605
down "/etc/openvpn/down.sh br0"
606
1
port 1194
2
proto tcp
3
proto udp
4
dev tap0
5
ca /home/pi/pki/ca.crt
6
cert /home/pi/pki/issued/rpi0.crt
7
key /home/pi/pki/private/rpi0.key
8
dh "/home/pi/pki/dh.pem"
9
server-bridge 192.168.1.73 255.255.255.0 192.168.1.90 192.168.1.99
10
ifconfig-pool-persist ipp.txt
11
push "route 192.168.1.254 255.255.255.0"
12
push "redirect-gateway def1 bypass-dhcp"
13
push "dhcp-option DNS 208.67.222.222"
14
push "dhcp-option DNS 208.67.220.220"
15
keepalive 10 120
16
tls-auth /home/pi/pki/private/ta.key 0
17
cipher AES-128-CBC
18
comp-lzo
19
user nobody
20
group nogroup
21
persist-key
22
persist-tun
23
status /home/pi/Documents/openvpn-status.log
24
log /home/pi/Documents/openvpn.log
25
log-append /home/pi/Documents/openvpnappend.log
26
verb 9
27
up "/etc/openvpn/up.sh br0"
28
down "/etc/openvpn/down.sh br0"