From b54d77527b0e6922b03fead40c4f94ccd8cbcc5f Mon Sep 17 00:00:00 2001 From: i12bretro <54692756+i12bretro@users.noreply.github.com> Date: Mon, 17 Jan 2022 19:50:31 -0500 Subject: [PATCH] 0284: Setting Up OpenWRT OpenVPN Server and Certificate Creation --- 0284.html | 238 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 238 insertions(+) create mode 100644 0284.html diff --git a/0284.html b/0284.html new file mode 100644 index 0000000..3b41975 --- /dev/null +++ b/0284.html @@ -0,0 +1,238 @@ + + + + Setting Up OpenWRT OpenVPN Server and Certificate Creation + + + + + + +
+
+
+

Setting Up OpenWRT OpenVPN Server and Certificate Creation

+
+
+
+

Create Required Certificates

+ +
    +
  1. Launch XCA
  2. +
  3. Open the PKI database if it is not already (File > Open DataBase), enter password
  4. +
  5. Click on the Certificates tab, right click on your Intermediate CA certificate
  6. +
  7. Select New
  8. +
  9. On the Source tab, make sure Use this Certificate for signing is selected
  10. +
  11. Verify your Intermediate CA certificate is selected from the drop down
  12. +
  13. Click the Subject tab
  14. +
  15. Complete the Distinguished Name section +

    internalName: OpenVPN Server
    + countryName: US
    + stateOrProvinceName: Virginia
    + localityName: Northern
    + organizationName: i12bretro
    + organizationUnitName: i12bretro Certificate Authority
    + commonName: vpn.i12bretro.local

    +
  16. +
  17. Click the Generate a New Key button
  18. +
  19. Enter a name and set the key size to at least 2048
  20. +
  21. Click Create
  22. +
  23. Click on the Extensions tab
  24. +
  25. Set the Type dropdown to End Endity
  26. +
  27. Check the box next to Subject Key Identifier
  28. +
  29. Update the validity dates to fit your needs
  30. +
  31. Click the Key Usage tab
  32. +
  33. Under Key Usage select Digital Signature and Key Encipherment
  34. +
  35. Under Extended Key Usage select TLS Web Server Authentication
  36. +
  37. Click the Netscape tab
  38. +
  39. Deselect all options and clear the Netscape Comment field
  40. +
  41. Click OK to create the certificate
  42. +
  43. Click on the Certificates tab, right click on your Intermediate CA certificate again
  44. +
  45. Select New
  46. +
  47. On the Source tab, make sure Use this Certificate for signing is selected
  48. +
  49. Verify your Intermediate CA certificate is selected from the drop down
  50. +
  51. Click the Subject tab
  52. +
  53. Complete the Distinguished Name section +

    internalName: OpenVPN Client #1
    + countryName: US
    + stateOrProvinceName: Virginia
    + localityName: Northern
    + organizationName: i12bretro
    + organizationUnitName: i12bretro Certificate Authority
    + commonName: VPN Client 1

    +
  54. +
  55. Click the Generate a New Key button
  56. +
  57. Enter a name and set the key size to at least 2048
  58. +
  59. Click Create
  60. +
  61. Click on the Extensions tab
  62. +
  63. Set the Type dropdown to End Endity
  64. +
  65. Check the box next to Subject Key Identifier
  66. +
  67. Update the validity dates to fit your needs
  68. +
  69. Click the Key Usage tab
  70. +
  71. Under Key Usage select Digital Signature, Key Agreement
  72. +
  73. Under Extended Key Usage select TLS Web Client Authentication
  74. +
  75. Click the Netscape tab
  76. +
  77. Deselect all options and clear the Netscape Comment field
  78. +
  79. Click OK to create the certificate
  80. +
  81. On the Certificates tab, click the OpenVPN Server certificate
  82. +
  83. Select Extra > Generate DH Parameter
  84. +
  85. Type 2048 for DH parameter bits
  86. +
  87. Click OK
  88. +
  89. Select a location for dh2048.pem and click Save
  90. +
+ +

Exporting Required Files for OpenVPN

