Skip to main content

ipnat resource

Use the ipnat Chef InSpec audit resource to test rules that are defined for IP NAT. The purpose of the ipnat utility is to add or remove set of IP NAT rules. Rules are added to the end of the internal lists, matching the order in which they appear when given to ipnat. ipnat -l helps to view the current NAT table entry mappings. The rule match is done against the output rules of ipnat -l.



This resource is distributed with Chef InSpec and is automatically available for use.


An ipnat resource block declares tests for rules set for IP NAT:

describe ipnat do
  it { should have_rule("RULE") }


  • have_rule('RULE') tests the active rule for IP NAT. This must match the entire line taken from ipnat -l.


The following examples show how to use this Chef InSpec audit resource.

Test to ensure mapping rule of the internally used IP address with ISP provided 8-bit subnet at

describe ipnat do
  it { should have_rule("map en0 ->") }

Test to ensure if there is a NAT rule to use the builtin ftp-proxy

describe ipnat do
  it { should have_rule("map en0 -> proxy port ftp ftp/tcp") }


The rule specification must match the output of ipnat -l that depends on how you have built your rules.


For a full list of available matchers, see our Universal Matchers page.

This resource has the following special matchers.


The have_rule matcher tests the named rule against the information in the output rule of ipnat -l:

it { should have_rule("RULE") }
Edit this page on GitHub

Thank you for your feedback!


Search Results