0284.html 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Setting Up OpenWRT OpenVPN Server and Certificate Creation</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta charset="UTF-8">
  7. <meta name="keywords" content="Home Lab Ideas,Home Lab,Install Guide,Free Software,Linux,OpenWRT,Router,Networking,VPN Solution,Self-Hosted VPN,VPN Server,OVPN,OpenVPN,VPN,Installation,How To Run OpenVPN Server On OpenWRT,How To Install OpenVPN Server On OpenWRT,How To,Tutorial,i12bretro">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Setting Up OpenWRT OpenVPN Server and Certificate Creation">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <meta name="revised" content="10/09/2022 06:36:08 AM" />
  12. <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
  13. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  14. <script type="text/javascript" src="includes/js/steps.js"></script>
  15. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="gridContainer">
  19. <div class="topMargin"></div>
  20. <div id="listName" class="topMargin">
  21. <h1>Setting Up OpenWRT OpenVPN Server and Certificate Creation</h1>
  22. </div>
  23. <div></div>
  24. <div id="content">
  25. <h2>Create Required Certificates</h2>
  26. <ol>
  27. <li>Launch XCA</li>
  28. <li>Open the PKI database if it is not already (File &gt; Open DataBase), enter password</li>
  29. <li>Click on the Certificates tab, right click on your Intermediate CA certificate</li>
  30. <li>Select New</li>
  31. <li>On the Source tab, make sure Use this Certificate for signing is selected</li>
  32. <li>Verify your Intermediate CA certificate is selected from the drop down</li>
  33. <li>Click the Subject tab</li>
  34. <li>Complete the Distinguished Name section
  35. <p>internalName: OpenVPN Server<br />
  36. countryName: US<br />
  37. stateOrProvinceName: Virginia<br />
  38. localityName: Northern<br />
  39. organizationName: i12bretro<br />
  40. organizationUnitName: i12bretro Certificate Authority<br />
  41. commonName: vpn.i12bretro.local</p>
  42. </li>
  43. <li>Click the Generate a New Key button</li>
  44. <li>Enter a name and set the key size to at least 2048</li>
  45. <li>Click Create</li>
  46. <li>Click on the Extensions tab</li>
  47. <li>Set the Type dropdown to End Endity</li>
  48. <li>Check the box next to Subject Key Identifier</li>
  49. <li>Update the validity dates to fit your needs</li>
  50. <li>Click the Key Usage tab</li>
  51. <li>Under Key Usage select Digital Signature and Key Encipherment</li>
  52. <li>Under Extended Key Usage select TLS Web Server Authentication</li>
  53. <li>Click the Netscape tab</li>
  54. <li>Deselect all options and clear the Netscape Comment field</li>
  55. <li>Click OK to create the certificate</li>
  56. <li>Click on the Certificates tab, right click on your Intermediate CA certificate again</li>
  57. <li>Select New</li>
  58. <li>On the Source tab, make sure Use this Certificate for signing is selected</li>
  59. <li>Verify your Intermediate CA certificate is selected from the drop down</li>
  60. <li>Click the Subject tab</li>
  61. <li>Complete the Distinguished Name section
  62. <p>internalName: OpenVPN Client #1<br />
  63. countryName: US<br />
  64. stateOrProvinceName: Virginia<br />
  65. localityName: Northern<br />
  66. organizationName: i12bretro<br />
  67. organizationUnitName: i12bretro Certificate Authority<br />
  68. commonName: VPN Client 1</p>
  69. </li>
  70. <li>Click the Generate a New Key button</li>
  71. <li>Enter a name and set the key size to at least 2048</li>
  72. <li>Click Create</li>
  73. <li>Click on the Extensions tab</li>
  74. <li>Set the Type dropdown to End Endity</li>
  75. <li>Check the box next to Subject Key Identifier</li>
  76. <li>Update the validity dates to fit your needs</li>
  77. <li>Click the Key Usage tab</li>
  78. <li>Under Key Usage select Digital Signature, Key Agreement</li>
  79. <li>Under Extended Key Usage select TLS Web Client Authentication</li>
  80. <li>Click the Netscape tab</li>
  81. <li>Deselect all options and clear the Netscape Comment field</li>
  82. <li>Click OK to create the certificate</li>
  83. <li>On the Certificates tab, click the OpenVPN Server certificate</li>
  84. <li>Select Extra &gt; Generate DH Parameter</li>
  85. <li>Type 2048 for DH parameter bits</li>
  86. <li>Click OK</li>
  87. <li>Select a location for dh2048.pem and click Save</li>
  88. </ol>
  89. <h2>Exporting Required Files for OpenVPN</h2>
  90. <ol>
  91. <li>In XCA, click on the Certificates tab</li>
  92. <li>Right click the Intermediate CA certificate &gt; Export &gt; File</li>
  93. <li>Set the file name with a .pem extension and verify the export format is PEM chain (*.pem)</li>
  94. <li>Click OK</li>
  95. <li>Right click the OpenVPN Server certificate &gt; Export &gt; File</li>
  96. <li>Set the file name with a .crt extension and verify the export format is PEM (*.crt)</li>
  97. <li>Click OK</li>
  98. <li>Right click the OpenVPN Client #1 certificate &gt; Export &gt; File</li>
  99. <li>Set the file name with a .crt extension and verify the export format is PEM (*.crt)</li>
  100. <li>Click OK</li>
  101. <li>Click on the Private Keys tab</li>
  102. <li>Right click the OpenVPN Server key &gt; Export &gt; File</li>
  103. <li>Set the file name with a .pk8 extension and verify the export format is PKCS #8 (*.pk8)</li>
  104. <li>Click OK</li>
  105. <li>Right click the OpenVPN Client #1 key&gt; Export &gt; File</li>
  106. <li>Set the file name with a .pk8 extension and verify the export format is PKCS #8 (*.pk8)</li>
  107. <li>Click OK</li>
  108. </ol>
  109. <h2>Setting Up OpenVPN Server in OpenWRT</h2>
  110. <ol>
  111. <li>Open a web browser and navigate to your OpenWRT IP address</li>
  112. <li>Login when prompted</li>
  113. <li>Select System &gt; Software from the navigation menu</li>
  114. <li>Click on the Update lists button to update the software repositories</li>
  115. <li>Click the Dismiss button once the update has completed</li>
  116. <li>Type openvpn in the filter field</li>
  117. <li>Click the Install... button next to openvpn-openssl</li>
  118. <li>Click the Install button to confirm installing with dependencies</li>
  119. <li>Click the Dismiss button once the install has completed</li>
  120. <li>Click the Install... button next to luci-app-openvpn</li>
  121. <li>Click the Install button to confirm installing with dependencies</li>
  122. <li>Click the Dismiss button once the install has completed</li>
  123. <li>Refresh the browser window</li>
  124. <li>Select VPN &gt; OpenVPN from the navigation menu</li>
  125. <li>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 &gt; Click Add</li>
  126. <li>Click the Edit button across from the newly created OpenVPNServer entry</li>
  127. <li>Next to ca, click the button, browse to and upload the previously exported CA .pem file</li>
  128. <li>Select the ca .pem file to be used</li>
  129. <li>Next to dh, click the button, browse to and upload the previously exported dh2048.pem file</li>
  130. <li>Select the dh2048.pem file to be used</li>
  131. <li>Next to cert, click the button, browse to and upload the previously exported OpenVPN server .crt file</li>
  132. <li>Select the .crt file to be used</li>
  133. <li>Next to key, click the button, browse to and upload the previously exported OpenVPN server .pk8 file</li>
  134. <li>Select the ca .pk8 file to be used</li>
  135. <li>Click the Additional Field dropdown &gt; Select proto &gt; Click Add</li>
  136. <li>Set the value of proto to udp</li>
  137. <li>Click the Additional Field dropdown &gt; Select port &gt; Click Add</li>
  138. <li>Set the value of port to 1194</li>
  139. <li>Click the Additional Field dropdown &gt; Select dev_type &gt; Click Add</li>
  140. <li>Set the value of dev_type to tun</li>
  141. <li>Scroll to the bottom of the page and click the Save &amp; Apply button</li>
  142. <li>Select VPN &gt; OpenVPN from the navigation menu</li>
  143. <li>Check the Enabled checkbox next to the OpenVPNServer entry and click the Save &amp; Apply button</li>
  144. <li>After a few seconds the page will refresh and the OpenVPN server should be running<br />
  145. <span style="font-size:16px;"><em>NOTE: If the server is not running, check the system logs for troubleshooting by selecting Status &gt; System Log from the navigation menu</em></span></li>
  146. </ol>
  147. <h2>Installing OpenVPN Client Software and Testing</h2>
  148. <ol>
  149. <li>Download the OpenVPN software <a href="https://openvpn.net/community-downloads/" target="_blank">Download</a></li>
  150. <li>Run the installer with all the default values</li>
  151. <li>Click the Start button and search OpenVPN GUI</li>
  152. <li>Select OpenVPN GUI from the results to start the application</li>
  153. </ol>
  154. <h2>Creating the OpenVPN Client Profile</h2>
  155. <ol>
  156. <li>Download the OVPN template <a href="https://drive.google.com/open?id=1cwgQfCoQmDOMbY1kW7JK4q07ijHdl37y" target="_blank">Download</a></li>
  157. <li>Rename the .ovpn template something meaningful</li>
  158. <li>Edit the .ovpn template replacing the following:
  159. <p>&lt;#replace with dynamic dns#&gt; with a dynamic DNS or external IP address to your server<br />
  160. &lt;#replace with CA chain#&gt; with the contents of CA_Chain.pem<br />
  161. &lt;#replace with client 1 cert #&gt; with the contents of OpenVPN_Client #1.crt<br />
  162. &lt;#replace with client 1 key #&gt; with the contents of OpenVPN_Client #1.pk8</p>
  163. </li>
  164. <li>Save your changes</li>
  165. <li>Copy the .ovpn template to OpenVPN install directory/config</li>
  166. <li>Right click OpenVPN GUI in the system tray &gt; Connect</li>
  167. </ol> </div>
  168. </div>
  169. </body>
  170. </html>