{"id":2356,"date":"2022-08-25T16:04:43","date_gmt":"2022-08-25T16:04:43","guid":{"rendered":"https:\/\/blog.samarthya.me\/wps\/?p=2356"},"modified":"2022-08-25T16:04:47","modified_gmt":"2022-08-25T16:04:47","slug":"static-ips-in-qemu-vms","status":"publish","type":"post","link":"https:\/\/blog.samarthya.me\/wps\/2022\/08\/25\/static-ips-in-qemu-vms\/","title":{"rendered":"Static IP&#8217;s in QEMU VM&#8217;s"},"content":{"rendered":"\n<p>Continuing from where I left in the <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.samarthya.me\/wps\/2022\/08\/24\/running-qemu-based-vms-on-osx-m1\/\" data-type=\"URL\" data-id=\"https:\/\/blog.samarthya.me\/wps\/2022\/08\/24\/running-qemu-based-vms-on-osx-m1\/\" target=\"_blank\">blog<\/a> before. If you are using looking to configure a static IP for your machines (may be your use case is similar to mine) this blog might be useful for you.<\/p>\n\n\n\n<p>My system is a Apple M1 silicone and Virtualbox was not for me and I had to painfully find my way in the ocean. <\/p>\n\n\n\n<div class=\"wp-block-snow-monkey-blocks-balloon smb-balloon wp-block-snow-monkey-blocks-balloon-is-layout-constrained\"><div class=\"smb-balloon__person\"><div class=\"smb-balloon__figure\"><img decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/blog.samarthya.me\/wps\/wp-content\/uploads\/2019\/02\/cropped-cropped-web_hi_res_512-150x150.png\" alt=\"\" class=\"wp-image-1157\" srcset=\"https:\/\/blog.samarthya.me\/wps\/wp-content\/uploads\/2019\/02\/cropped-cropped-web_hi_res_512-150x150.png 150w, https:\/\/blog.samarthya.me\/wps\/wp-content\/uploads\/2019\/02\/cropped-cropped-web_hi_res_512.png 248w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/div><div class=\"smb-balloon__name\">Samarthya<\/div><\/div><div class=\"smb-balloon__body is-layout-constrained wp-block-balloon-is-layout-constrained\"><p>Have a look at <a href=\"https:\/\/github.com\/lima-vm\/vde_vmnet\" data-type=\"URL\" data-id=\"https:\/\/github.com\/lima-vm\/vde_vmnet\">this<\/a> useful lib.<\/p><\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Typical Usage<\/h3>\n\n\n\n<pre class=\"wp-block-code has-black-color has-luminous-vivid-amber-background-color has-text-color has-background has-small-font-size\"><code>> <em>qemu-system-aarch64<\/em> ...<strong> -device virtio-net-pci,netdev=net0,mac=de:ad:be:ef:00:01 -netdev vde,id=net0,sock=\/var\/run\/vde.ctl<\/strong><\/code><\/pre>\n\n\n\n<div class=\"wp-block-snow-monkey-blocks-balloon smb-balloon smb-balloon--reverse wp-block-snow-monkey-blocks-balloon-is-layout-constrained\"><div class=\"smb-balloon__person\"><div class=\"smb-balloon__figure\"><img decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/blog.samarthya.me\/wps\/wp-content\/uploads\/2019\/02\/cropped-cropped-web_hi_res_512-150x150.png\" alt=\"\" class=\"wp-image-1157\" srcset=\"https:\/\/blog.samarthya.me\/wps\/wp-content\/uploads\/2019\/02\/cropped-cropped-web_hi_res_512-150x150.png 150w, https:\/\/blog.samarthya.me\/wps\/wp-content\/uploads\/2019\/02\/cropped-cropped-web_hi_res_512.png 248w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/div><div class=\"smb-balloon__name\">Samarthya<\/div><\/div><div class=\"smb-balloon__body is-layout-constrained wp-block-balloon-is-layout-constrained\"><p>Steps I am using are mentioned <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/lima-vm\/vde_vmnet#how-to-reserve-dhcp-addresses\" data-type=\"URL\" data-id=\"https:\/\/github.com\/lima-vm\/vde_vmnet#how-to-reserve-dhcp-addresses\" target=\"_blank\">here<\/a>.<\/p><\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Installation<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>I built it from source so it was just following the steps mentioned in the <code>README.md<\/code><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-small-font-size\"><code>sudo make <strong>PREFIX<\/strong>=\/opt\/vde\/ install<\/code><\/pre>\n\n\n\n<p>The PREFIX defines a path and can be any path to your liking, but the recommended one is <code>\/opt\/vde<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-small-font-size\"><code>> ls -als \/opt\/vde \ntotal 0\n0 drwxr-xr-x   7 root  wheel  224 Aug 23 14:21 .\n0 drwxr-xr-x  12 root  wheel  384 Aug 23 14:21 ..\n0 drwxr-xr-x  15 root  wheel  480 Aug 24 14:48 bin\n0 drwxr-xr-x   3 root  wheel   96 Aug 23 14:21 etc\n0 drwxr-xr-x   7 root  wheel  224 Aug 24 14:48 include\n0 drwxr-xr-x  19 root  wheel  608 Aug 24 14:48 lib\n0 drwxr-xr-x   3 root  wheel   96 Aug 23 14:21 share<\/code><\/pre>\n\n\n\n<p>Install would two files of interest<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>\/Library\/LaunchDaemons\/io.github.virtualsquare.vde-2.vde_switch.plist<\/code><\/li><li><code>\/Library\/LaunchDaemons\/io.github.lima-vm.vde_vmnet.plist<\/code><\/li><\/ul>\n\n\n\n<p>My contents for <code>vde_vmnet.plist<\/code> are as under<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-small-font-size\"><code>&lt;!-- make install: yes -->\n&lt;plist version=\"1.0\">\n\t&lt;dict>\n\t\t&lt;key>Label&lt;\/key>\n\t\t&lt;string>io.github.lima-vm.vde_vmnet.plist&lt;\/string>\n\t\t&lt;key>Program&lt;\/key>\n\t\t&lt;string>\/opt\/vde\/bin\/vde_vmnet&lt;\/string>\n\t\t&lt;key>ProgramArguments&lt;\/key>\n\t\t&lt;array>\n\t\t\t&lt;string>\/opt\/vde\/bin\/vde_vmnet&lt;\/string>\n\t\t\t&lt;string>--vmnet-gateway=192.168.105.1&lt;\/string>\n\t\t\t&lt;string>\/var\/run\/vde.ctl&lt;\/string>\n\t\t&lt;\/array>\n\t\t&lt;key>StandardErrorPath&lt;\/key>\n\t\t&lt;string>\/var\/run\/vde_vmnet.stderr&lt;\/string>\n\t\t&lt;key>StandardOutPath&lt;\/key>\n\t\t&lt;string>\/var\/run\/vde_vmnet.stdout&lt;\/string>\n\t\t&lt;key>RunAtLoad&lt;\/key>\n\t\t&lt;true \/>\n\t\t&lt;key>UserName&lt;\/key>\n\t\t&lt;string>root&lt;\/string>\n\t\t&lt;key>KeepAlive&lt;\/key>\n\t\t&lt;dict>\n\t\t\t&lt;key>PathState&lt;\/key>\n\t\t\t&lt;dict>\n\t\t\t\t&lt;key>\/var\/run\/vde.pid&lt;\/key>\n\t\t\t\t&lt;true \/>\n\t\t\t&lt;\/dict>\n\t\t&lt;\/dict>\n\t&lt;\/dict>\n&lt;\/plist>\n<\/code><\/pre>\n\n\n\n<p>By default the guest IP is assigned by the DHCP server provided for the Host, but the guest will be able to access the internet and will be accessible from the host.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Reserve an IP<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>Define a unique <code>MAC<\/code> address for the VM, e.g. <code>de:ad:be:ef:00:01<\/code><\/li><li>Select a reserved IP address, e.g. <code>192.168.105:10<\/code><\/li><li>Create a file <code>\/etc\/bootptab<\/code><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-small-font-size\"><code>%%\n# hostname     hwtype  hwaddr              ipaddr          bootfile\ncentos1        1       de:ad:be:ef:00:01   192.168.105.10\ncentos2        1       de:ad:be:ef:00:02   192.168.105.20\ncentos3        1       de:ad:be:ef:00:03   192.168.105.30<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>Reload the DHCP daemon<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background\"><code>sudo launchctl unload -w \/System\/Library\/LaunchDaemons\/bootps.plist\nsudo launchctl load -w \/System\/Library\/LaunchDaemons\/bootps.plist<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>Run the qemu machine with <code>-device virtio-net-pci,netdev=net0,mac=de:ad:be:ef:00:01<\/code><\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"463\" src=\"https:\/\/blog.samarthya.me\/wps\/wp-content\/uploads\/2022\/08\/Screen-Shot-2022-08-25-at-12.03.57-PM-1024x463.png\" alt=\"\" class=\"wp-image-2357\" srcset=\"https:\/\/blog.samarthya.me\/wps\/wp-content\/uploads\/2022\/08\/Screen-Shot-2022-08-25-at-12.03.57-PM-1024x463.png 1024w, https:\/\/blog.samarthya.me\/wps\/wp-content\/uploads\/2022\/08\/Screen-Shot-2022-08-25-at-12.03.57-PM-300x136.png 300w, https:\/\/blog.samarthya.me\/wps\/wp-content\/uploads\/2022\/08\/Screen-Shot-2022-08-25-at-12.03.57-PM-1536x694.png 1536w, https:\/\/blog.samarthya.me\/wps\/wp-content\/uploads\/2022\/08\/Screen-Shot-2022-08-25-at-12.03.57-PM.png 1554w, https:\/\/blog.samarthya.me\/wps\/wp-content\/uploads\/2022\/08\/Screen-Shot-2022-08-25-at-12.03.57-PM-300x136@2x.png 600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Continuing from where I left in the blog before. If you are using looking to configure a static IP for your machines (may be your use case is similar to mine) this blog might be useful for you. My system is a Apple M1 silicone and Virtualbox was not for me and I had to [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":2357,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-2356","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-technical","post_format-post-format-image"],"_links":{"self":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/2356","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/comments?post=2356"}],"version-history":[{"count":1,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/2356\/revisions"}],"predecessor-version":[{"id":2358,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/2356\/revisions\/2358"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/media\/2357"}],"wp:attachment":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/media?parent=2356"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/categories?post=2356"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/tags?post=2356"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}