# Egress

{% embed url="<https://www.youtube.com/watch?v=4x20rkr-8jQ>" %}

## Understanding Egress&#x20;

Netmaker's Egress feature allows your network clients to reach external networks through a designated linux node. An Egress node is a netclient deployed on a device or router that has access to a specific subnet, such as:

* A Virtual Private Cloud (VPC)
* A Kubernetes Network
* A Home or Office Network
* A Private Network
* A Data Center

<figure><img src="https://1465744049-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSqMcN3gvfPLhO0hh4agC%2Fuploads%2Fkd3X0QUBbuTL1xLBRxZ8%2FScreenshot%202026-02-13%20204621.png?alt=media&#x26;token=9725f5e3-4adf-412c-b78e-7b751696f5d1" alt=""><figcaption></figcaption></figure>

When you create an Egress Route in the Netmaker UI, you specify which external network ranges the egress node can reach. Once configured, all clients in your Netmaker network (including external clients) can access those ranges through the Egress node.

<figure><img src="https://1465744049-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSqMcN3gvfPLhO0hh4agC%2Fuploads%2FH4wAvzwX7k0Sh5DI5Jvp%2Fimage.png?alt=media&#x26;token=ada5ddf4-8808-4739-86df-79251edb0b71" alt=""><figcaption></figcaption></figure>

Network Address Translation (NAT) is typically required for Egress nodes unless the external network can directly route traffic back to the Netmaker nodes. Netmaker now offers two NAT modes when configuring Egress Routes: Direct and Virtual

When creating an Egress Route with NAT enabled, Netmaker offers two NAT modes:

<figure><img src="https://1465744049-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSqMcN3gvfPLhO0hh4agC%2Fuploads%2FsVbGBBpKTTaIo3FlBsSw%2Fimage.png?alt=media&#x26;token=16d578cb-4f56-4dc8-b068-0268840a21ff" alt=""><figcaption></figcaption></figure>

* **Direct:**  The traditional NAT mode that requires unique IP ranges for each remote site
* **Virtual:** A new mode available in the e**nterprise plan** that assigns virtual IP ranges, allowing multiple sites with overlapping local IPs to coexist. It resolves a key limitation by enabling connectivity across these overlapping networks.

{% hint style="info" %}
NAT can be disabled for users who prefer to manage their own masquerading and post-routing rules, or who need to preserve source IP addresses.
{% endhint %}

## Configuring an Egress Gateway

Deploy a netclient on a network-accessible **Linux** node such as a server, office router, or Kubernetes worker node—that is stable and mostly static (minimal IP changes or downtime). For HA Egress, you can assign the route to a group of Linux nodes to provide redundancy and continuous connectivity.

<figure><img src="https://1465744049-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSqMcN3gvfPLhO0hh4agC%2Fuploads%2FybtOdZt8eUaEABgNwwNk%2Fimage.png?alt=media&#x26;token=a49299f1-9839-4bfe-95fb-d816e9a81d1a" alt=""><figcaption></figcaption></figure>

Click the **"Add Route"** button to open the "Create New Egress Route" modal.

<figure><img src="https://1465744049-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSqMcN3gvfPLhO0hh4agC%2Fuploads%2FTVb4WmiQnpfcS79ehyKX%2Fimage.png?alt=media&#x26;token=4d4ceb4e-5e2a-447b-a00b-215369ea9df3" alt=""><figcaption></figcaption></figure>

{% stepper %}
{% step %}

### Enter a Name (Required)

In the **Name** field, enter a unique and descriptive name for this egress route.

Example: `nyc-office`
{% endstep %}

{% step %}

### Enter a Description (Optional)

In the **Description** field, optionally describe the purpose or location of this egress route.

Example: `NYC office LAN network`
{% endstep %}

{% step %}

### Set the NAT mode to Direct or Virtual (Required)

**Direct:** Standard NAT for unique IP addresses.

**Virtual:** Enables multiple sites with overlapping IPs.
{% endstep %}

{% step %}

### Specify Egress Target (Required)

In the **Egress** field, enter the external resource this egress route should reach. You can specify:

* Subnet → `10.116.0.0/20`
* Single IP → `10.116.0.18/32`
* Domain (BETA) → `example.com`
  {% endstep %}

{% step %}

### Click "Next"

After completing all fields, click the **"Next"** button to continue with the egress route creation.
{% endstep %}

{% step %}

### Select a node to act as an Egress

Select the node (netclient) to serve as the Egress node for the route, or assign a tag to enable HA Egress.

<figure><img src="https://1465744049-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSqMcN3gvfPLhO0hh4agC%2Fuploads%2Fo5fLf1qYNDMAafBnJ0dr%2Fimage.png?alt=media&#x26;token=c9c5fc19-8c78-424e-b1c3-de9582b87eb9" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

### Configure Egress Access Policies (Optional but Recommended)

Purpose: Define **which nodes and users** are allowed to access the egress route.

