> ## Documentation Index
> Fetch the complete documentation index at: https://docs.megaport.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Using Packet Filters with NAT Gateway

> This help topic describes how to create, edit, and apply packet filter lists on a NAT Gateway.

export const Image = ({src, alt = '', caption, width, height, shadow}) => {
  const errorPrefix = '\x1b[31;1;4mERROR\x1b[0m: Image -';
  if (typeof src !== 'string') {
    src = String(src);
  }
  if (!src || src === 'undefined') {
    console.error(`${errorPrefix} \`src\` is required — rendering an empty string instead`);
    return <></>;
  }
  const img = <img className={['mega-image-style', shadow ? 'shadow' : ''].join(' ')} src={src} alt={alt} width={width} height={height} style={{
    display: 'block'
  }} />;
  return caption ? <figure>
      {img}
      <figcaption style={{
    textAlign: 'center',
    width
  }}>{caption}</figcaption>
    </figure> : img;
};

Packet filters control which traffic flows through your Megaport NAT Gateway (NAT Gateway). Packet filters allow data from defined IP addresses to pass through, and deny access to data from other defined IP addresses.

Packet filters are defined on a NAT Gateway after it has been ordered and has gone live. You then edit the configuration of your NAT Gateway to add the packet filters that you need. When you configure a connection to your NAT Gateway, you can add your packet filters to either the A-End or B-End of the connection, depending on your NAT Gateway's location.

<Image src="/images/nat/dia-packet-filters-nat-gateway.png" shadow={true} width={600} />

## Packet filter rules

* Packet filter lists are defined on a deployed NAT Gateway.
* Packet filter lists are applied to the VXC interface - either A-End or B-End, depending where your NAT Gateway is located.
* If no packet filters are applied to the connection, then all traffic is allowed to flow through your NAT Gateway.
* When a packet filter is applied to the connection, any traffic not permitted by the packet filter is denied.
* Packet filters support the following matches:
  * Source IP Address
  * Destination IP Address
  * IP Protocol
  * Source Port/Port Range (for TCP and UDP protocols)
  * Destination Port/Port Range (for TCP and UDP protocols)
* Packet filters support both IPv4 and IPv6.
* You can create up to 20 packet filter lists.
* Each packet filter list can contain up to 50 entries.

## Creating packet filters

You can only create packet filters on a deployed NAT Gateway. You can create a maximum of 20 packet filter lists per NAT Gateway.

**To create a packet filter list**

1. Create, order, and deploy a NAT Gateway.\
   For more information, see [Creating a NAT Gateway](/nat/creating-nat-gateway).

2. On the Services page, find your new NAT Gateway and click the gear icon next to the NAT Gateway in the Portal.
   <Image src="/images/nat/button-nat-gateway-details.png" alt="The NAT Gateway details button" shadow={true} width={250} />
   The NAT Gateway Configuration page appears.
   <Image src="/images/nat/edit-configure-nat-gateway.png" shadow={true} width={600} />

3. Select the **Packet Filter Lists** tab.\
   The Packet Filter List page appears.
   <Image src="/images/nat/packet-filters-config-nat-gateway.png" shadow={true} width={750} />

4. Click **New List** to add a new list.

5. Enter a name for your packet filter list in the **Name** field.

6. Enter your filter details.

   * **Action** -- Select Permit or Deny from the drop-down list.

   * **Source IP Address** -- Enter the source IP address you want to filter traffic from.

   * **Destination IP Address** -- Enter the destination IP address of your filter.

     <Note>
       The source IP address and destination IP address must be the same format. For example, they must both be IPv4 or IPv6.
     </Note>

   * **Protocol** -- Select the protocol to filter traffic on. If the protocol you require is not on the list, you can select **Custom**.

   * **IP Protocol Number** -- This will be populated automatically when you choose a protocol from the drop-down list. If you choose **Custom**, you must enter a number from the list of assigned internet protocol numbers.

   * **Source Ports** -- You can specify a source port or a range of ports in the format 1111-9999.

   * **Destination Ports** -- Specify a destination port or a range of ports.

   * **Description** (optional) -- Add a description.

   Use the position icon at the beginning of the row to reorder the list using drag and drop.\
   Click the trash icon at the end of the row to delete an entry in a list.

   <Image src="/images/nat/nat-packet-filters-position-and-delete.png" alt="A packet filter rule, highlighting the positioning handle in the first column and the trash (delete) button in the last column" shadow={true} width={650} />

7. Add as many entries to the list as you need, up to a maximum of 50 per list.

8. Click **Save**.

## Editing a packet filter list

Add or delete entries from a packet filter list, or update the settings of each entry.

**To edit a packet filter list**

1. Select the list you want to edit from the drop-down list.

2. Make your changes.\
   You can change any part of the list.

3. Click **Save**.

## Duplicating a packet filter list

You can duplicate a list to speed up filter configuration.

**To duplicate a packet filter list**

1. Select the list you want to duplicate from the drop-down list.

2. Click **Duplicate List**.

3. Enter a name for the list in the **Name** field.

4. Edit the required details in the list to make it unique.

5. Click **Save**.

## Deleting a packet filter list

You can delete entire lists if they are not required any more or are out of date.

**To delete a packet filter list**

1. Select the list you want to delete from the drop-down list.

2. Click **Delete List**.

3. Click **OK** to confirm.

## Applying a packet filter list

You can apply a packet filter list to the VXC when you create a connection from your NAT Gateway.

**To apply a packet filter list**

1. Create a connection from the NAT Gateway with the packet filter lists defined.\
   For more information, see [Creating a NAT Gateway VXC](/nat/nat-gateway-vxc).

2. In the VXC definition, enter the connection details then click **Next**.

3. On the NAT Gateway A-End page, enter these details:

   * **Interface IP Addresses** -- Enter the A-End interface IP address and subnet mask as required for your network.

   * **Packet Filters** -- Select a packet filter list from the **Inbound** or **Outbound** drop-down list, as required for your configuration.

   <Note>
     You can also fill in other fields here, such as IP addresses or BGP connections.\
     For more information, see [Configuring a NAT Gateway VXC](/nat/configuring-nat-vxc).
   </Note>

4. Click **Next**.

5. Read the Summary page and click **Add VXC**.

## Helpful references

* [Creating a NAT Gateway](/nat/creating-nat-gateway)
* [Creating a NAT Gateway VXC](/nat/nat-gateway-vxc)
* [Megaport NAT Gateway Route Filtering](/nat/route-filtering)
* [NAT Gateway Features](/nat/nat-gateway-features)
