[PR #487] External NAT IP mapping support #2769

Open
opened 2025-11-20 08:03:56 -05:00 by saavagebueno · 0 comments
Owner

Original Pull Request: https://github.com/netbirdio/netbird/pull/487

State: closed
Merged: Yes


Support external IP mappings for host interface IPs

The external IP must not be behind a CGNAT and port-forwarding for incoming UDP packets from WgPort on from the external IP to WgPort on the host interface IP must be present. This can take form of:

  • single port-forwarding rule from external IP to host interface IP
  • 1:1 DNAT mapping ExternalIP to host interface IP
  • NAT DMZ to host interface IP.

Configuration

A special value of stun will use the STUN server's XORMappedAddress to set the External IP value; this is for installations behind dynamic DHCP assuming the above restrictions are met.

A single mapping will take the form of external[/internal]

  • external (required):
    • external IP address or stun to use STUN to determine the external IP address
  • internal (optional)
    • the host interface IP address or an interface name
    • if the "internal" argument is present and "stun" is specified for external, the STUN request will be generated by a connection originating from the specified host interface IP

Examples:

 "stun"                 => all interface IPs will be mapped to external IP reported by stun
 "12.34.56.78"          => all interfaces IPs will be mapped to external IP of 12.34.56.78
 "stun/eth0"            => IPv4 assigned to interface eth0 will be mapped to external IP reported by stun
 "stun/10.1.2.3"        => interface IP 10.1.2.3 will be mapped to external IP reported by stun
 "12.34.56.78/eth0"     => IPv4 assigned to interface eth0 will be mapped to external IP of 12.34.56.78
 "12.34.56.78/10.1.2.3" => interface IP 10.1.2.3 will be mapped to external IP of 12.34.56.78
**Original Pull Request:** https://github.com/netbirdio/netbird/pull/487 **State:** closed **Merged:** Yes --- ### Support external IP mappings for host interface IPs The external IP **_must not be behind_** a CGNAT **_and_** port-forwarding for incoming UDP packets from `WgPort` on from the external IP to `WgPort` on the host interface IP **_must be present_**. This can take form of: - single port-forwarding rule from external IP to host interface IP - 1:1 DNAT mapping ExternalIP to host interface IP - NAT DMZ to host interface IP. #### Configuration A special value of `stun` will use the STUN server's XORMappedAddress to set the External IP value; this is for installations behind dynamic DHCP assuming the above restrictions are met. A single mapping will take the form of `external[/internal]` - `external` (required): - external IP address or `stun` to use STUN to determine the external IP address - `internal` (optional) - the host interface IP address or an interface name - if the "internal" argument is present and "stun" is specified for `external`, the STUN request will be generated by a connection originating from the specified host interface IP #### Examples: ``` "stun" => all interface IPs will be mapped to external IP reported by stun "12.34.56.78" => all interfaces IPs will be mapped to external IP of 12.34.56.78 "stun/eth0" => IPv4 assigned to interface eth0 will be mapped to external IP reported by stun "stun/10.1.2.3" => interface IP 10.1.2.3 will be mapped to external IP reported by stun "12.34.56.78/eth0" => IPv4 assigned to interface eth0 will be mapped to external IP of 12.34.56.78 "12.34.56.78/10.1.2.3" => interface IP 10.1.2.3 will be mapped to external IP of 12.34.56.78 ```
saavagebueno added the pull-request label 2025-11-20 08:03:56 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#2769