<figure><img src="https://1465744049-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSqMcN3gvfPLhO0hh4agC%2Fuploads%2FkWyN021fEeTgHje6JZjU%2Fe4.png?alt=media&#x26;token=123fb8c8-ba7e-43ee-8226-e314b0b7d167" alt=""><figcaption></figcaption></figure>

{% stepper %}
{% step %}

### Add Resources Policy

Select the **nodes** that are allowed to route traffic through the egress route.<br>

<figure><img src="https://1465744049-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSqMcN3gvfPLhO0hh4agC%2Fuploads%2FuSerzX7PX6lyoVJcO4cg%2Fe5.png?alt=media&#x26;token=2bee01ec-7008-4d1a-b9ee-0f96364d9df3" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Add Users Policy

Select the **users** who are allowed to access the egress route

<figure><img src="https://1465744049-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSqMcN3gvfPLhO0hh4agC%2Fuploads%2FsKcuIWOGY6KAcxby8lxh%2Fe6.png?alt=media&#x26;token=67a37b59-0ea0-4fa8-8d17-e1338df4139b" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### When finished, click "Finish" to save the configuration.

<figure><img src="https://1465744049-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSqMcN3gvfPLhO0hh4agC%2Fuploads%2FXaAxguUmcGihyvL0ronW%2Fimage.png?alt=media&#x26;token=385bc85a-d4c9-4185-bf20-be4b3365824d" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### If you have multiple ranges to add, click "Add Route" again.

<figure><img src="https://1465744049-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSqMcN3gvfPLhO0hh4agC%2Fuploads%2FgCa0wwmxjvAenUFkRbPI%2Fimage.png?alt=media&#x26;token=fd7950d2-1320-472f-8561-3cc5fc990ede" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

Netmaker will set either iptables or nftables rules on the node depending on which one you have installed on your client. This will then implement these rules, allowing it to route traffic from the network to the specified range(s).

### The Overlapping IP Problem

In many organizations, remote sites independently use the same private IP address ranges. This is very common because:

* Branch offices often use standard ranges like 192.168.1.0/24 or 10.0.0.0/8
* Acquired companies already have established networks that can't be easily changed
* Customer sites use default router configurations with identical IP schemes

Why This Is a Problem: Imagine you have three branch offices:

1. NYC office: 192.168.1.0/24
2. LA office: 192.168.1.0/24
3. Chicago office: 192.168.1.0/24

Each office has a server at 192.168.1.10. When you try to connect to 192.168.1.10, which office's server should you reach? Your network can't tell them apart because they all use the same address. This creates a routing conflict.

**Traditional Limitation:** In Direct NAT mode, Netmaker could only route to one office at a time. Accessing additional sites required renumbering networks to ensure unique IP ranges—a costly and time-consuming process.

### Virtual NAT Mode: The Solution for Egress Routes

Virtual NAT mode assigns each remote network accessed through an Egress Route a unique virtual IP range. When you configure an Egress Route with Virtual NAT:

* You specify the actual remote network in the Egress field (e.g., 192.168.1.0/24)
* You select "Virtual" as the NAT mode\ <br>

  <figure><img src="https://1465744049-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSqMcN3gvfPLhO0hh4agC%2Fuploads%2Fk0xzF6xlNIRNqwQdgTkv%2Fimage.png?alt=media&#x26;token=e785375c-2688-4043-a52f-f163b653a740" alt=""><figcaption></figcaption></figure>
* Virtual NAT automatically assigns a unique virtual IP range (e.g., 198.19.10.0/24) defined under the network settings\ <br>

  <figure><img src="https://1465744049-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSqMcN3gvfPLhO0hh4agC%2Fuploads%2FlqUeyJ5IrkVFa2ANBAwg%2Fimage.png?alt=media&#x26;token=28f1a4b6-be24-4960-bdeb-d3ebf332448e" alt=""><figcaption></figcaption></figure>
* Netmaker clients use the virtual range to access the remote network
* The egress node automatically translates between virtual and actual IPs

This removes the previous limitation on overlapping IP ranges for Egress Routes, enabling both site-to-site and remote access use cases with conflicting network addresses.

#### Setting Your Own Virtual IP Range

1. Access the network interface and edit the network settings<br>

   <figure><img src="https://1465744049-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSqMcN3gvfPLhO0hh4agC%2Fuploads%2FIyog0G7dzgM1kFJVEuTK%2Fimage.png?alt=media&#x26;token=03a54c1a-b8e3-4921-8d36-d51240eb1822" alt=""><figcaption></figcaption></figure>

2. Enter the desired virtual subnet (e.g., `197.0.8.2/16`)\ <br>

   <figure><img src="https://1465744049-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSqMcN3gvfPLhO0hh4agC%2Fuploads%2FWjADhT950o0WREHkB9z7%2Fimage.png?alt=media&#x26;token=a284dd0a-bb32-4024-8304-ad6cb3e12b71" alt=""><figcaption></figcaption></figure>

3. Apply network configuration changes.

## Advanced Use Cases

1. Segmenting Traffic Flow Through Egress Gateways

   User will need to add these additional routing rules on the egress machine to segment traffic to multiple egress ranges as desired when on multiple networks

```plaintext
iptables -t filter -N netmakeregressiptables -t filter -I FORWARD -i netmaker -d egressGwRangeA,egressGwRangeB -j netmakeregressiptables -t filter -I netmakeregress -s networkRangeA -d egressRangeA -j ACCEPTiptables -t filter -I netmakeregress -s networkRangeB -d egressRangeB -j ACCEPTiptables -t filter -A netmakeregress -j DROP# NAT Rulesiptables -t nat -I POSTROUTING -s networkRangeA -d egressGwRangeA -j MASQUERADEiptables -t nat -I POSTROUTING -s egressGwRangeA -d networkRangeA -j MASQUERADEiptables -t nat -I POSTROUTING -s networkRangeB -d egressGwRangeB -j MASQUERADEiptables -t nat -I POSTROUTING -s egressGwRangeB -d networkRangeB  -j MASQUERADE
```

plaintext

2. IPv6 NAT Masquerading for Egress Gateways

   Currently IPv6 Egress Gateways are not working because the default kernel builds for most common linux distributions do not support ipv6 masquerading. Custom linux kernel needs to be built with flag for enabling ipv6 masquerading to get ipv6 egress gateways working.

   Some online resources about the topic:

```plaintext
https://superuser.com/questions/1751062/ipv6-masquerading-on-linuxhttps://www.kernelconfig.io/config_nf_nat_masquerade_ipv6?q=&kernelversion=5.15.116&arch=x86https://www.reddit.com/r/PFSENSE/comments/vb4r3s/ip6_masquerading
```

plaintext

### Egressing External Clients <a href="#egressing-external-clients" id="egressing-external-clients"></a>

Unmanaged external clients that are directly connected to a Remote Access Gateway can also act as egressing machines. The idea is the same as egress gateways. The only difference is that Netclient is necessary with egress gateways, whilst only Wireguard is needed with egressing external clients. This feature is provisioned for situations or scenarios where installation of Netclient is not ideal or even possible. For example most VPN routers support WireGuard, but they are available only as plugins that are tailormade or closely coupled with the router’s firmware or user interface. While there are ways to make Netclient work for some routers, the integration could get cumbersome, obsolete, or compromising. Of course this feature is also applicable for simple or ad-hoc networking purposes so long as the external client supports iptables and IP forwarding.

At the time of this writing, this feature only supports Linux-based external clients. But the remote machines can be anything, provided they are in the same local network as one of the egressing external client’s network interface.

#### Configuring Egressing External Clients <a href="#egressing-external-clients__configuring-egressing-external-clients" id="egressing-external-clients__configuring-egressing-external-clients"></a>

The configuration is pretty much the same as Egress Gateways. First, make sure that iptables is installed and IP forwarding is enabled. Please refer to your distro’s documentation on how to do this. For Ubuntu you might do:

```plaintext
#update
apt-get update

#install
iptablesapt-get install iptables

#enable IP forwarding
sysctl -w net.ipv4.ip_forward=1
```

You can then responsibly specify the applicable egress ranges on the external client’s VPN configuration, specifically in the “Additional Addresses” field as shown in the image below. It goes without saying that you can specify single addresses such as 172.16.1.2/32.

<figure><img src="https://1465744049-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSqMcN3gvfPLhO0hh4agC%2Fuploads%2FQbP33LPt7scl3LDyKtIm%2Fe11.jpg?alt=media&#x26;token=474efc0c-703d-47d1-8006-574b9f4ef445" alt=""><figcaption></figcaption></figure>

Your Netmaker server will then pick up the egress ranges and propagate it to all the other managed devices in the netmaker network. And of course you can edit them anytime when necessary. For more information on how to create or edit client VPN configurations, please refer to these links:

{% content-ref url="../getting-started/operations-field-guide/deploying-static-wireguard" %}
[deploying-static-wireguard](https://learn.netmaker.io/getting-started/operations-field-guide/deploying-static-wireguard)
{% endcontent-ref %}

{% content-ref url="../how-to-guides/integrating-non-native-devices" %}
[integrating-non-native-devices](https://learn.netmaker.io/how-to-guides/integrating-non-native-devices)
{% endcontent-ref %}

In some cases you might need to add POSTROUTING rules. In Ubuntu, you might do:

```plaintext
#get the name of the specific network interface of the egressing client machine# that is associated with the egress ranges that you have specifiedip a#add the necessary POSTROUTING rule, say the interface name is `eth1`iptables -t nat -I POSTROUTING -o eth1 -j MASQUERADE
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.netmaker.io/features/egress.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