+ +
    +
  1. In XCA, click on the Certificates tab
  2. +
  3. Right click the Intermediate CA certificate > Export > File
  4. +
  5. Set the file name with a .pem extension and verify the export format is PEM chain (*.pem)
  6. +
  7. Click OK
  8. +
  9. Right click the OpenVPN Server certificate > Export > File
  10. +
  11. Set the file name with a .crt extension and verify the export format is PEM (*.crt)
  12. +
  13. Click OK
  14. +
  15. Right click the OpenVPN Client #1 certificate > Export > File
  16. +
  17. Set the file name with a .crt extension and verify the export format is PEM (*.crt)
  18. +
  19. Click OK
  20. +
  21. Click on the Private Keys tab
  22. +
  23. Right click the OpenVPN Server key > Export > File
  24. +
  25. Set the file name with a .pk8 extension and verify the export format is PKCS #8 (*.pk8)
  26. +
  27. Click OK
  28. +
  29. Right click the OpenVPN Client #1 key> Export > File
  30. +
  31. Set the file name with a .pk8 extension and verify the export format is PKCS #8 (*.pk8)
  32. +
  33. Click OK
  34. +
+ +

Setting Up OpenVPN Server in OpenWRT

+ +
    +
  1. Open a web browser and navigate to your OpenWRT IP address
  2. +
  3. Login when prompted
  4. +
  5. Select System > Software from the navigation menu
  6. +
  7. Click on the Update lists button to update the software repositories
  8. +
  9. Click the Dismiss button once the update has completed
  10. +
  11. Type openvpn in the filter field
  12. +
  13. Click the Install... button next to openvpn-openssl
  14. +
  15. Click the Install button to confirm installing with dependencies
  16. +
  17. Click the Dismiss button once the install has completed
  18. +
  19. Click the Install... button next to luci-app-openvpn
  20. +
  21. Click the Install button to confirm installing with dependencies
  22. +
  23. Click the Dismiss button once the install has completed
  24. +
  25. Refresh the browser window
  26. +
  27. Select VPN > OpenVPN from the navigation menu
  28. +
  29. Under the Template based configuration heading, enter OpenVPNServer as the Instance name and select Server configuration for a routed multi-client VPN as the template > Click Add
  30. +
  31. Click the Edit button across from the newly created OpenVPNServer entry
  32. +
  33. Next to ca, click the button, browse to and upload the previously exported CA .pem file
  34. +
  35. Select the ca .pem file to be used
  36. +
  37. Next to dh, click the button, browse to and upload the previously exported dh2048.pem file
  38. +
  39. Select the dh2048.pem file to be used
  40. +
  41. Next to cert, click the button, browse to and upload the previously exported OpenVPN server .crt file
  42. +
  43. Select the .crt file to be used
  44. +
  45. Next to key, click the button, browse to and upload the previously exported OpenVPN server .pk8 file
  46. +
  47. Select the ca .pk8 file to be used
  48. +
  49. Click the Additional Field dropdown > Select proto > Click Add
  50. +
  51. Set the value of proto to udp
  52. +
  53. Click the Additional Field dropdown > Select port > Click Add
  54. +
  55. Set the value of port to 1194
  56. +
  57. Click the Additional Field dropdown > Select dev_type > Click Add
  58. +
  59. Set the value of dev_type to tun
  60. +
  61. Scroll to the bottom of the page and click the Save & Apply button
  62. +
  63. Select VPN > OpenVPN from the navigation menu
  64. +
  65. Check the Enabled checkbox next to the OpenVPNServer entry and click the Save & Apply button
  66. +
  67. After a few seconds the page will refresh and the OpenVPN server should be running
    + NOTE: If the server is not running, check the system logs for troubleshooting by selecting Status > System Log from the navigation menu
  68. +
+ +

Installing OpenVPN Client Software and Testing

+ +
    +
  1. Download the OpenVPN software Download
  2. +
  3. Run the installer with all the default values
  4. +
  5. Click the Start button and search OpenVPN GUI
  6. +
  7. Select OpenVPN GUI from the results to start the application
  8. +
+ +

Creating the OpenVPN Client Profile

+ +
    +
  1. Download the OVPN template Download
  2. +
  3. Rename the .ovpn template something meaningful
  4. +
  5. Edit the .ovpn template replacing the following: +

    <#replace with dynamic dns#> with a dynamic DNS or external IP address to your server
    + <#replace with CA chain#> with the contents of CA_Chain.pem
    + <#replace with client 1 cert #> with the contents of OpenVPN_Client #1.crt
    + <#replace with client 1 key #> with the contents of OpenVPN_Client #1.pk8

    +
  6. +
  7. Save your changes
  8. +
  9. Copy the .ovpn template to OpenVPN install directory/config
  10. +
  11. Right click OpenVPN GUI in the system tray > Connect
  12. +
+
+
+ + + \ No newline at end of file