wolfssl: Update to v4.6.0-stable
[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 In LuCi, select `Network` >> `Interfaces` and then `Add New Interface`.
33
34 - Set `Name of the new interface` to `myvpn` or anything else you would like.
35 - Set `Protocol of the new interface` to unmanaged.
36 - Set `Cover the following interface` to `Custom Interface: vpn0`.
37 - In my current working system, the `firewall-zone` for the interface
38   is set to `lan`, but I don't think that really matters in this case.
39
40 In my working configuration, I added tap0 into the LAN bridge
41 interface, and deleted the WAN interface. However, my vpn server is a
42 separate unit on my network, intended to operate in "bridge mode",
43 where if you server is your gateway router, a different configuration
44 might be necessary.
45
46 ## Certificate and Key Setup Instructions
47
48 ```
49 cd /etc/easy-rsa
50 source vars
51 clean-all
52 build-ca
53 build-dh
54 build-key-server myvpn
55 openvpn --genkey --secret /etc/easy-rsa/keys/ta.key
56 mkdir -m 700 /etc/openvpn/keys
57 mv ca.crt myvpn.crt myvpn.key dh2018.pem /etc/openvpn/keys
58 ```
59
60 N.B.: Using easy-rsa is a straightforward approach, but it may be
61 possible to produce more secure certificates using openssl directly.
62
63 ## Server configuration
64
65 For the `server bridge` option: The first two parameters are the ip
66 and netmask of the gateway on the bridged subnet. The next two
67 parameters indicate the pool-start-IP and pool-end-IP, which is the
68 part of your IP address pool that you have reserved just for VPN
69 clients. You must to make sure that the DHCP server for your LAN is
70 not leasing out those IP addresses to local (non-vpn) clients.
71
72 /etc/config/openvpn
73 ```
74 config openvpn 'myvpn'
75         option enabled '1'
76         option dev 'tap0'
77         option port '1194'
78         option proto 'udp'
79         option keepalive '10 120'
80         option persist_key '1'
81         option persist_tun '1'
82         option user 'nobody'
83         option group 'nogroup'
84         option ca '/etc/openvpn/keys/ca.crt'
85         option cert '/etc/openvpn/keys/myvpn.crt'
86         option key '/etc/openvpn/keys/myvpn.key'
87         option dh '/etc/openvpn/keys/dh2048.pem'
88         option tls_server '1'
89         option tls_auth '/etc/openvpn/keys/ta.key 0'
90         option server_bridge '10.0.0.1 255.255.255.0 10.0.0.201 10.0.0.220'
91         option client_to_client '1'
92         list push 'persist-key'
93         list push 'persist-tun'
94         list push 'redirect-gateway def1'
95         list push 'route 10.0.0.0 255.255.255.0'
96         list push 'dhcp-option DNS 10.0.0.1'
97         option mute '15'
98         option verb '3'
99 ```
100
101 ## Client setup information
102
103 TODO