Navigation Menu

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

vagrant should be able to forward tcp and udp on the same port number #1108

Closed
hdorio opened this issue Sep 8, 2012 · 4 comments
Closed

Comments

@hdorio
Copy link
Contributor

hdorio commented Sep 8, 2012

try this

Vagrant::Config.run do |config|
  config.vm.box = "base"
  config.vm.forward_port 5000, 5000, { :name => "port1"}
  config.vm.forward_port 5000, 5000, { :name => "port2", :protocol => "udp" }
end

vagrant up

[default] VM already created. Booting if it's not already running...
[default] Clearing any previously set forwarded ports...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] -- 5000 => 5000 (adapter 1)
[default] Exporting NFS shared folders...
...

only one port is forwarded

@Leechael
Copy link

Leechael commented Sep 8, 2012

I'm just post same issue than I see your post...

See my patch here and hope it helps: https://gist.github.com/3677837

@whatupdave
Copy link

Has this reappeared in the new version?

Vagrantfile:

(10000..12000).each do |port|
  config.vm.forward_port port, port, protocol: 'tcp'
  config.vm.forward_port port, port, protocol: 'udp'
end

Error:

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

vm:
* Forwarded port '10000' (host port) is declared multiple times

@mitchellh
Copy link
Contributor

Fixed: e64696e

@mlex
Copy link
Contributor

mlex commented Aug 12, 2013

The problem reappears with vagrant 1.2.7. If I want to forward both udp and tcp port 53 using the following configuration

  config.vm.network :forwarded_port, guest: 53, host: 53000, protocol: 'tcp'
  config.vm.network :forwarded_port, guest: 53, host: 53000, protocol: 'udp'

then only the udp-port gets forwarded. The configuration for the tcp-port-forwarding is completely ignored.

The problem is in plugins/providers/virtualbox/util/compile_forwarded_ports.rb where the host_port is used as a key for the hash containing the forwarded-port-configurations. A fix similar to hdorio's fix 76c9f67 should work though.

mlex added a commit to mlex/vagrant that referenced this issue Aug 16, 2013
mitchellh added a commit that referenced this issue Aug 28, 2013
…ort-number

core: allow port-forwarding of the same port number but with different protocols [GH-1108]
@hashicorp hashicorp locked and limited conversation to collaborators Apr 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants