hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.27k stars 4.43k forks source link

specify default_gateway in Vagrantfile #436

Closed t9md closed 13 years ago

t9md commented 13 years ago

I want to specify default gataway in Vagrantfile like following.

config.vm.network = "192.168.86.205"
config.vm.gatway = "192.168.86.1"

The purpose of this feature is make chef provisioning easier. Because chef's example recipe frequently use node[:network][:default_interface] and node[:ipaddress]. node[:ipoaddress] is ohai value value which is retrieved from which interface is used to reach gateway. Vagrant's VM's gatway is eth0 but eth0 can not be used to communicate multi-vm each other.

So,In chef's advanced recipe development like one haproxy lb and thre rails app, I need to change

node[:ipaddress]

in cloned recipe to

<% server_ip = member[:network][:interfaces][:eth1][:addresses].select { |e| e.last[:family]== "inet" }.flatten.first -%>o

like that.

Ofcause, current vagrant use eth0 as VM control and set it IP via dhcp, I think this change cause other probrem...

t9md commented 13 years ago

I re-think this feature request, and now I'm not sure it is good to implement this as Vagrant DSL. Because I can change default-gateway with provisioning. Thanks.

flaccid commented 11 years ago

Possible to re-open this one?

I would like something in vagrant to save me having to do https://github.com/flaccid/Vagrantfiles/blob/master/cpbm/Vagrantfile#L39

I found that with public_network behind a router, the default gateway needs to be changed so that the traffic can NAT in and out for those external hosts.

Interested in hearing better solutions or if there is something I am doing wrong.

prabu701 commented 10 years ago

Yes this can be handled by proivision for once. But when I restart the vm, the gateway is gone. Every time, I have to add provision when I do "vagrant up". That goes against what Vagrant is trying to solve.

delitescere commented 9 years ago

See https://github.com/mitchellh/vagrant/issues/2389#issuecomment-67455884 for a solution.