12

I am using the VMWare Plugin. I am currently using the following :

config.vm.network "public_network", ip: "172.17.255.13", netmask: "255.255.255.0"

It does indeed make a BRIDGED connection, however it is a BRIDGED DHCP Connection.

Has anybody used static IP's successfully?

It is a CentOS-6.6 Box.

Update: It was the particular VM configuration, the creator didn't delete a file in /etc/ that needs to be cleared before VM packaging

grepsedawk
  • 3,324
  • 2
  • 26
  • 49

3 Answers3

5

I came up with a pretty elegant solution while waiting for this to get patched by the vagrant-vmware-workstation plugin team.

I set up vagrant set up a public_network with auto_config set to false. (So vagrant doesn't overwrite the file I change)

config.vm.network "public_network", auto_config: false

After I set that up, I can run a shell provisioner to echo to the file that contains the settings for eth1 (eth0 is always vagrant's host only network)

config.vm.provision "shell" do |s|
    s.path = "setIP.sh"
    s.args   = ["192.168.1.150", "255.255.255.0"] #ip/netmask
    privileged = "true"
end

It runs a shell script passing the IP and Netmask into the shell script as arguments.

The shell script modifies /etc/sysconfig/network-scripts/ifcfg-eth1 (the config file for eth1 in CentOS-6.6) then proceeds to restart networking to make the settings take effect.

setIP.sh:

echo Setting IP to $1, Netmask to $2
cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-eth1

#PACHONK SET-IP CONFIG BEGIN
IPADDR=$1
NETMASK=$2
ONBOOT=yes
DEVICE=eth1
#PACHONK SET-IP CONFIG BEGIN

EOF

#Restart networking to make IP active
/etc/init.d/network restart

Like I said, looks like it's been a bug for awhile. I created the most elegant fix I could for the time being.

grepsedawk
  • 3,324
  • 2
  • 26
  • 49
1

According to this bug thread, people encountered the same issue when they were using vmware_fusion as provider; while is was working with a virtualbox provider.

It seems that a v3.2.0 of the VMware Fusion/Workstation plugin have been released with a bugfix for this. Try to update your VMWare Plugin to this version and test it again.

But if we take a look at the Vagrant VMWare Plugin for 3.2.0, it mentions:

core: static IPs work for public networks (private networks have always works)

And nothing in the newly released versions (> 3.2.0) seems to fix this.

Pierre
  • 2,552
  • 5
  • 26
  • 47
0

Turns out the CentOS base vagrant box we were using had some kind of issue. I packaged a fresh CentOS vagrant box by hand, and it was able to provision using the vagrant plugin.

grepsedawk
  • 3,324
  • 2
  • 26
  • 49