e90566c78e3018cf2a9141f94227a3ee60721302
[librecmc/librecmc.git] / docs / OpenVPN_Layer_2_Server.md
1 # OpenVPN Layer 2 Server
2
3 ## Introduction
4
5 Librecmc can operate as an OpenVPN server. OpenVPN technology connects
6 two networks via an encrypted tunnel. With proper server, network, and
7 client configuration, OpenVPN allows a client outside of your LAN to
8 see the LAN as though it were physically connected to the LAN.
9
10 OpenVPN can run in layer 2 or layer 3 mode. In layer 3 mode, the
11 remote client sees your LAN as though it is on the other side of an IP
12 router. In layer 2 mode, the remote client sees your LAN as though
13 they are both on the same Data Link segment (e.g., the same Ethernet
14 link). Layer 3 mode is easier to set up, but layer 2 mode is sometimes
15 desired to give clients a more direct exposure to services on the LAN.
16
17 ## Warnings
18
19 This information is provided for educational purposes only and is not
20 meant to be a guide to best network security practices. Readers are
21 advised to study all relevant OpenVPN and network security
22 documentation.
23
24 ## Required LibreCMC packages
25
26 * openvpn-openssl
27 * openvpn-easy-rsa
28 * luci-app-openvpn
29
30 ## Interface Setup
31
32 TODO
33
34 ## Certificate and Key Setup Instructions
35
36 ```
37 cd /etc/easy-rsa
38 source vars
39 clean-all
40 build-ca
41 build-dh
42 build-key-server myvpn
43 openvpn --genkey --secret /etc/easy-rsa/keys/ta.key
44 mkdir -m 700 /etc/openvpn/keys
45 mv ca.crt myvpn.crt myvpn.key dh2018.pem /etc/openvpn/keys
46 ```
47
48 N.B.: Using easy-rsa is a straightforward approach, but it may be
49 possible to produce more secure certificates using openssl directly.
50
51 ## Server configuration
52
53 For the `server bridge` option: The first two parameters are the ip
54 and netmask of the gateway on the bridged subnet. The next two
55 parameters indicate the pool-start-IP and pool-end-IP, which is the
56 part of your IP address pool that you have reserved just for VPN
57 clients. You must to make sure that the DHCP server for your LAN is
58 not leasing out those IP addresses to local (non-vpn) clients.
59
60 /etc/config/openvpn
61 ```
62 config openvpn 'myvpn'
63         option enabled '1'
64         option dev 'tap0'
65         option port '1194'
66         option proto 'udp'
67         option keepalive '10 120'
68         option persist_key '1'
69         option persist_tun '1'
70         option user 'nobody'
71         option group 'nogroup'
72         option ca '/etc/openvpn/keys/ca.crt'
73         option cert '/etc/openvpn/keys/myvpn.crt'
74         option key '/etc/openvpn/keys/myvpn.key'
75         option dh '/etc/openvpn/keys/dh2048.pem'
76         option tls_server '1'
77         option tls_auth '/etc/openvpn/keys/ta.key 0'
78         option server_bridge '10.0.0.1 255.255.255.0 10.0.0.201 10.0.0.220'
79         option client_to_client '1'
80         list push 'persist-key'
81         list push 'persist-tun'
82         list push 'redirect-gateway def1'
83         list push 'route 10.0.0.0 255.255.255.0'
84         list push 'dhcp-option DNS 10.0.0.1'
85         option mute '15'
86         option verb '3'
87 ```
88
89 ## Client setup information
90
91 TODO