Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port forwarding unique checking does not use IP address #7905

Closed
andkirby opened this issue Oct 17, 2016 · 5 comments
Closed

Port forwarding unique checking does not use IP address #7905

andkirby opened this issue Oct 17, 2016 · 5 comments

Comments

@andkirby
Copy link

andkirby commented Oct 17, 2016

In a nutshell, there is no ability to forward the same port of different IP addresses to a guest OS.

E.g.:
Host 127.0.0.111:80 => guest 8011
Host 127.0.0.222:80 => guest 8022

Vagrant version

1.8.6

Host operating system

Windows 10

Guest operating system

CentOS

Vagrantfile

VAGRANTFILE_API_VERSION = '2'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = 'centos/7'
  config.vm.box_check_update = false
  config.vm.boot_timeout = 300

  config.vm.network 'forwarded_port', guest: 8011, host: 80, host_ip: '127.0.0.111', id: 'aaa'
  config.vm.network 'forwarded_port', guest: 8022, host: 80, host_ip: '127.0.0.222', id: 'bbb'
end

Expected behavior

Added ports forwarding as expected:

  • Host 127.0.0.111:80 => guest 8011
  • Host 127.0.0.222:80 => guest 8022

Actual behavior

Error output

There are errors in the configuration of this machine. Please fix
the following errors and try again:

vm:
* Forwarded port '80' (host port) is declared multiple times
with the protocol 'tcp'.

Steps to reproduce

  1. Run vagrant up in the same directory as Vagrantfile

References

I have found the code which responsible for this:
https://github.com/mitchellh/vagrant/blob/7eb1091a7102dd4d2ebab762ee1658689a889880/plugins/kernel_v2/config/vm.rb#L688

In my understanding there is the host_ip option should be used. And, seem, guest_ip (without it, it will produce the same problem but on the guest side.)

@andkirby
Copy link
Author

andkirby commented Oct 17, 2016

Stackoverflow issue.

@andkirby
Copy link
Author

andkirby commented Oct 17, 2016

P.S.
Seem, the method VagrantPlugins::Kernel_V2::VMConfig::validate() is really huge. Can it be refactored?.. If it will be split, it would be easier to overwrite code parts.

@chrisroberts
Copy link
Member

#7035

@chrisroberts
Copy link
Member

Fixed via: #7035

@ghost
Copy link

ghost commented Apr 2, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@hashicorp hashicorp locked and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants