0284.html 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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/24/2022 10:45:03 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>Prerequisites</h2>
  26. <ul>
  27. <li class="noCheckbox">A XCA PKI database <a href="https://youtu.be/ezzj3x207lQ" target="_blank">https://youtu.be/ezzj3x207lQ</a></li>
  28. </ul>
  29. <h2>Create Required Certificates</h2>
  30. <ol>
  31. <li>Launch XCA</li>
  32. <li>Open the PKI database if it is not already (File &gt; Open DataBase), enter password</li>
  33. <li>Click on the Certificates tab, right click on your Intermediate CA certificate</li>
  34. <li>Select New</li>
  35. <li>On the Source tab, make sure Use this Certificate for signing is selected</li>
  36. <li>Verify your Intermediate CA certificate is selected from the drop down</li>
  37. <li>Click the Subject tab</li>
  38. <li>Complete the Distinguished Name section
  39. <p>internalName: OpenVPN Server<br />
  40. countryName: US<br />
  41. stateOrProvinceName: Virginia<br />
  42. localityName: Northern<br />
  43. organizationName: i12bretro<br />
  44. organizationUnitName: i12bretro Certificate Authority<br />
  45. commonName: vpn.i12bretro.local</p>
  46. </li>
  47. <li>Click the Generate a New Key button</li>
  48. <li>Enter a name and set the key size to at least 2048</li>
  49. <li>Click Create</li>
  50. <li>Click on the Extensions tab</li>
  51. <li>Set the Type dropdown to End Endity</li>
  52. <li>Check the box next to Subject Key Identifier</li>
  53. <li>Update the validity dates to fit your needs</li>
  54. <li>Click the Key Usage tab</li>
  55. <li>Under Key Usage select Digital Signature and Key Encipherment</li>
  56. <li>Under Extended Key Usage select TLS Web Server Authentication</li>
  57. <li>Click the Netscape tab</li>
  58. <li>Deselect all options and clear the Netscape Comment field</li>
  59. <li>Click OK to create the certificate</li>
  60. <li>Click on the Certificates tab, right click on your Intermediate CA certificate again</li>
  61. <li>Select New</li>
  62. <li>On the Source tab, make sure Use this Certificate for signing is selected</li>
  63. <li>Verify your Intermediate CA certificate is selected from the drop down</li>
  64. <li>Click the Subject tab</li>
  65. <li>Complete the Distinguished Name section
  66. <p>internalName: OpenVPN Client #1<br />
  67. countryName: US<br />
  68. stateOrProvinceName: Virginia<br />
  69. localityName: Northern<br />
  70. organizationName: i12bretro<br />
  71. organizationUnitName: i12bretro Certificate Authority<br />
  72. commonName: VPN Client 1</p>
  73. </li>
  74. <li>Click the Generate a New Key button</li>
  75. <li>Enter a name and set the key size to at least 2048</li>
  76. <li>Click Create</li>
  77. <li>Click on the Extensions tab</li>
  78. <li>Set the Type dropdown to End Endity</li>
  79. <li>Check the box next to Subject Key Identifier</li>
  80. <li>Update the validity dates to fit your needs</li>
  81. <li>Click the Key Usage tab</li>
  82. <li>Under Key Usage select Digital Signature, Key Agreement</li>
  83. <li>Under Extended Key Usage select TLS Web Client Authentication</li>
  84. <li>Click the Netscape tab</li>
  85. <li>Deselect all options and clear the Netscape Comment field</li>
  86. <li>Click OK to create the certificate</li>
  87. <li>On the Certificates tab, click the OpenVPN Server certificate</li>
  88. <li>Select Extra &gt; Generate DH Parameter</li>
  89. <li>Type 2048 for DH parameter bits</li>
  90. <li>Click OK</li>
  91. <li>Select a location for dh2048.pem and click Save</li>
  92. </ol>
  93. <h2>Exporting Required Files for OpenVPN</h2>
  94. <ol>
  95. <li>In XCA, click on the Certificates tab</li>
  96. <li>Right click the Intermediate CA certificate &gt; Export &gt; File</li>
  97. <li>Set the file name with a .pem extension and verify the export format is PEM chain (*.pem)</li>
  98. <li>Click OK</li>
  99. <li>Right click the OpenVPN Server certificate &gt; Export &gt; File</li>
  100. <li>Set the file name with a .crt extension and verify the export format is PEM (*.crt)</li>
  101. <li>Click OK</li>
  102. <li>Right click the OpenVPN Client #1 certificate &gt; Export &gt; File</li>
  103. <li>Set the file name with a .crt extension and verify the export format is PEM (*.crt)</li>
  104. <li>Click OK</li>
  105. <li>Click on the Private Keys tab</li>
  106. <li>Right click the OpenVPN Server key &gt; Export &gt; File</li>
  107. <li>Set the file name with a .pk8 extension and verify the export format is PKCS #8 (*.pk8)</li>
  108. <li>Click OK</li>
  109. <li>Right click the OpenVPN Client #1 key&gt; Export &gt; File</li>
  110. <li>Set the file name with a .pk8 extension and verify the export format is PKCS #8 (*.pk8)</li>
  111. <li>Click OK</li>
  112. </ol>
  113. <h2>Setting Up OpenVPN Server in OpenWRT</h2>
  114. <ol>
  115. <li>Open a web browser and navigate to your OpenWRT IP address</li>
  116. <li>Login when prompted</li>
  117. <li>Select System &gt; Software from the navigation menu</li>
  118. <li>Click on the Update lists button to update the software repositories</li>
  119. <li>Click the Dismiss button once the update has completed</li>
  120. <li>Type openvpn in the filter field</li>
  121. <li>Click the Install... button next to openvpn-openssl</li>
  122. <li>Click the Install button to confirm installing with dependencies</li>
  123. <li>Click the Dismiss button once the install has completed</li>
  124. <li>Click the Install... button next to luci-app-openvpn</li>
  125. <li>Click the Install button to confirm installing with dependencies</li>
  126. <li>Click the Dismiss button once the install has completed</li>
  127. <li>Refresh the browser window</li>
  128. <li>Select VPN &gt; OpenVPN from the navigation menu</li>
  129. <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>
  130. <li>Click the Edit button across from the newly created OpenVPNServer entry</li>
  131. <li>Next to ca, click the button, browse to and upload the previously exported CA .pem file</li>
  132. <li>Select the ca .pem file to be used</li>
  133. <li>Next to dh, click the button, browse to and upload the previously exported dh2048.pem file</li>
  134. <li>Select the dh2048.pem file to be used</li>
  135. <li>Next to cert, click the button, browse to and upload the previously exported OpenVPN server .crt file</li>
  136. <li>Select the .crt file to be used</li>
  137. <li>Next to key, click the button, browse to and upload the previously exported OpenVPN server .pk8 file</li>
  138. <li>Select the ca .pk8 file to be used</li>
  139. <li>Click the Additional Field dropdown &gt; Select proto &gt; Click Add</li>
  140. <li>Set the value of proto to udp</li>
  141. <li>Click the Additional Field dropdown &gt; Select port &gt; Click Add</li>
  142. <li>Set the value of port to 1194</li>
  143. <li>Click the Additional Field dropdown &gt; Select dev_type &gt; Click Add</li>
  144. <li>Set the value of dev_type to tun</li>
  145. <li>Scroll to the bottom of the page and click the Save &amp; Apply button</li>
  146. <li>Select VPN &gt; OpenVPN from the navigation menu</li>
  147. <li>Check the Enabled checkbox next to the OpenVPNServer entry and click the Save &amp; Apply button</li>
  148. <li>After a few seconds the page will refresh and the OpenVPN server should be running<br />
  149. <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>
  150. </ol>
  151. <h2>Installing OpenVPN Client Software and Testing</h2>
  152. <ol>
  153. <li>Download the OpenVPN software <a href="https://openvpn.net/community-downloads/" target="_blank">Download</a></li>
  154. <li>Run the installer with all the default values</li>
  155. <li>Click the Start button and search OpenVPN GUI</li>
  156. <li>Select OpenVPN GUI from the results to start the application</li>
  157. </ol>
  158. <h2>Creating the OpenVPN Client Profile</h2>
  159. <ol>
  160. <li>Download the OVPN template <a href="https://drive.google.com/open?id=1cwgQfCoQmDOMbY1kW7JK4q07ijHdl37y" target="_blank">Download</a></li>
  161. <li>Rename the .ovpn template something meaningful</li>
  162. <li>Edit the .ovpn template replacing the following:
  163. <p>&lt;#replace with dynamic dns#&gt; with a dynamic DNS or external IP address to your server<br />
  164. &lt;#replace with CA chain#&gt; with the contents of CA_Chain.pem<br />
  165. &lt;#replace with client 1 cert #&gt; with the contents of OpenVPN_Client #1.crt<br />
  166. &lt;#replace with client 1 key #&gt; with the contents of OpenVPN_Client #1.pk8</p>
  167. </li>
  168. <li>Save your changes</li>
  169. <li>Copy the .ovpn template to OpenVPN install directory/config</li>
  170. <li>Right click OpenVPN GUI in the system tray &gt; Connect</li>
  171. </ol> </div>
  172. </div>
  173. </body>
  174. </html>