Forge Home

windows_port_forwarding

Manage the windows port forwarding with Puppet

1,736 downloads

58 latest version

5.0 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 1.0.0 (latest)
  • 0.1.1
  • 0.1.0
released Sep 27th 2024
This version is compatible with:
  • Puppet Enterprise 2023.8.x, 2023.7.x, 2023.6.x, 2023.5.x, 2023.4.x, 2023.3.x, 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x
  • Puppet >= 6.0.0 < 9.0.0

Start using this module

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

Add this module to your Puppetfile:

mod 'webalex-windows_port_forwarding', '1.0.0'
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 1.0.0

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 1.0.0 Sep 27th 2024

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