Skip to content

Commit

Permalink
Bind default SSH to 127.0.0.1 [hashicorpGH-1785]
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Jun 9, 2013
1 parent 6c99f3d commit ba91602
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ FEATURES:
- Added a `working_directory` configuration option to the Puppet apply
provisioner so you can specify the working directory when `puppet` is
called, making it friendly to Hiera data and such. [GH-1670]
- Ability to specify the host IP to bind forwarded ports to. [GH-1785]

IMPROVEMENTS:

Expand All @@ -23,6 +24,8 @@ IMPROVEMENTS:
- VirtualBox: Only configure networks if there are any to configure.
This allows linux's that don't implement this capability to work with
Vagrant. [GH-1796]
- Default SSH forwarded port now binds to 127.0.0.1 so only local
connections are allowed. [GH-1785]

BUG FIXES:

Expand Down
1 change: 1 addition & 0 deletions config/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
config.vm.network :forwarded_port,
guest: 22,
host: 2222,
host_ip: "127.0.0.1",
id: "ssh",
auto_correct: true

Expand Down
1 change: 1 addition & 0 deletions plugins/providers/virtualbox/action/forward_ports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def forward_ports
ports << {
:adapter => fp.adapter,
:guestport => fp.guest_port,
:hostip => fp.host_ip,
:hostport => fp.host_port,
:name => fp.id,
:protocol => fp.protocol
Expand Down
4 changes: 2 additions & 2 deletions plugins/providers/virtualbox/driver/version_4_2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,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}",
Expand Down
6 changes: 6 additions & 0 deletions plugins/providers/virtualbox/model/forwarded_port.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class ForwardedPort
# @return [Integer]
attr_reader :guest_port

# The IP that the forwarded port will bind to on the host machine.
#
# @return [String]
attr_reader :host_ip

# The port on the host used to access the port on the guest.
#
# @return [Integer]
Expand All @@ -43,6 +48,7 @@ def initialize(id, host_port, guest_port, options)
@auto_correct = true
@auto_correct = options[:auto_correct] if options.has_key?(:auto_correct)
@adapter = (options[:adapter] || 1).to_i
@host_ip = options[:host_ip] || nil
@protocol = options[:protocol] || "tcp"
end

Expand Down

0 comments on commit ba91602

Please sign in to comment.