Add a NAT rule

You can create NAT rules to modify the IP addresses and ports for traffic flowing between networks, generally between a trusted and an untrusted network.

You can specify source NAT rules for traffic originating from the specified source address and destination NAT rules for traffic to the specified destination address. You can also specify loopback policies to translate traffic from internal sources to internal servers.

To create a source NAT rule, specify the original and translated sources and the inbound and outbound interfaces.

To create a destination NAT rule, specify the original and translated destinations and services, and the inbound and outbound interfaces.

NAT method in destination rules allows you to enforce load balancing and failover for internal hosts. You can specify health checks to enforce the load balance and failover settings.

  1. Go to Rules and policies > NAT rules. Select IPv4 or IPv6 and then select Add NAT rule.
  2. The rule is turned on by default.
  3. Enter the rule details.
    NameDescription
    Rule name Enter a name.
    Rule group

    Select a rule group or create one. The firewall rule will belong to this group.

    If you select Automatic, the firewall rule is added to an existing group based on first match with rule type and source-destination zones.

  4. Specify the translation settings for source, destination, services, and interfaces to match traffic flowing through interfaces and VPN tunnels.

    Original source, destination, and service are the pre-NAT entities of traffic when it enters XG Firewall. Translated source, destination, and services are the post-NAT entities of traffic when it exits XG Firewall. You can select the original source, destination, and services or create new ones.

    NameDescription
    Original source Specify the pre-NAT source objects of outgoing traffic.

    To create an inbound NAT rule when the inbound IP address is unknown, select Any.

    Translated source (SNAT) IP addresses of the original source objects are translated to the IP addresses that you specify. Use this to perform source NAT (SNAT) for outgoing traffic. To masquerade traffic, select MASQ.

    To create an inbound NAT rule, select Original.

    Original destination Specify the pre-NAT destination objects of incoming traffic.

    To create an outbound NAT rule, select Any.

    Translated destination (DNAT) IP addresses of the destination objects are translated to the IP addresses or FQDN that you specify.

    To create an outbound NAT rule, select Original.

    Original service Specify the pre-NAT services. Services are a combination of protocols and ports.

    To create an outbound NAT rule, this is generally set to Any.

    Translated service (PAT) Original services are translated to the services that you specify. Use this for port address translation (PAT).

    If you've specified more than one original service or set it to Any, set the translated service to Original.

    The translated protocol must match the original protocol. You can translate original service ports to a single or equal number of translated service ports.

    You can use this to port forward traffic to internal servers, for example, specify TCP port 443 to forward incoming HTTPS traffic to an internal web server.

    Inbound interface

    Select the interfaces through which traffic specified in this rule enters XG Firewall.

    For destination NAT, you can specify Any.

    For VPNs, set this interface to Any, since VPNs are not interfaces.

    Outbound interface

    Select the interfaces from which traffic specified in this rule exits XG Firewall.

    For VPNs and for destination NAT rules that translate public IP addresses to private IP addresses, set this interface to Any.

  5. Optional Select Override source translation for specific outbound interfaces to apply interface-specific source translation. This option applies only to source NAT rules.
    1. Select the Outbound interface and Translated source (SNAT). To specify more than one, select Expand Expand button.
  6. Optional Select Create loopback rule to allow internal hosts to access other internal hosts, for example, servers.
  7. Optional Select Create reflexive rule to create a mirror rule that reverses the matching criteria of the rule from which it’s created.
    Note You can create loopback and reflexive rules for destination NAT rules. They are created, using the original NAT rule ID and name. Changing the original NAT rule settings later doesn’t change loopback and reflexive rule settings.
  8. Optional Select the Load balancing method to load balance traffic among the translated internal hosts.
    OptionDescription

    Round robin

    Requests are served sequentially, starting with the server next to the previously assigned server. Use it when you want to distribute traffic equally and don’t require session persistence.

    First alive

    Incoming requests are served to the primary server (the first IP address of the range). If the primary server fails, requests are forwarded to the next server and so on. Use it for failover.
    Random Requests are served randomly to the servers with equal load distribution. Use this when you want equal distribution and don’t require session persistence or order of distribution.
    Sticky IP Traffic from a specific source is forwarded to the mapped server. Use this when you want the requests to be processed by the same server.
    One-to-one Requests are sent to the mapped IP addresses. The IP addresses of the original and translated destinations must be equal in number.
  9. Optional Select Health check to enforce server failover. Specify the probe interval, response time-out and the number of retries after which to deactivate the host.

    Health check is enforced by default for First alive NAT method.

    1. Select the Probe method. You can select ICMP (ping) or TCP protocols.
    2. Enter the Port over which to check.
    3. Specify the Probe interval. It’s the interval between health checks.
    4. Specify the Response time-out. The server must respond within this time period to be considered alive.
    5. For Deactivate host after, specify the number of retries.
  10. Click Save.