Skip to content

Forwarded ports not being released with VMWare Fusion 8.5.3 #8130

@amacnamara

Description

@amacnamara

Vagrant version

Vagrant 1.9.1

Host operating system

macOS 10.12.1 (16B2659)

Guest operating system

Red Hat Enterprise Linux Server release 6.7 (Santiago)

Vagrantfile

Vagrant.configure("2") do |config|

# Hostmanager Settings
  config.hostmanager.enabled            = true    # Enable HostMan Plugin
  config.hostmanager.manage_host        = true    # Update Host's host file
  config.hostmanager.ignore_private_ip  = false
  config.hostmanager.include_offline    = true

  # Core Configurations
  config.vm.box            = "rcs_class_a_oel66_1.5.2"           # Specify the Vagrant Base Box by name
  config.vm.host_name      = "eaton.rcsdev.net"                  # Specify a hostname for the virtual machine
  config.ssh.forward_agent = true                                # Forward ssh keys
  config.ssh.forward_x11   = true                                # Forward X11
  config.vm.network "forwarded_port", guest: 7001,  host: 7001   # Forward WebLogic Admin Console Port
  config.vm.network "forwarded_port", guest: 4444,  host: 4444   # Forward RIDC Port
  config.vm.network "forwarded_port", guest: 16300, host: 16300  # Forward URM Port
  config.vm.network "forwarded_port", guest: 1521,  host: 1521   # Forward JDBC Port

  # Provisioning
  config.vm.provision "shell", path: "setup.sh"

  # VMWare specific
  config.vm.provider "vmware_fusion" do |v|
    v.vmx["memsize"] = "8192"
    v.vmx["numvcpus"] = "4"
    v.vmx["ethernet0.virtualDev"] = "vmxnet3"
  end

end

Expected behavior

When the machine is shut down, the forwarded ports should be freed up to be used by other vms. The port forwarding entries in /Library/Preferences/VMware\ Fusion/vmnet8/nat.conf should be removed.

Actual behavior

The port forwarding entries in /Library/Preferences/VMware\ Fusion/vmnet8/nat.conf are not removed. Vagrant catches and fixes the port collisions for the ssh port, which grabs another port to be used. Eventually, there are a lot of extra entries in nat.conf:

2201 = 192.168.225.136:22
2222 = 192.168.225.128:22
2204 = 192.168.225.145:22
2200 = 192.168.225.136:22
2202 = 192.168.225.140:22
2206 = 192.168.225.148:22
# VAGRANT-BEGIN: /Users/amacnamara/src/eat_urm_puppet/.vagrant/machines/default/vmware_fusion/8155631a-1c29-42a1-9a4f-0567011f98bd/oel66.vmx
2207 = 192.168.225.148:22
# VAGRANT-END: /Users/amacnamara/src/eat_urm_puppet/.vagrant/machines/default/vmware_fusion/8155631a-1c29-42a1-9a4f-0567011f98bd/oel66.vmx

This also causes other forwarded ports to collide, preventing vagrant up from running. In the above Vagrantfile example, port 7001 is set up in nat.conf, then never released, so subseguent vagrant ups fail.

Steps to reproduce

  1. Configure forwarded port in Vagrantfile
  2. vagrant up
  3. vagrant halt
  4. Reboot host
  5. vagrant up
  6. port collision

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions