Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

GH-281 DHCP server for host-only networking; initial implementation

  • Loading branch information...
commit 5dd8db87ecf90e341dfd6b3dedb5e0d347e09866 1 parent 8b8225f
Charles Duffy authored
View
17 lib/vagrant/action/vm/network.rb
@@ -93,9 +93,22 @@ def network_name(net_options)
# One doesn't exist, create it.
@env.ui.info I18n.t("vagrant.actions.vm.network.creating")
+ host_ip = network_ip(net_options[:ip], net_options[:netmask])
+
ni = interfaces.create
- ni.enable_static(network_ip(net_options[:ip], net_options[:netmask]),
- net_options[:netmask])
+ ni.enable_static(host_ip, net_options[:netmask])
+
+ if net_options[:dhcp_range] != nil then
+ @env.ui.info I18n.t("vagrant.actions.vm.network.dhcp.creating")
+ dhcp_server = ni.dhcp_server
+ dhcp_server.network_mask = net_options[:netmask]
+ dhcp_server.lower_ip = net_options[:dhcp_range][0]
+ dhcp_server.upper_ip = net_options[:dhcp_range][1]
+ dhcp_server.ip_address = host_ip
+ dhcp_server.enabled = true
+ dhcp_server.save
+ end
+
ni.name
end
View
3  lib/vagrant/config/vm.rb
@@ -56,7 +56,8 @@ def network(ip, options=nil)
:netmask => "255.255.255.0",
:adapter => 1,
:mac => nil,
- :name => nil
+ :name => nil,
+ :dhcp_range => nil
}.merge(options || {})
@network_options[options[:adapter]] = options
View
2  templates/locales/en.yml
@@ -350,6 +350,8 @@ en:
the IP or name of your host only network to not match that of
a bridged or non-hostonly network.
creating: "Creating new host only network for environment..."
+ dhcp:
+ creating: "Enabling DHCP server..."
enabling: "Enabling host only network..."
not_found: |-
The specified host network could not be found: '%{name}.'

0 comments on commit 5dd8db8

Please sign in to comment.
Something went wrong with that request. Please try again.