> ## 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.

# Megaport NAT Gateway Route Filtering

> This help topic describes Megaport NAT Gateway route filtering concepts and filter types.

export const Anchor = ({name}) => {
  const errorPrefix = '\x1b[31;1;4mERROR\x1b[0m: Anchor -';
  if (name === undefined || name === null || name === 'undefined') {
    console.error(`${errorPrefix} \`name\` must have a value — rendering an empty string instead`);
    return <></>;
  }
  const raw = typeof name === 'string' ? name : JSON.stringify(name);
  const id = raw.replace(/\s+/g, '-').replace(/[^A-Za-z0-9_-]/g, '').replace(/-+/g, '-').replace(/^-+|-+$/g, '');
  if (!id) {
    console.error(`${errorPrefix} \`name\` "${name}" sanitizes to an empty id — rendering an empty string instead`);
    return <></>;
  }
  return <a style={{
    scrollMarginTop: 'var(--scroll-mt)'
  }} id={id}></a>;
};

export const Gloss = ({term, anchor, langDir = 'en'}) => {
  const errorPrefix = '\x1b[31;1;4mERROR\x1b[0m: Gloss -';
  if (typeof term !== 'string') {
    term = String(term);
  }
  if (typeof anchor !== 'string') {
    anchor = String(anchor);
  }
  if (!term || term === 'undefined') {
    console.error(`${errorPrefix} the \`term\` property is required — rendering an empty string instead`);
    return <></>;
  }
  if (!anchor || anchor === 'undefined') {
    console.error(`${errorPrefix} the \`anchor\` property is required — rendering an empty string instead`);
    return <></>;
  }
  const lang = langDir === 'en' ? '/' : '/' + langDir + '/';
  const glossaryPage = lang + 'glossary/#' + anchor;
  return <a href={glossaryPage}>{term}</a>;
};

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;
};

This topic provides an overview of Megaport NAT Gateway (NAT Gateway) route filtering concepts.

<Image src="/images/nat/dia-nat-route-filtering-base.png" width={570} />

<Anchor name="route-filtering-overview" />

## Route filtering overview

Route filtering provides control over NAT Gateway route installation and propagation, typically between two or more networks. The networks can be either on-premises or a Cloud Service Provider (CSP).

Route filters are optional and can be used to:

* redistribute or prevent redistribution of routes between Virtual Cross Connects (VXCs).
* create a BGP prefix filter that includes a set of IPv4 or IPv6 CIDR blocks to manage as a group.
* allow or deny specific routes on specific connections.

<Anchor name="defaultroutes" />

## Default peering route advertisements

NAT Gateways use <Gloss term="Border Gateway Protocol (BGP)" anchor="bgp" /> to exchange network reachability information with adjacent BGP systems, known as *neighbors*, or *peers*. NAT Gateways work in <Gloss term="multicloud" anchor="multicloud" /> architectures that are connected using different combinations of peering types. In addition to private peering connectivity, NAT Gateways can connect to public peering types such as AWS, Azure, Oracle, and other Cloud Service Providers (CSPs).

BGP communicates between two neighbors using a standard TCP connection. By default, once the BGP neighbors are connected, they share routing information with each other. The connection between the neighbors is called a BGP connection or session.

<Image src="/images/nat/dia-nat-route-filtering-bgp-peering.png" width={560} />

Without using any route filters, Megaport advertises routes to BGP connections based on these peering types:

| **Peering Type** | **Routes Advertised**                                                         | **Advertised To**                      |
| ---------------- | ----------------------------------------------------------------------------- | -------------------------------------- |
| Non-cloud        | Routes from the Border Gateway Protocol (BGP) peer behind a Port.             | Non-cloud, private cloud, public cloud |
| Private cloud    | Routes from AWS Private, Azure Private Peer, and Google Cloud Platform.       | Non-cloud, private cloud               |
| Public cloud     | Routes from AWS Public, Azure MS Peer, Salesforce, and other cloud providers. | Non-cloud                              |

As an example, a route received from a public cloud BGP connection will not be advertised to a private cloud BGP connection.

You cannot override or control the peering type route advertisement.

Route filtering doesn't change this existing peer type policy but provides finer control when you need to filter specific routes or prefixes that would have otherwise been discovered and exchanged between BGP neighbors. Route filters cannot be used to advertise routes that are already filtered based on the peer type.

For the default route advertisement details, see [Megaport NAT Gateway Route Advertisement](/nat/route-advertisement).

<Anchor name="selectfilter" />

## Selecting a filter type

You can set a route filter to define which route advertisements the NAT Gateway permits or denies from BGP neighbors. You can filter routes by BGP connection or by prefix. Route filtering supports IPv4 and/or IPv6 routes for each format.

The two filter types are:

* **BGP peer filter** -- A filter that permits or denies all routes exchanged between BGP neighbors. For example, in a network deployment with BGP neighbors A, B, and C, A and B are allowed to exchange routes with each other but not with C, while all neighbors can exchange routes with headquarters. BGP peer filtering provides a simple way to filter routes between the neighbors to meet these requirements.

  For more information, see [Megaport NAT Gateway BGP Peer Filtering](/nat/bgp-peer-filtering).

* **BGP prefix filter** -- An advanced filter that permits or denies specific routes using route prefixes (IP addresses or ranges) to identify individual neighbors. You can apply the same prefix filter to more than one BGP neighbor, eliminating the need to type manual, redundant prefix entries. You can specify a permit or deny action for each prefix in the filter list. You can apply different lists using import or export directions.

  For more information, see [Megaport NAT Gateway BGP Prefix Filtering](/nat/bgp-prefix-filtering).

## Helpful references

* [Configuring BGP for Megaport NAT Gateway](/nat/configure-bgp)
* [Megaport NAT Gateway BGP Peer Filtering](/nat/bgp-peer-filtering)
* [Megaport NAT Gateway BGP Prefix Filtering](/nat/bgp-prefix-filtering)
* [Megaport NAT Gateway Route Advertisement](/nat/route-advertisement)
* [Megaport NAT Gateway Route Summarization](/nat/route-summarization)
