{"id":107,"date":"2018-09-26T17:19:17","date_gmt":"2018-09-26T17:19:17","guid":{"rendered":"https:\/\/trulyone.net\/blog\/?p=107"},"modified":"2018-09-26T17:19:17","modified_gmt":"2018-09-26T17:19:17","slug":"testing-server-configuration-with-virtualbox","status":"publish","type":"post","link":"https:\/\/www.trulyone.net\/blog\/computers\/testing-server-configuration-with-virtualbox\/","title":{"rendered":"Testing server configuration with VirtualBox"},"content":{"rendered":"\n<p>Before setting up a new server on a live machine it can sometimes\n be useful to set up a virtual machine in order to test the \nconfiguration. This will allow you to play around with settings and even\n make mistakes without causing harm to a real system. I like to do this \nso I can change things over and over until it\u2019s just right, then I can \ncopy the final configuration over to the live system. In this example I \nwill set up a Debian 9 virtual server in Oracle VirtualBox and configure\n so it can be accessed by the host machine and over a LAN. This means \nthe configuration can be tested from different devices.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Install VirtualBox<\/h3>\n\n\n\n<p>I won\u2019t cover this in detail. I found installation quite \nstraightforward. VirtualBox is available for Windows, OS X, Solaris and \nvarious Linux distributions. The instructions for installing various \noperating systems can be found&nbsp;<a href=\"https:\/\/www.virtualbox.org\/wiki\/Downloads\">here<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Download server installation image<\/h3>\n\n\n\n<p>The installation page for Debian is located&nbsp;<a href=\"https:\/\/www.debian.org\/distrib\/\">here.<\/a>&nbsp;There\n are various methods but most people with a decent internet connection \nwill want to download a small installation image and then download the \nrest of the packages from the internet.&nbsp; I chose&nbsp;<a href=\"https:\/\/www.debian.org\/distrib\/netinst\">small installation image<\/a>&nbsp;then selected the amd64 small image.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Setting up the virtual server<\/h3>\n\n\n\n<p>Start VirtualBox and select&nbsp;<em>new.&nbsp;<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/trulyone.net\/blog\/wp-content\/uploads\/2018\/09\/20180926-NewVM01.png\" alt=\"Creating a new Debian 9 Virtual Machine\" class=\"wp-image-196\"\/><figcaption>Creating a new Debian 9 Virtual Machine<\/figcaption><\/figure>\n\n\n\n<p>Give you machine a name, and select the Debian Version from the drop \ndown. Then create a new virtual hard disk, using the default settings \nshould be fine here.<\/p>\n\n\n\n<p>After this, select the settings for your new VM. Under&nbsp;<em>Storage<\/em> you will see a CD drive which is empty.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/trulyone.net\/blog\/wp-content\/uploads\/2018\/09\/20180926-NewVM02a.png\" alt=\"Storage Settings for your VM\" class=\"wp-image-204\"\/><figcaption>Storage Settings for your VM<\/figcaption><\/figure>\n\n\n\n<p>Under Attributes, change the Optical Drive to the Debian image your downloaded earlier.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Installing the virtual machine operating system<\/h3>\n\n\n\n<p>Click ok and you are ready to start your VM. Run through the \ninstallation process. In most cases the Debian defaults will be fine.<\/p>\n\n\n\n<p>At the software selection page I deselected the&nbsp;<em>Debian desktop environment&nbsp;<\/em>option and selected&nbsp;<em>web server<\/em> because I am setting it up as a headless web server.<\/p>\n\n\n\n<p>Following installation the machine should boot into the installed \nversion.&nbsp;Press the alt key to \u2018break out\u2019 of the VM and return to the \nhost operating system.<\/p>\n\n\n\n<p>I installed ssh via:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># apt-get install ssh<\/pre>\n\n\n\n<p>You can also find the machine\u2019s ip address by typing:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ ip a\n1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1\n    link\/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00\n    inet 127.0.0.1\/8 scope host lo\n       valid_lft forever preferred_lft forever\n    inet6 ::1\/128 scope host \n       valid_lft forever preferred_lft forever\n2: enp0s3: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP group default qlen 1000\n    link\/ether 08:00:27:89:08:ae brd ff:ff:ff:ff:ff:ff\n    inet 192.168.10.2\/24 brd 192.168.4.255 scope global enp0s3\n       valid_lft forever preferred_lft forever\n    inet6 fe80::a00:27ff:fe89:8ae\/64 scope link \n       valid_lft forever preferred_lft forever\n\n<\/pre>\n\n\n\n<p>The ip address is 192.168.10.2. You can try to ssh into the machine \nfrom the host OS. Also type the ip address into a web browser and \nconfirm that you can see the default apache web page.<\/p>\n\n\n\n<p>Poweroff the machine and then restart in headless mode. Open a terminal on the host machine and type:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ VBoxHeadless -s testy\nOracle VM VirtualBox Headless Interface 5.2.18_Debian\n(C) 2008-2018 Oracle Corporation\nAll rights reserved.<\/pre>\n\n\n\n<p>You can now ssh into the machine as before and configure your virtual\n server in a safe test environment before rolling it out for real. Try \naccessing the web server from a phone or tablet connected to the same \nnetwork.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Some improvements<\/h3>\n\n\n\n<p>You could add the ip address to your \n\/etc\/hosts file in order to make access it easier.&nbsp; In the future I am \ngoing to set up dnsmasq on my network so other devices can also type a \nhostname instead of an ip address.<\/p>\n\n\n\n<p>If you think the ip address is going to change frequently then you can find the virtual machine\u2019s mac address under the&nbsp;<em>Network<\/em>\n section of settings. Click advanced to show it. You can then configure \nyour DHCP server to allocate a fixed ip address to the VM.<\/p>\n\n\n\n<p>This is fairly basic run through of the setup. In another article I \nwill cover some alternate configurations and other ways of running a VM \ntest server.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Before setting up a new server on a live machine it can sometimes be useful to set up a virtual machine in order to test the configuration. This will allow you to play around with settings and even make mistakes without causing harm to a real system. I like to do this so I can &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trulyone.net\/blog\/computers\/testing-server-configuration-with-virtualbox\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Testing server configuration with VirtualBox&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,16],"tags":[33,51,71,73,74],"class_list":["post-107","post","type-post","status-publish","format-standard","hentry","category-computers","category-sysadmin","tag-debian","tag-linux","tag-sysadmin","tag-tutorial","tag-virtualbox"],"_links":{"self":[{"href":"https:\/\/www.trulyone.net\/blog\/wp-json\/wp\/v2\/posts\/107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.trulyone.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trulyone.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trulyone.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trulyone.net\/blog\/wp-json\/wp\/v2\/comments?post=107"}],"version-history":[{"count":0,"href":"https:\/\/www.trulyone.net\/blog\/wp-json\/wp\/v2\/posts\/107\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trulyone.net\/blog\/wp-json\/wp\/v2\/media?parent=107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trulyone.net\/blog\/wp-json\/wp\/v2\/categories?post=107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trulyone.net\/blog\/wp-json\/wp\/v2\/tags?post=107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}