Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

Commit 7704c04

Browse files
committed
Simplified how VM networks are created
1 parent 014b54f commit 7704c04

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ DevBox can be configured using the `config.yaml` configuration file.
99

1010

1111
#### VM
12-
The IP address for the VM can be changed by updating the `ip` property. Also the default name for the VM is 'devbox', this can be changed by adding the `name` property. The default hostname for the VM is also 'devbox', this can be changed by adding the `hostname` property.
12+
By default, DevBox will create a private network with an automatically assigned IP address. Use `ifconfig` on the VM to determine the IP address. A static IP address for the VM can be given by adding the `ip` property and assigning an address from the [reserved private address space](https://en.wikipedia.org/wiki/Private_network#Private_IPv4_address_spaces). Also the default name for the VM is 'devbox', this can be changed by adding the `name` property. The default hostname for the VM is also 'devbox', this can be changed by adding the `hostname` property.
1313
```yaml
1414
ip: "192.168.22.18"
1515
name: vmname

Vagrantfile

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,19 @@ Vagrant.configure("2") do |config|
7070
config.vm.box = settings["box"] ||= "damianlewis/ubuntu-#{settings["ubuntu"] ||= default_ubuntu}-#{webserver == "apache" ? "lamp" : "lemp"}"
7171
config.vm.box_version = settings["version"] ||= ">= 1.0"
7272

73-
# Configure a private network
74-
if settings["ip"] != "autonetwork"
75-
config.vm.network :private_network, ip: settings["ip"] ||= "192.168.10.10"
76-
else
77-
config.vm.network :private_network, :ip => "0.0.0.0", :auto_network => true
78-
end
79-
80-
# Configure additional networks
73+
# Configure networks
8174
if settings.has_key?("networks")
8275
settings["networks"].each do |network|
83-
if network["ip"] != "autonetwork"
84-
config.vm.network network["type"], ip: network["ip"], bridge: network["bridge"] ||= nil, netmask: network["netmask"] ||= "255.255.255.0"
76+
if network.has_key?("ip")
77+
config.vm.network network["type"], ip: network["ip"], bridge: network["bridge"] ||= nil
8578
else
86-
config.vm.network network["type"], :ip => "0.0.0.0", :auto_network => true, bridge: network["bridge"] ||= nil, netmask: network["netmask"] ||= "255.255.255.0"
79+
config.vm.network network["type"], bridge: network["bridge"] ||= nil
8780
end
8881
end
82+
elsif settings.has_key?("ip")
83+
config.vm.network :private_network, ip: settings["ip"]
84+
else
85+
config.vm.network :private_network, type: "dhcp"
8986
end
9087

9188
# Configure VirtualBox settings

0 commit comments

Comments
 (0)