# Private Network – Static IP vs DHCP

**URL:** https://discourse.roots.io/t/private-network-static-ip-vs-dhcp/5045
**Category:** trellis
**Created:** 2015-10-16T00:06:11Z
**Posts:** 4

## Post 1 by @tyler_morrison — 2015-10-16T00:06:12Z

Hey all,

First off, I’ve got to take a moment and thank all the Roots developers for your hard work. In the past few months since I started using Trellis + Bedrock + Sage, my life has become SO much easier. Not only do your products work wonderfully, having a site like Discourse gives me the confidence to use them with clients and not worry about unforeseen bugs / shoddy coding. On to the question…

**QUESTION:** Is there a specific reason that the current Vagrant setup opts for a static private network IP – `config.vm.network :private_network, ip: '192.168.50.5'` – over DHCP?

I never noticed this until I tried to launch more than one Vagrant instance at the same time. Obviously, when I attempted this, Vagrant told me to “go kick rocks” because it would cause a conflict. After I did some digging in the Vagrant documentation, I noticed that they recommended DHCP so that the private network could be automatically generated.

Long story short, I could not ever get the vagrant-hostsupdater plugin to play nice with the new config type – `config.vm.network :private_network, type: 'dhcp'`; however, I did have success after I swapped out the vagrant-hostsupdater plugin with vagrant-hostmanager plugin…

```
if Vagrant.has_plugin?("vagrant-hostmanager")
    config.hostmanager.ip_resolver = proc do |vm, resolving_vm|
      if hostname = (vm.ssh_info && vm.ssh_info[:host])
        `vagrant ssh -c "hostname -I"`.split()[1]
      end
    end

    config.hostmanager.enabled = true
    config.hostmanager.manage_host = true
    config.hostmanager.ignore_private_ip = false
    config.hostmanager.include_offline = true
    config.hostmanager.aliases = [aliases, www_aliases]
  else
    fail_with_message "vagrant-hostmanager missing, please install the plugin with this command:\nvagrant plugin install vagrant-hostmanager"
  end
```

Thoughts?

---

## Post 2 by @ben — 2015-10-16T00:07:27Z

This was discussed at [https://github.com/roots/trellis/issues/295](https://github.com/roots/trellis/issues/295)

---

## Post 3 by @kalenjohnson — 2015-10-16T00:08:48Z

There’s a comment right above that line:

> <https://github.com/roots/trellis/blob/master/Vagrantfile#L37>

---

## Post 4 by @tyler_morrison — 2015-10-16T00:13:44Z

Thanks for the quick reply! I noticed that comment, I just wasn’t keen on the idea of having to manually edit that setting for each new installation.

From the GitHub issue that @ben shared, it looks like I’ll just use my own customization for the time being so that I can have automatic private network configs without having to edit either the Vagrantfile or /etc/hosts myself.
