Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
technical:openvpn_setup [2018/12/03 08:08] – [DD-WRT Router Setup] bob | technical:openvpn_setup [2018/12/20 13:18] (current) – [Generate the master Certificate Authority (CA) certificate & key] bob | ||
---|---|---|---|
Line 47: | Line 47: | ||
==== Generate the master Certificate Authority (CA) certificate & key ==== | ==== Generate the master Certificate Authority (CA) certificate & key ==== | ||
- | Use easy-rsa 2, a set of scripts which is bundled with OpenVPN. With the Windows OpenVPN client open up a Command Prompt window with administrative privileges and cd to c:\Program Files\OpenVPN\easy-rsa. Run the following batch file to copy configuration files into place (this will overwrite any preexisting vars.bat and openssl.cnf files): | + | Use easy-rsa 2, a set of scripts which is bundled with OpenVPN. With the Windows OpenVPN client open up a Command Prompt window with administrative privileges and cd to c:\Program Files\OpenVPN\easy-rsa. Run the following batch file to copy configuration files into place (this will overwrite any preexisting vars.bat and openssl.cnf files). Skip this if you already have vars.bat setup the way you like it. : |
< | < | ||
Line 71: | Line 71: | ||
build-ca | build-ca | ||
</ | </ | ||
+ | |||
+ | The " | ||
+ | |||
+ | < | ||
+ | # Build a cert authority valid for ten years, starting now | ||
+ | openssl req -days 3650 -nodes -new -x509 -keyout %KEY_DIR%\ca.key -out %KEY_DIR%\ca.crt -config %KEY_CONFIG% | ||
+ | </ | ||
+ | |||
+ | Substitute " | ||
The final command (build-ca) will build the certificate authority (CA) certificate and key by invoking the interactive openssl command. My certificate looked like: | The final command (build-ca) will build the certificate authority (CA) certificate and key by invoking the interactive openssl command. My certificate looked like: | ||
Line 220: | Line 229: | ||
- | ==== Generate | + | ==== Generate |
Generate a certificate and private key for the server. On Windows: | Generate a certificate and private key for the server. On Windows: | ||
Line 233: | Line 242: | ||
* “1 out of 1 certificate requests certified, commit? [y/n]”. | * “1 out of 1 certificate requests certified, commit? [y/n]”. | ||
- | ==== Generate | + | The " |
+ | |||
+ | < | ||
+ | # Build a request for a cert that will be valid for ten years | ||
+ | openssl req -days 3650 -nodes -new -keyout %KEY_DIR%\%1.key -out %KEY_DIR%\%1.csr -config %KEY_CONFIG% | ||
+ | # Sign the cert request with our ca, creating a cert/key pair | ||
+ | openssl ca -days 3650 -out %KEY_DIR%\%1.crt -in %KEY_DIR%\%1.csr -extensions server -config %KEY_CONFIG% | ||
+ | </ | ||
+ | |||
+ | ==== Generate | ||
Generating client certificates is very similar to the previous step. On Windows: | Generating client certificates is very similar to the previous step. On Windows: | ||
Line 244: | Line 262: | ||
Remember that for each client, make sure to type the appropriate Common Name when prompted, i.e. “client1”, | Remember that for each client, make sure to type the appropriate Common Name when prompted, i.e. “client1”, | ||
+ | |||
+ | The “build-key” command generates client files by first building a Certificate Signing Request (CSR) and then signing the CSR. It issues these OpenSSL commands: | ||
+ | |||
+ | < | ||
+ | # Build a request for a cert that will be valid for ten years | ||
+ | openssl req -days 3650 -nodes -new -keyout %KEY_DIR%\%1.key -out %KEY_DIR%\%1.csr -config %KEY_CONFIG% | ||
+ | # Sign the cert request with our ca, creating a cert/key pair | ||
+ | openssl ca -days 3650 -out %KEY_DIR%\%1.crt -in %KEY_DIR%\%1.csr -config %KEY_CONFIG% | ||
+ | </ | ||
Clients can generate their own private key locally. To do this they submit a Certificate Signing Request (CSR) to the key signer. The key-signer can then processed the CSR and returned a signed certificate to the client. | Clients can generate their own private key locally. To do this they submit a Certificate Signing Request (CSR) to the key signer. The key-signer can then processed the CSR and returned a signed certificate to the client. | ||
- | ==== Generate Diffie Hellman | + | |
+ | ==== Generate Diffie Hellman | ||
Diffie Hellman parameters must be generated for the OpenVPN server. On Windows: | Diffie Hellman parameters must be generated for the OpenVPN server. On Windows: | ||
Line 276: | Line 304: | ||
[[https:// | [[https:// | ||
- | To avoid IP address conflicts in a routed configuration: | + | Here is another great article on setting up a [[https:// |
+ | |||
+ | When using tunneling mode, to avoid IP address conflicts in a routed configuration: | ||
* the private LAN IP subnet | * the private LAN IP subnet | ||
Line 282: | Line 312: | ||
* the remote LAN subnet | * the remote LAN subnet | ||
- | must all be different from each other. | + | must all be different from each other. I used bridge mode and avoided all the routing stuff. |
Choose subnets for the private LAN and the VPN that are unlikely to conflict. I chose 192.168.100.x for my home LAN. | Choose subnets for the private LAN and the VPN that are unlikely to conflict. I chose 192.168.100.x for my home LAN. | ||
Line 288: | Line 318: | ||
==== Customizable Web Page Setup Parameters ==== | ==== Customizable Web Page Setup Parameters ==== | ||
- | * DD-WRT default settings in {} | + | <WRAP center round tip 80%> |
- | * OpenVPN config example | + | Settings are stored |
+ | </ | ||
^ Setting | ^ Setting | ||
- | | Start Type | Use " | + | | Start Type | Use " |
- | | Server Mode | The mode of tunneling. TUN: routing (layer 3), TAP: bridging networks (layer 2). | {} [dev-type tun/ | + | | Server Mode | The mode of tunneling. TUN: routing (layer 3), TAP: bridging networks (layer 2). | | |
- | | DHCP-Proxy mode | Only in bridge mode. Let the clients use the network DHCP server not the OpenVPN DHCP. | {} [] | | + | | DHCP-Proxy mode | Only in bridge mode. Let the clients use the network DHCP server not the OpenVPN DHCP. | | |
- | | Pool start IP | 1st IP of the IP pool used (Only in bridge mode). | [] | | + | | Pool start IP | 1st IP of the IP pool used (Only in bridge mode). | | |
- | | Pool end IP | Last IP of the IP pool used (Only in bridge mode). | [] | | + | | Pool end IP | Last IP of the IP pool used (Only in bridge mode). | | |
- | | Gateway | Default gateway to use (Only in bridge mode). | [] | | + | | Gateway | Default gateway to use (Only in bridge mode). | | |
- | | Network (e.g. 10.10.10.0) | Network to use for the tunnel (Only in routing mode). | [] | | + | | Network (e.g. 10.10.10.0) | Network to use for the tunnel (Only in routing mode). | | |
- | | Netmask (e.g. 255.255.255.0) | Netmask of the used network. | [] | | + | | Netmask (e.g. 255.255.255.0) | Netmask of the used network. | | |
- | | Block DHCP accross | + | | Block DHCP across |
- | | Port | Port which OpenVPN server listens on. | {1194} [port xxx] | | + | | Port | Port which OpenVPN server listens on. | 1194 | |
- | | Tunnel Protocol | The subprotocol the connection will use on the real used tcp connection. | {udp} [proto udp/ | + | | Tunnel Protocol | The subprotocol the connection will use on the real used tcp connection. | UDP | |
- | | Encryption Cipher | The encryption algorithm that will be used for the tunnel. Blowfish: fastest to AES512 safest. | {AES128} [cipher xxx] | | + | | Encryption Cipher | The encryption algorithm that will be used for the tunnel. Blowfish: fastest to AES512 safest. | AES128 | |
- | | Hash Algorithm (None and MD4 to SHA512) | The hash algorithm that will be used. MD4: fastest (maybe unsafe) to SHA512. | {SHA256} [auth xxx] | | + | | Hash Algorithm (None and MD4 to SHA512) | The hash algorithm that will be used. MD4: fastest (maybe unsafe) to SHA512. | SHA256 | |
- | | Advanced options | Leave defaults as is if you dont know what you are doing. | {disabled} | | + | | Advanced options | Leave defaults as is if you dont know what you are doing. | disabled | |
- | | LZO Compression | Enables compression over VPN. This might speedup the connection. Must be the same value as on server. | {yes} [comp-lzo yes/ | + | | LZO Compression | Enables compression over VPN. This might speedup the connection. Must be the same value as on server. | yes | |
- | | Redirect default Gateway | Force the clients to use the tunnel as default gateway. | {disabled} [] | | + | | Redirect default Gateway | Force the clients to use the tunnel as default gateway. | disabled | |
- | | Allow Client to Client | Allow clients to see each other. | {disabled} [client-to-client] | + | | Allow Client to Client | Allow clients to see each other. | disabled | |
| Allow duplicate cn | Allow to use 1 client cert to use on multiple clients (security risk) | | | | Allow duplicate cn | Allow to use 1 client cert to use on multiple clients (security risk) | | | ||
- | | TUN MTU Setting | Set the MTU of the tunnel | {1500} [tun-mtu xxx] | | + | | TUN MTU Setting | Set the MTU of the tunnel | 1500 | |
- | | MSS-Fix/ | + | | MSS-Fix/ |
- | | TLS Cipher | What encryption algorithm OpenVPN should use for encrypting its control channel. | {disabled} [] | | + | | TLS Cipher | What encryption algorithm OpenVPN should use for encrypting its control channel. | disabled | |
- | | Additional Config | Any additional configurations you want to define for the VPN connection. | {empty} | + | | Additional Config | Any additional configurations you want to define for the VPN connection. | | |
| Public Server Cert | Server certificate issued by CA for this particular router (usually server.crt); | | Public Server Cert | Server certificate issued by CA for this particular router (usually server.crt); | ||
| CA Cert | The master key which is used to sign each of the server and client certificates. Certificate in PEM form (usually ca.crt); only part between (and including) -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- is necessary; as it is stored in NVRAM, everything else from that file should be removed to conserve space. | | | | CA Cert | The master key which is used to sign each of the server and client certificates. Certificate in PEM form (usually ca.crt); only part between (and including) -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- is necessary; as it is stored in NVRAM, everything else from that file should be removed to conserve space. | | | ||
| Private Server Key | Key associated with certificate above (usually server.key); | | Private Server Key | Key associated with certificate above (usually server.key); | ||
| DH PEM | Diffie Hellman parameters generated for the OpenVPN server (usually dh1024.pem) | | | | DH PEM | Diffie Hellman parameters generated for the OpenVPN server (usually dh1024.pem) | | | ||
- | | Additional Config | Any additional configurations you want to define for the VPN connection. | {empty} | + | | Additional Config | Any additional configurations you want to define for the VPN connection. | | |
| TLS Auth Key | The static key OpenVPN should use for generating HMAC send/ | | TLS Auth Key | The static key OpenVPN should use for generating HMAC send/ | ||
| Certificate Revoke List | | | | | Certificate Revoke List | | | |