Skip to main content

How to configure a local subdomain development with Linux

Note

In the following scenario everything is done within one machine. This setup can be recreated with more then one machine as well. Use your imagination!

Task

I want to have subdomains like static.mydomain or whatever.mydomain.

Ingredients

  • any host OS that is capable of running Virtualbox, VMware or your favorite virtualisation software
  • a linux distribution that uses/supplies a small kernel, like Ubuntu server, Fedora without X, Arch or any of your choice, preferably one that you are familiar with. Of course if you are not a linux guru you can  still use a gui, just give enough memory for your guest linux.

Setup process

  1. have your virtualisation software set up on your host
  2. install your linux distro of choice as a guest, it is best to use at least one "Bridged" (my choice) or "Host only" network adapters that every other guest machine can see too if you later need it. 
  3. set up your /etc/resolv.conf file to have your nameservers in the following order:
    (NOTE: only the first one has to be your localhost, the remaining two is your choice of providers)

    nameserver 127.0.0.1
    nameserver 8.8.8.8
    nameserver 8.8.4.4
  4. install the package that has dnsmasq in it or compile it from source.
  5. setup dnsmasq according to the example below:

dnsmasq configuration

Generally the config file is at /etc/dnsmasq.conf.
Let's say you want to have a domain that is resolved by your machine -who take part in the development- as one of the dev machines address on the local network. For example I want to have the domain ikondev to be resolved to the ip address of VM1 (Virtual Machine 1 on the above image). This way we can have several subdomains for ikondev without updating /etc/hosts file each and every time we add a new subdomain to our webserver to listen to.

In your dnsmasq.conf set the following lines: (these lines has to be uncommented too)

  • domain-needed
  • bogus-priv
  • strict-order (this will make this local DNS server to be the main nameserver)
  • address=/ikondev/192.168.1.101 (this is the entry for the ikondev domain to point to the machine with 192.168.1.101. You can set up several more entries like this of course)
  • interface=eth0 (eth0 has to be changed to your network interface which connects to the development network)
  • no-dhcp-interface=eth0 (eth0 has to be the same as the one for the previous setting as we do not want to set up a dhcp server)

Final touches

Now all we have to do is restart the network and the dnsmasq services and set all the dev machines primary nameserver to be VM2's ip address as it will be serving our local and mainstream resolves.
Voila! all subdomains typed for ikondev will be resolved as VM1. :)

Popular posts from this blog

Shrink Vmware Workstation Ubuntu guest's VMDK file size physically on Windows host

I will be short on the topic as you too only seeking the resolution to the problem in the title. This tutorial is based on using Vmware Workstation 11 on Windows 8.1 host using an Ubuntu 14.04 guest. Note : you have to have the vmware tools, client additions installed on the quest machine! First go to the Vmware client's terminal when you are ready to shrink it down and type: sudo vmware-toolbox-cmd disk list This will give you the mount points that can be shrinked individually. For me I will only go with shrinking the main disk with "/" (root). First lets wipe the free space clean so the shrinker will know what is free to get rid of: sudo vmware-toolbox-cmd disk wipe / To shrink: sudo vmware-toolbox-cmd disk shrink / That's it, after the process in my case I've had a 4.4G file shrinked down to 1.7G, which is much closer to what the client OS saw (1.5G).

Login to Ubuntu with Yubikey

DISCLAIMER: I am by no means responsible for anyone using this tutorial to lock herself out of their system, nor for any damage, data loss, etc. You get the idea, use this at your own risk. With that out of the way, let's get to the fun part. This tutorial will outline the steps I used in my current Xubuntu (Ubuntu with Xfce) 16.04 to enable my Yubikey as a hardware key as a requirement to log in. I am using the default eCryptFS encryption method to encrypt a private folder (not my home folder) which also keeps unlocking when my user logs in. This process worked on my Arch desktop too, which I took from this genius post: https://blog.jamesthebard.net/archlinux-and-u2f-login/ Big thanks and credit to him! This tutorial will be mostly copy-paste, though I wish to do it with the Ubuntu specifics. The login manager I am using is LightDM , I also removed the screensaver that comes with Xubuntu out of the box. On Arch I was able to use GDM with success.

Byobu automated window setup

I am recently working all day in a multiple virtual machine environment and became very tired of typing repetitive commands. The most irritating was to always recreate the default Byobu (with tmux ) window setups, running the initial servers in them, etc. So I have asked the question on ServerFault . As a result I have created my 6+ window Byobu automator script and live happily ever since |^_^| Here is a small GIST example for a simple, non-splitting window setup: