Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added an option to specify Host and guest ip for port forward #1121

Closed
wants to merge 6 commits into from

8 participants

@rrehbeindoi

Added an option to specify Host and guest ip for port forward.

Also changed the default SSH to use the loopback interface rather then bind to 'all interfaces'. This should mitigate the openness of vagrant boxes with known username/password full ssh access to anyone that can talk to port 2222 (and family)

@arteal

I think this is must-have feature! Thanks for writing it and I hope it will be included soon!

@taurus-forever

We also do need this functionality too and can help with testing it for next Vagrant release if require. Tnx!

@jbmaster

Nice feature. However there is an issue if you need to forward the same port on multiple guestip.
In this case vagrant create only one entry, for port that is defined later in config.

@rrehbeindoi

Thank you. I had not considered the possibility of 2+ of 3+ guest interfaces. Short term, 'all interfaces' is still available by either leaving the guestip option off, or setting it to blank, which would match the current 'all interfaces' default behavior.

@mconigliaro

Wow, we just discovered this "SSH listens on all interfaces by default" business. It seems crazy to me that this is the default setting, let alone that there is apparently no way to change it. Since this pull request was never accepted, does anyone have a workaround?

@rrehbeindoi

Till @mitchellh gets around to it, the workaround is to have a properly configured firewall. Technically, you should anyway, but I'd feel better if there was a bit more of a 'many moats' factor, rather then assuming users enable their firewalls.

Other then having #1122 closed, I haven't gotten any form of vagrant developer feedback about this feature. So far, it has just comments from vagrant users.

@mitchellh
Owner

Apologies for being so late and missing this PR. This looks good. Looking into merging now.

@rcarmo

Erm... I just came across this looking for this very same functionality, and it's been two months...

@rurounijones

Being able to specify the IP address on the guest is essential when you having services binding to specific private IP addresses. +1 for this functionality.

@rurounijones

It looks like this was (half?) fixed on the commit jbmaster commented on and linked to above, to fix the SSH issue GH-1785 that was also fixed in this pull request.

It looks like some "guestip" code was added to that pull request but I am not sure if it gets us the full guest IP binding ability. @rrehbeindoi , I don't suppose you could confirm this?

@rrehbeindoi

These changes appear to be have been added for the VirtualBox 4.2 driver. Not sure if it matters for people 'keeping up to date' that it is still missing for 4.1 and 4.0.

@mitchellh
Owner

This is in and part of the release of 1.2.3, but only for VirtualBox 4.2. Support for other versions was just added.

@mitchellh mitchellh closed this
@znz znz referenced this pull request from a commit in znz/vagrant
@znz znz pass guest_ip option from config to driver [GH-1121] 8890676
@dldinternet dldinternet referenced this pull request from a commit in dldinternet/vagrant
@mitchellh Forward ports can specify host/guest IP to bind to [GH-1121] 0eaa07d
@dldinternet dldinternet referenced this pull request from a commit in dldinternet/vagrant
@mitchellh Forward ports can specify host/guest IP to bind to [GH-1121] 9bf51fc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
4 plugins/providers/virtualbox/driver/version_4_0.rb
@@ -142,9 +142,9 @@ def forward_ports(ports)
ports.each do |options|
pf_builder = [options[:name],
options[:protocol] || "tcp",
- "",
+ options[:hostip] || "",
options[:hostport],
- "",
+ options[:guestip] || "",
options[:guestport]]
args.concat(["--natpf#{options[:adapter] || 1}",
View
4 plugins/providers/virtualbox/driver/version_4_1.rb
@@ -142,9 +142,9 @@ def forward_ports(ports)
ports.each do |options|
pf_builder = [options[:name],
options[:protocol] || "tcp",
- "",
+ options[:hostip] || "",
options[:hostport],
- "",
+ options[:guestip] || "",
options[:guestport]]
args.concat(["--natpf#{options[:adapter] || 1}",
Something went wrong with that request. Please try again.