{"id":1736,"date":"2017-02-21T22:10:36","date_gmt":"2017-02-22T03:10:36","guid":{"rendered":"http:\/\/osric.com\/chris\/accidental-developer\/?p=1736"},"modified":"2017-02-21T22:10:36","modified_gmt":"2017-02-22T03:10:36","slug":"virtualbox-static-ip-address-on-a-host-only-network","status":"publish","type":"post","link":"https:\/\/osric.com\/chris\/accidental-developer\/2017\/02\/virtualbox-static-ip-address-on-a-host-only-network\/","title":{"rendered":"VirtualBox static IP address on a host-only network"},"content":{"rendered":"<p>I have a number of CentOS 7 servers that comprise a FreeIPA domain on a VirtualBox host-only network. Whenever I start a server though, it is liable to pick up an IP address that I&#8217;ve already assigned to another server (which is currently powered off) in \/etc\/hosts.<\/p>\n<p>How do I assign it a specific static IP address?<\/p>\n<p>In CentOS 7, you can use the Network Manager Text User Interface (nmtui) to edit the network settings. Here&#8217;s the first thing I tried, which wasn&#8217;t quite right:<\/p>\n<p><code># nmtui<\/code><\/p>\n<ul>\n<li>Edit a connection<\/li>\n<li>Select a connection, e.g. enp0s3<\/li>\n<li>IPv4 Configuration<\/li>\n<li>Change from Automatic to Manual<\/li>\n<li>Select Show<\/li>\n<li>Enter 192.168.56.109\/32 for addresses<\/li>\n<li>Enter 192.168.56.255 for the gateway<\/li>\n<\/ul>\n<p>When I used those settings, it didn&#8217;t work. No route to host, etc. I looked at the network interface settings via a different method:<\/p>\n<p><code># ip addr show<\/code><\/p>\n<p>The brd (broadcast) address listed was the same as my ip address, 192.168.56.109, which was unexpected and probably why it wasn&#8217;t working!<\/p>\n<p>I ran <code>nmtui<\/code> again and changed the address from 192.168.56.109\/32 to 192.168.56.109\/24 and it worked.<\/p>\n<p>Since the \/32 is interpreted as the subnet mask, it created a subnet with an address range of 1, and the broadcast address would be the same as the ip address. Specifying a subnet mask of \/24 creates a subnet with 256 addresses, and a broadcast address of 192.168.56.255 (the same as was listed for the other machines on the virtual network that were using DHCP).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to assign a CentOS 7 server running on VirtualBox attached to a host-only network a static IP address.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[422],"tags":[415,430,432,431,421],"class_list":["post-1736","post","type-post","status-publish","format-standard","hentry","category-sysadmin","tag-centos-7","tag-networking","tag-nmtui","tag-static-ip","tag-virtualbox"],"_links":{"self":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/1736","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/comments?post=1736"}],"version-history":[{"count":7,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/1736\/revisions"}],"predecessor-version":[{"id":1748,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/1736\/revisions\/1748"}],"wp:attachment":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/media?parent=1736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/categories?post=1736"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/tags?post=1736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}