Forge Home

windows_port_forwarding

Manage the windows port forwarding with Puppet

1,101 downloads

927 latest version

5.0 quality score

Version information

  • 0.1.1 (latest)
  • 0.1.0
released Jul 9th 2021
This version is compatible with:
  • Puppet Enterprise 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x, 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
  • Puppet >= 4.7.0 < 7.0.0
  • windows

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'webalex-windows_port_forwarding', '0.1.1'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add webalex-windows_port_forwarding
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install webalex-windows_port_forwarding --version 0.1.1

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

webalex/windows_port_forwarding — version 0.1.1 Jul 9th 2021

Build Status

windows_port_forwarding

Table of Contents

  1. Description
  2. Usage - Configuration options and additional functionality
  3. Limitations - OS compatibility, etc.
  4. Development - Guide for contributing to the module

Description

Manage the windows port forwarding with Puppet (netsh as required). [IPHelper service is required]

Features

  • Create/edit/delete individual port forward (windows_port_forwarding)

Usage

windows_port_forwarding

Manage individual port forward

Listing port foward

The type and provider is able to enumerate the port forward existing on the system:

C:\>puppet resource windows_port_forwarding
...
windows_port_forwarding { '*:8991':
  ensure     => 'present',
  connect_on => '*:8989',
  protocol   => 'v4tov4',
}
windows_port_forwarding { '10.137.34.85:8889':
  ensure     => 'present',
  connect_on => '*:8988',
  protocol   => 'v4tov4',
}

You can limit output to a single port forward by passing its name as an argument, eg:

C:\>puppet resource windows_port_forwarding '*:8991'
windows_port_forwarding { '*:8991':
  ensure     => 'present',
  connect_on => '*:8989',
  protocol   => 'v4tov4',
}

Ensuring a port forward

The basic syntax for ensuring rules is:

windows_port_forwarding{"${$::ipaddress}:9090":
    ensure     => present,
    protocol   => 'v4tov4',
    connect_on => '*:8988';
}

If a port forward with the same name but different properties already exists, it will be updated to ensure it is defined correctly. To delete a port forward, set ensure => absent.

You can use listen_on parameter if you want to define custom resource title:

windows_port_forwarding{'port forward':
    ensure     => present,
    protocol   => 'v4tov4',
    listen_on  => '*:8990',
    connect_on => "${$::ipaddress}:8988";
}

Purging port forward

You can choose to purge unmanaged port forward from the system (be careful! - this will remove any port forward that is not manged by Puppet):

resources { 'windows_port_forwarding':
  purge => true;
}

Troubleshooting

  • Try running puppet in debug mode (--debug)
  • To reset port forward to default: netsh interface portproxy reset
  • Print all port forward using netsh netsh interface portproxy show all
  • Help on how to create port forward

Limitations

  • netsh is used. There is no PowerShell cmdlet available to manage port forward.
  • Requires the netsh interface portproxy command

Development

PRs accepted :)

Testing

Source