3

I use vagrant to launch VM's and bridge the network access to my local machine. Unfortunately exvery VM launch gives me a new IP address, and MAC address. I have a domain.local that I use and currently I have to change my computer's hosts file every launch to match.

I have admin access to all the machines (local, VM, and the router for the intranet). How to I tell .local domains to resolve locally only in a way that won't require me to change (or set at all) my local hosts file?

Braiam
  • 35,991
Bradley
  • 1,519

2 Answers2

3

I understand you need to resolve for dynamically assigned addresses.

I had the same issue and used DNSMASQ, this is an integrated DNS & DHCP server that runs very well on ubuntu server. Great benefit is that it is nearly zero config.

How I set it up:

NAT - SRV01 - InternalNet - SRV02 / SRV03 / CLNT

So SRV02 / SRV03 / CLNT are only connected to InternalNet, getting DHCP and domain lookups from SRV01. SRV01 is gateway for these machines as well (by using ip forwarding and iptables masquerade on SRV01).

Works like a charm.

/dnsmasq

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
  • 1
    That went right over my head. It looks like a solution, are you able to elaborate or be a little more specific? What extra information do you need from me to do so? – Bradley Jul 25 '13 at 16:21
  • 2
    @Bradley http://unix.stackexchange.com/questions/16890/how-to-make-a-machine-accessible-from-the-lan-using-its-hostname/16901#16901 may help – Gilles 'SO- stop being evil' Jul 25 '13 at 23:19
  • @Bradley Sorry it took so long for me to answer... Of course I can elaboreate. What I did is install 3 Ubuntu servers (SRV01, SRV02 and SRV03) and a Windows host (CLNT) in VBox VM's. On SRV01, which has 2 vnics (one NAT-ted (called it WAN), the other one internal network (called it LAN)) I installed DNSMASQ. Configured it to hand out IP-addresses on LAN (which automagically enables the hostname to be resolved to the IP that was handed out). The other machines only have internal nics (the LAN part of SRV01) and are set to dynamc IP config (DHCP). HTH, if you need more info let me know. – user182984 Aug 28 '13 at 08:01
1

You can use Zeroconf. It broadcasts the host name and makes it available to the other hosts on the local network. That way you can access your hosts using hostA.local, hostB.local, etc.

On Debian bases systems you need the package libnss-mdns for the host name advertisement and avahi-daemon for the name resolution.

Marco
  • 33,548