0405.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Run an OpenWRT VM on Proxmox VE</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,Hypervisor,Install Guide,Self-Hosted,Web Based,Web Based Tools,Proxmox Host,OpenWRT Tutorial,OpenWRT,Networking,Linux,Virtualization,Virtual Router,Virtual Machine,VM,Router,Proxmox,Proxmox VE,How To Run OpenWRT Virtual Machine,How To Virtualize OpenWRT,OpenWRT VM,OpenWRT Virtual Machine,OpenWRT Proxmox VM,Proxmox Step By Step,Virtualize OpenWRT,X64,VM Router,Homelab,How To,Tutorial,i12bretro">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Run an OpenWRT VM on Proxmox VE">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <meta name="revised" content="03/27/2022 12:39:42 PM" />
  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>Run an OpenWRT VM on Proxmox VE</h1>
  22. </div>
  23. <div></div>
  24. <div id="content">
  25. <h2>What is OpenWRT?</h2>
  26. <blockquote>OpenWrt is an open-source project for embedded operating systems based on Linux, primarily used on embedded devices to route network traffic. The main components are Linux, util-linux, musl, and BusyBox. All components have been optimized to be small enough to fit into the limited storage and memory available in home routers.<em> -<a href="https://en.wikipedia.org/wiki/OpenWrt" target="_blank">https://en.wikipedia.org/wiki/OpenWrt</a></em></blockquote>
  27. <h2>Creating the VM</h2>
  28. <ol>
  29. <li>Open a web browser and navigate to the ProxMox web UI https://ProxMoxDNSorIP:8006/</li>
  30. <li>Click the Create VM button at the top right</li>
  31. <li>On the General tab, name the VM OpenWRT and set a VM ID (123 in this example) &gt; click Next</li>
  32. <li>On the OS tab select Do not use any media and set the Guest OS Type to Linux and Version to 5.x - 2.6 Kernel &gt; click Next</li>
  33. <li>On the System tab click Next</li>
  34. <li>On the Hard Disk tab set the Disk size to 0.001 &gt; click Next</li>
  35. <li>On the CPU tab set the number of CPU cores and the Type to host &gt; click Next</li>
  36. <li>On the Memory tab set the amount of memory to 256 MiB &gt; click Next</li>
  37. <li>On the Network tab set the Model field to VirtIO (paravirtualized), Uncheck the Firewall box &gt; click Next</li>
  38. <li>On the Confirm tab review the settings and click Finish</li>
  39. <li>Select the newly created OpenWRT VM from the left navigation panel</li>
  40. <li>Select Hardware from the left sub-navigation menu</li>
  41. <li>Click the Hard Disk to select it</li>
  42. <li>Click the Detach button at the top of the main content window to detach the hard disk from the VM</li>
  43. <li>Click the Unused disk to select it</li>
  44. <li>Click the Remove button at the top of the main content window to permanently delete it</li>
  45. <li>Click the Add button &gt; Network Device</li>
  46. <li>Set the Model field to VirtIO (paravirtualized), Uncheck the Firewall box &gt; Click Add</li>
  47. </ol>
  48. <h2>Setting Up the OpenWRT Disk</h2>
  49. <ol>
  50. <li>Select the Proxmox node name in the left navigation menu</li>
  51. <li>Click Shell in the left sub-navigation</li>
  52. <li>Run the following commands in the terminal
  53. <div class="codeBlock CMD"># lookup the latest stable version number<br />
  54. regex=&#39;&lt;strong&gt;Current Stable Release - OpenWrt ([^/]*)&lt;\/strong&gt;&#39; &amp;&amp; response=$(curl -s https://openwrt.org) &amp;&amp; [[ $response =~ $regex ]] &amp;&amp; stableVersion=&quot;${BASH_REMATCH[1]}&quot;<br />
  55. # download openwrt image<br />
  56. wget -O openwrt.img.gz https://downloads.openwrt.org/releases/$stableVersion/targets/x86/64/openwrt-$stableVersion-x86-64-generic-ext4-combined.img.gz<br />
  57. # extract the openwrt img<br />
  58. gunzip ./openwrt.img.gz<br />
  59. # rename the extracted img<br />
  60. mv ./openwrt*.img ./openwrt.raw<br />
  61. # increase the raw disk to 512 MB<br />
  62. qemu-img resize -f raw ./openwrt.raw 512M<br />
  63. # import the disk to the openwrt vm<br />
  64. # update the vm id and storage device as needed<br />
  65. # usage: qm importdisk <vmid> <source /> <storage><br />
  66. qm importdisk 123 openwrt.raw HDD_500GB</storage></vmid></div>
  67. <strong> </strong></li>
  68. <li><strong>Once the disk import completes, select the OpenWRT VM from the left navigation menu &gt; Hardware</strong></li>
  69. <li><strong>Double click the Unused Disk &gt; Click the Add button</strong></li>
  70. <li><strong>Select Options from the left sub-navigation menu</strong></li>
  71. <li><strong>Double click Boot Order</strong></li>
  72. <li><strong>Check the Enabled box next to the hard disk</strong></li>
  73. <li><strong>Drag the Hard disk up in the boot order as needed, typically below the CD-ROM device</strong></li>
  74. <li><strong>Click OK</strong></li>
  75. <li><strong>Double click Use tablet pointer &gt; Uncheck the Enabled box &gt; Click OK</strong></li>
  76. <li><strong>Click the Start button in the top right of the screen</strong></li>
  77. <li><strong>Click the Console link to watch the boot process</strong></li>
  78. <li><strong>Wait for the text to stop scrolling and press Enter</strong></li>
  79. <li><strong>Run the following command to change/set the root password </strong>
  80. <div class="codeBlock CMD"><strong>passwd</strong></div>
  81. <strong> </strong></li>
  82. <li><strong>Type a new root password twice to set it</strong></li>
  83. <li><strong>Continue the configuration by running the following commands </strong>
  84. <div class="codeBlock CMD"><strong># set the lan ip address, use something in the same subnet as your LAN<br />
  85. uci set network.lan.ipaddr=&#39;10.10.27.151&#39;<br />
  86. # restart network services<br />
  87. service network restart<br />
  88. # update openwrt packages<br />
  89. opkg update<br />
  90. # install the luci web ui<br />
  91. opkg install luci</strong></div>
  92. <strong> </strong></li>
  93. <li><strong>Open a new browser tab and navigate to http://IPofVM, http://10.10.27.151 in the example</strong></li>
  94. <li><strong>At the login screen, enter the username root and the password set above &gt; Click the Login button</strong></li>
  95. <li><strong>Enjoy OpenWRT running in Proxmox</strong></li>
  96. </ol>
  97. </div>
  98. </div>
  99. </body>
  100. </html>