{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/vagrant/issues/10407","repository_url":"https://api.github.com/repos/hashicorp/vagrant","labels_url":"https://api.github.com/repos/hashicorp/vagrant/issues/10407/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/vagrant/issues/10407/comments","events_url":"https://api.github.com/repos/hashicorp/vagrant/issues/10407/events","html_url":"https://github.com/hashicorp/vagrant/issues/10407","id":380425739,"node_id":"MDU6SXNzdWUzODA0MjU3Mzk=","number":10407,"title":"FR: Sanity checks for the port forwarding of Vagrant VMs","user":{"login":"danowar2k","id":10991509,"node_id":"MDQ6VXNlcjEwOTkxNTA5","avatar_url":"https://avatars2.githubusercontent.com/u/10991509?v=4","gravatar_id":"","url":"https://api.github.com/users/danowar2k","html_url":"https://github.com/danowar2k","followers_url":"https://api.github.com/users/danowar2k/followers","following_url":"https://api.github.com/users/danowar2k/following{/other_user}","gists_url":"https://api.github.com/users/danowar2k/gists{/gist_id}","starred_url":"https://api.github.com/users/danowar2k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danowar2k/subscriptions","organizations_url":"https://api.github.com/users/danowar2k/orgs","repos_url":"https://api.github.com/users/danowar2k/repos","events_url":"https://api.github.com/users/danowar2k/events{/privacy}","received_events_url":"https://api.github.com/users/danowar2k/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-11-13T21:13:00Z","updated_at":"2018-11-13T21:19:30Z","closed_at":null,"author_association":"NONE","body":"### Vagrant version\r\n2.2.0\r\n\r\n### Host operating system\r\nWindows 7\r\n\r\n### Guest operating system\r\nSolaris 11.3\r\n\r\n### Vagrantfile\r\n```ruby\r\n# -*- mode: ruby -*-\r\n# vi: set ft=ruby :\r\n\r\nVagrant.configure(\"2\") do |config|\r\n  (2..3).each do |i|\r\n    config.vm.define \"dev-#{i}\", autostart: false do |dev_vm_config|\r\n      dev_vm_config.vm.hostname = \"dev-#{i}\"\r\n      dev_vm_config.vm.box = \"heavybeans/solaris11-small-server\"\r\n      dev_vm_config.vm.network \"private_network\", ip: \"192.168.33.#{i}\"\r\n      dev_vm_config.vm.synced_folder \".\", \"/vagrant\", disabled: true\r\n    end\r\n  end\r\nend\r\n```\r\n### Debug output\r\nhttps://gist.github.com/danowar2k/6a2c423b5a7f85cd5559b8f2289ab873\r\n\r\n### Expected behavior\r\nThere should be some fail-safe mechanism that checks if a host port (in this case 2222) is being forwarded to by multiple machines and maybe throw an error if the Vagrantfile would result in such fail state. Ideally Virtualbox would prevent forwarding to the same port twice, but it doesn't, so....\r\n\r\n### Actual behavior\r\ndev-2 forwarded 22 to 2222.\r\ndev-3 forwarded 22 to 2222.\r\nNo one was warned of anything and so the up process was broken as soon as the second forward existed.\r\n\r\n### Steps to reproduce\r\n1. export VAGRANT_LOG=debug; vagrant up dev-2 dev-3"},"comment":{"url":"https://api.github.com/repos/hashicorp/vagrant/issues/comments/438440896","html_url":"https://github.com/hashicorp/vagrant/issues/10407#issuecomment-438440896","issue_url":"https://api.github.com/repos/hashicorp/vagrant/issues/10407","id":438440896,"node_id":"MDEyOklzc3VlQ29tbWVudDQzODQ0MDg5Ng==","user":{"login":"danowar2k","id":10991509,"node_id":"MDQ6VXNlcjEwOTkxNTA5","avatar_url":"https://avatars2.githubusercontent.com/u/10991509?v=4","gravatar_id":"","url":"https://api.github.com/users/danowar2k","html_url":"https://github.com/danowar2k","followers_url":"https://api.github.com/users/danowar2k/followers","following_url":"https://api.github.com/users/danowar2k/following{/other_user}","gists_url":"https://api.github.com/users/danowar2k/gists{/gist_id}","starred_url":"https://api.github.com/users/danowar2k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danowar2k/subscriptions","organizations_url":"https://api.github.com/users/danowar2k/orgs","repos_url":"https://api.github.com/users/danowar2k/repos","events_url":"https://api.github.com/users/danowar2k/events{/privacy}","received_events_url":"https://api.github.com/users/danowar2k/received_events","type":"User","site_admin":false},"created_at":"2018-11-13T21:19:30Z","updated_at":"2018-11-13T21:19:30Z","author_association":"NONE","body":"More info: The relevant lines in the box.ovf:\r\n``` xml\r\n<NAT>\r\n   <DNS pass-domain=\"true\" use-proxy=\"false\" use-host-resolver=\"false\"/>\r\n   <Alias logging=\"false\" proxy-only=\"false\" use-same-ports=\"false\"/>\r\n   <Forwarding name=\"SSH\" proto=\"1\" hostport=\"2222\" guestport=\"22\"/>\r\n</NAT>\r\n```\r\nThe relevant code in Vagrant (at least I think it is):\r\nSource: https://github.com/hashicorp/vagrant/blob/master/plugins/providers/virtualbox/driver/version_5_0.rb\r\n``` ruby\r\ndef ssh_port(expected_port)\r\n  @logger.debug(\"Searching for SSH port: #{expected_port.inspect}\")\r\n\r\n  # Look for the forwarded port only by comparing the guest port\r\n  read_forwarded_ports.each do |_, _, hostport, guestport|\r\n    return hostport if guestport == expected_port\r\n  end\r\n\r\n  nil\r\nend\r\n```\r\n"}}
{"actor":{"display_login":"danowar2k"}}