0017.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Setting Up DD-WRT OpenVPN Server and Certificate Creation</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  7. <script type="text/javascript">
  8. $(function(){
  9. $('textarea').each(function(i,e){
  10. theTextarea = $(this);
  11. theTextarea.height((theTextarea[0].scrollHeight-5) +'px');
  12. });
  13. $('li').each(function(i,e){
  14. var uuid = 'li_' + Math.floor(Math.random() * Math.floor(1000000)).toString() + '_' + i.toString();
  15. $(this).contents().wrap('<span id="'+ uuid +'"><label for="cb_'+ uuid +'"></label></span>');
  16. $(this).prepend('<input type="checkbox" class="completeBox" id="cb_' + uuid +'" rel="'+ uuid +'" />')
  17. });
  18. $('code,div.codeBlock,textarea.codeBlock').each(function(i,e){
  19. theElement = $(this);
  20. var lines = theElement.html().split("\n");
  21. theElement.empty();
  22. for(l=0;l<lines.length;l++){
  23. if($.trim(lines[l]) != '' && $.trim(lines[l]).substr(0,1) != '#' && $.trim(lines[l]).indexOf(' #') == -1 && lines[l].substr(0, 4).toUpperCase() != 'REM '){
  24. theElement.append('<input type="image" src="images/clipboard.png" value="" class="copy-text" rel="copy_'+ i +'_'+ l +'" data-clipboard-text="'+ lines[l].replace(/"/g, '&quot;') +'" /><span id="copy_'+ i +'_'+ l +'">'+ lines[l] +'</span>');
  25. } else {
  26. theElement.append(lines[l]);
  27. }
  28. }
  29. });
  30. $(document).on('click','input.copy-text',function(){
  31. theButton = $(this);
  32. $('input.copy-text').attr('src','images/clipboard.png');
  33. $('span.copy-animation').removeClass('copy-animation');
  34. try {
  35. $('#'+ theButton.attr('rel')).addClass('copy-animation');
  36. navigator.clipboard.writeText(theButton.data('clipboard-text').replace(/<[^>]*>?/gm, ''));
  37. theButton.attr('src','images/clipboard_active.png');
  38. } catch(err) {
  39. }
  40. return false;
  41. });
  42. $(document).on('click','input.completeBox',function(){
  43. theBox = $(this);
  44. $('#'+ theBox.attr('rel')).addClass('strikethrough');
  45. theBox.prop('disabled',true);
  46. theBox.parent('li').prevAll().each(function(i,e){
  47. theLI = $(this);
  48. if(theLI.find('input[type=checkbox]').not(':checked')){
  49. $('#'+ theLI.find('input[type=checkbox]').attr('rel')).addClass('strikethrough');
  50. theLI.find('input[type=checkbox]').prop('checked',true).prop('disabled',true);
  51. }
  52. });
  53. });
  54. if(window.self !== window.top){
  55. window.parent.$('iframe.stepsFrame').height((this['scrollingElement']['scrollHeight']+20) +'px');
  56. }
  57. });
  58. </script>
  59. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  60. </head>
  61. <body>
  62. <div id="gridContainer">
  63. <div class="topMargin"></div>
  64. <div id="listName" class="topMargin">
  65. <h1>Setting Up DD-WRT OpenVPN Server and Certificate Creation</h1>
  66. </div>
  67. <div></div>
  68. <div id="content">
  69. <h2>
  70. Create Required Certificates</h2>
  71. <ol>
  72. <li>
  73. Launch XCA</li>
  74. <li>
  75. Open the PKI database if it is not already (File &gt; Open DataBase), enter password</li>
  76. <li>
  77. Click on the Certificates tab, right click on your Intermediate CA certificate</li>
  78. <li>
  79. Select New</li>
  80. <li>
  81. On the Source tab, make sure Use this Certificate for signing is selected</li>
  82. <li>
  83. Verify your Intermediate CA certificate is selected from the drop down</li>
  84. <li>
  85. Click the Subject tab</li>
  86. <li>
  87. Complete the Distinguished Name section
  88. <p>
  89. internalName: OpenVPN Server<br />
  90. countryName: US<br />
  91. stateOrProvinceName: Virginia<br />
  92. localityName: Northern<br />
  93. organizationName: i12bretro<br />
  94. organizationUnitName: i12bretro Certificate Authority<br />
  95. commonName: vpn.i12bretro.local</p>
  96. </li>
  97. <li>
  98. Click the Generate a New Key button</li>
  99. <li>
  100. Enter a name and set the key size to at least 2048</li>
  101. <li>
  102. Click Create</li>
  103. <li>
  104. Click on the Extensions tab</li>
  105. <li>
  106. Set the Type dropdown to End Endity</li>
  107. <li>
  108. Check the box next to Subject Key Identifier</li>
  109. <li>
  110. Update the validity dates to fit your needs</li>
  111. <li>
  112. Click the Key Usage tab</li>
  113. <li>
  114. Under Key Usage select Digital Signature and Key Encipherment</li>
  115. <li>
  116. Under Extended Key Usage select TLS Web Server Authentication</li>
  117. <li>
  118. Click the Netscape tab</li>
  119. <li>
  120. Deselect all options and clear the Netscape Comment field</li>
  121. <li>
  122. Click OK to create the certificate</li>
  123. <li>
  124. Click on the Certificates tab, right click on your Intermediate CA certificate again</li>
  125. <li>
  126. Select New</li>
  127. <li>
  128. On the Source tab, make sure Use this Certificate for signing is selected</li>
  129. <li>
  130. Verify your Intermediate CA certificate is selected from the drop down</li>
  131. <li>
  132. Click the Subject tab</li>
  133. <li>
  134. Complete the Distinguished Name section
  135. <p>
  136. internalName: OpenVPN Client #1<br />
  137. countryName: US<br />
  138. stateOrProvinceName: Virginia<br />
  139. localityName: Northern<br />
  140. organizationName: i12bretro<br />
  141. organizationUnitName: i12bretro Certificate Authority<br />
  142. commonName: VPN Client 1</p>
  143. </li>
  144. <li>
  145. Click the Generate a New Key button</li>
  146. <li>
  147. Enter a name and set the key size to at least 2048</li>
  148. <li>
  149. Click Create</li>
  150. <li>
  151. Click on the Extensions tab</li>
  152. <li>
  153. Set the Type dropdown to End Endity</li>
  154. <li>
  155. Check the box next to Subject Key Identifier</li>
  156. <li>
  157. Update the validity dates to fit your needs</li>
  158. <li>
  159. Click the Key Usage tab</li>
  160. <li>
  161. Under Key Usage select Digital Signature, Key Agreement</li>
  162. <li>
  163. Under Extended Key Usage select TLS Web Client Authentication</li>
  164. <li>
  165. Click the Netscape tab</li>
  166. <li>
  167. Deselect all options and clear the Netscape Comment field</li>
  168. <li>
  169. Click OK to create the certificate</li>
  170. <li>
  171. On the Certificates tab, click the OpenVPN Server certificate</li>
  172. <li>
  173. Select Extra &gt; Generate DH Parameter</li>
  174. <li>
  175. Type 2048 for DH parameter bits</li>
  176. <li>
  177. Click OK</li>
  178. <li>
  179. Select a location for dh2048.pem and click Save</li>
  180. </ol>
  181. <h2>
  182. Exporting Required Files for OpenVPN</h2>
  183. <ol>
  184. <li>
  185. In XCA, click on the Certificates tab</li>
  186. <li>
  187. Right click the Intermediate CA certificate &gt; Export &gt; File</li>
  188. <li>
  189. Set the file name with a .pem extension and verify the export format is PEM chain (*.pem)</li>
  190. <li>
  191. Click OK</li>
  192. <li>
  193. Right click the OpenVPN Server certificate &gt; Export &gt; File</li>
  194. <li>
  195. Set the file name with a .crt extension and verify the export format is PEM (*.crt)</li>
  196. <li>
  197. Click OK</li>
  198. <li>
  199. Right click the OpenVPN Client #1 certificate &gt; Export &gt; File</li>
  200. <li>
  201. Set the file name with a .crt extension and verify the export format is PEM (*.crt)</li>
  202. <li>
  203. Click OK</li>
  204. <li>
  205. Click on the Private Keys tab</li>
  206. <li>
  207. Right click the OpenVPN Server key &gt; Export &gt; File</li>
  208. <li>
  209. Set the file name with a .pk8 extension and verify the export format is PKCS #8 (*.pk8)</li>
  210. <li>
  211. Click OK</li>
  212. <li>
  213. Right click the OpenVPN Client #1 key&gt; Export &gt; File</li>
  214. <li>
  215. Set the file name with a .pk8 extension and verify the export format is PKCS #8 (*.pk8)</li>
  216. <li>
  217. Click OK</li>
  218. </ol>
  219. <h2>
  220. Setting Up OpenVPN Server in DD-WRT</h2>
  221. <ol>
  222. <li>
  223. Open a web browser and navigate to your DD-WRT IP address</li>
  224. <li>
  225. Login when prompted</li>
  226. <li>
  227. Select the Administration tab</li>
  228. <li>
  229. Select the Backup sub tab</li>
  230. <li>
  231. Click Backup at the very bottom</li>
  232. <li>
  233. Save the nvrambak file somewhere safe</li>
  234. <li>
  235. Select the Services tab</li>
  236. <li>
  237. Select the VPN sub tab</li>
  238. <li>
  239. Scroll down and select enable next to OpenVPN under the OpenVPN Server/Daemon header</li>
  240. <li>
  241. Set the OpenVPN Settings as the following:
  242. <ol start="1" style="list-style-type: lower-alpha;">
  243. <li>
  244. Start Type: System</li>
  245. <li>
  246. Config as: Server</li>
  247. <li>
  248. Server mode: Router (TUN)</li>
  249. <li>
  250. Network: 10.10.28.0</li>
  251. <li>
  252. Netmask: 255.255.255.0</li>
  253. <li>
  254. Port: 1194</li>
  255. <li>
  256. Tunnel Protocol: TCP</li>
  257. <li>
  258. Encyption Cipher: AES-256 GCM</li>
  259. <li>
  260. Hash Algorithm: SHA256</li>
  261. <li>
  262. Advanced Options: Enable</li>
  263. <li>
  264. TLS Cipher: TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384</li>
  265. <li>
  266. Compression: Compress lz4-v2</li>
  267. <li>
  268. Redirect default Gateway: Disable</li>
  269. <li>
  270. Allow Client to Client: Enable</li>
  271. <li>
  272. Allow duplicate CN: Disable</li>
  273. <li>
  274. Tunnel MT setting: 1500</li>
  275. <li>
  276. Tunnel UDP MSS-Fix: Disable</li>
  277. </ol>
  278. </li>
  279. <li>
  280. Paste the contents of OpenVPN_Server.crt into the Public Server Cert field</li>
  281. <li>
  282. Paste the contents of CA_Chain.pem into the CA Cert field</li>
  283. <li>
  284. Paste the contents of OpenVPN_Server.pem into the Private Server Key field</li>
  285. <li>
  286. Paste the contents of dh2048.pem into the DH PEM field</li>
  287. <li>
  288. Paste the following into the Additional Config field:<br />
  289. push &quot;route-gateway 10.10.27.27&quot;<br />
  290. push &quot;route 10.10.27.0 255.255.255.0&quot;<br />
  291. push &quot;dhcp-option DNS 10.10.27.1&quot;<br />
  292. push &quot;dhcp-option DNS 208.67.222.222&quot;</li>
  293. <li>
  294. Note in the above:<br />
  295. route-gateway is the IP address of the internet gateway on your local network<br />
  296. route is the subnet of your local network<br />
  297. dhcp-option DNS sets DNS servers, in my case my domain controller and an OpenDNS server</li>
  298. <li>
  299. Click Save at the bottom</li>
  300. <li>
  301. Click Apply Settings</li>
  302. <li>
  303. Click the Administration tab</li>
  304. <li>
  305. Click the Command sub tab</li>
  306. <li>
  307. Paste the following into the Commands field<br />
  308. <p>
  309. iptables -t nat -I PREROUTING -p udp --dport 1194 -j ACCEPT<br />
  310. iptables -I INPUT -p udp --dport 1194 -j ACCEPT<br />
  311. iptables -t nat -I PREROUTING -p tcp --dport 1194 -j ACCEPT<br />
  312. iptables -I INPUT -p tcp --dport 1194 -j ACCEPT<br />
  313. iptables -I INPUT -i tun2 -j ACCEPT<br />
  314. iptables -I FORWARD -i tun2 -j ACCEPT<br />
  315. iptables -I FORWARD -o tun2 -j ACCEPT<br />
  316. iptables -t nat -A POSTROUTING -s 10.10.28.0/24 -o eth0 -j MASQUERADE</p>
  317. </li>
  318. <li>
  319. Click Save Firewall at the bottom</li>
  320. <li>
  321. Click the Management sub tab</li>
  322. <li>
  323. Click Reboot Router at the very bottom</li>
  324. </ol>
  325. <h2>
  326. Installing OpenVPN Client Software and Testing</h2>
  327. <ol>
  328. <li>
  329. Download the OpenVPN software <a href="https://openvpn.net/community-downloads/" target="_blank">Download</a></li>
  330. <li>
  331. Run the installer with all the default values</li>
  332. <li>
  333. Click the Start button and search OpenVPN GUI</li>
  334. <li>
  335. Select OpenVPN GUI from the results to start the application</li>
  336. </ol>
  337. <h2>
  338. Creating the OpenVPN Client Profile</h2>
  339. <ol>
  340. <li>
  341. Download the OVPN template <a href="https://drive.google.com/open?id=1cwgQfCoQmDOMbY1kW7JK4q07ijHdl37y" target="_blank">Download</a></li>
  342. <li>
  343. Rename the .ovpn template something meaningful</li>
  344. <li>
  345. Edit the .ovpn template replacing the following:<br />
  346. <p>
  347. &lt;#replace with dynamic dns#&gt; with a dynamic DNS or external IP address to your server<br />
  348. &lt;#replace with CA chain#&gt; with the contents of CA_Chain.pem<br />
  349. &lt;#replace with client 1 cert #&gt; with the contents of OpenVPN_Client #1.crt<br />
  350. &lt;#replace with client 1 key #&gt; with the contents of OpenVPN_Client #1.pk8</p>
  351. </li>
  352. <li>
  353. Save your changes</li>
  354. <li>
  355. Copy the .ovpn template to OpenVPN install directory/config</li>
  356. <li>
  357. Right click OpenVPN GUI in the system tray &gt; Connect</li>
  358. </ol>
  359. </div>
  360. </div>
  361. </body>
  362. </html>