NetNatStaticMapping

Shahin Mortazave 491 Reputation points
2020-12-01T14:14:48.37+00:00

Hi,
is it possible to nat a rang of ports with NetNatStaticMapping?

Add-NetNatStaticMapping -ExternalIPAddress "0.0.0.0/24" -ExternalPort 5000-51000 -Protocol TCP -InternalIPAddress "10.0.20.15" -InternalPort 5000-51000 -NatName NATNetwork

if not, any idea how to do this?

Hyper-V
Hyper-V
A Windows technology providing a hypervisor-based virtualization solution enabling customers to consolidate workloads onto a single server.
2,758 questions
Windows Server Infrastructure
Windows Server Infrastructure
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Infrastructure: A Microsoft solution area focused on providing organizations with a cloud solution that supports their real-world needs and meets evolving regulatory requirements.
554 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Mico Mi 1,926 Reputation points
    2020-12-02T08:52:19.257+00:00

    Hi,
    Technically it is not possible to map multiple ports on a NAT policy. The best method of accomplishing your requirement is to configure multiple NAT policies mapping single source and destination ports if the number of ports is not large.

    Thanks for your time!
    Best Regards,
    Mico Mi

    -----------------------------

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Shahin Mortazave 491 Reputation points
    2020-12-07T12:52:01.287+00:00

    This would means that I have to map 1000 ports manually!!

    0 comments No comments

  3. Mico Mi 1,926 Reputation points
    2020-12-08T01:48:24.747+00:00

    Hi,
    It's a pity that there seems to be no command to map ports at the same time so far.
    Since ports need to be mapped one by one, mapping 1000 ports manually is indeed a big project.
    Best Regards,
    Mico Mi

    Thanks for your time!
    Best Regards,
    Mico Mi

    -----------------------------

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  4. Eric Siron 1,566 Reputation points MVP
    2020-12-09T02:20:40.293+00:00

    Not tested, but something along the lines of:

    50000..51000 | % {Add-NetNatStaticMapping -ExternalIPAddress "0.0.0.0/24" -ExternalPort $_ -Protocol TCP -InternalIPAddress "10.0.20.15" -InternalPort $_ -NatName NATNetwork }
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.