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

# Aviatrix Gateway to FortiGate

> This document describes how to configure an IPsec tunnel between an Aviatrix Gateway and a FortiGate firewall using Aviatrix Site2Cloud. This task is divided into two parts:

This document describes how to configure an IPsec tunnel between an Aviatrix
Gateway and a FortiGate firewall using Aviatrix Site2Cloud. This task is divided
into two parts:

1. Configure a [Site2Cloud tunnel](#setting-up-external-s2c-connection) in
   Aviatrix CoPilot.
2. Configure a [VPN tunnel](#fortigate-configuration) and related components in
   the FortiGate Firewall.

<a id="fg-s2c-avtx-start" />

## Setting up External (S2C) Connection

1. In Aviatrix CoPilot, launch an
   <a href={"/docs/enterprise/" + "10.1" + "/reference/ui/cloud-fabric/gateways#view-transit-gateways"}>Aviatrix Transit Gateway</a>
   .
2. Navigate to Networking > Connectivity > External Connections (S2C) and click
   *Add New* to create a Site2Cloud connection using the values for one of the
   below options (for either you can select either PSK or certificate-based
   authentication).

* [Static Route-Based](https://legacy.docs.aviatrix.com/documentation/latest/network/external-connection-create-static-route-based-unmapped.html)
* [Static Policy-Based](https://legacy.docs.aviatrix.com/documentation/latest/network/external-connection-create-static-policy-based-unmapped.html)

3. After the connection is created, select the vertical ellipsis
   <img src="https://mintcdn.com/aviatrix-14b37c43/Gre8pdluiL7JmlpL/images/guides/connectivity/vpn/threedot.png?fit=max&auto=format&n=Gre8pdluiL7JmlpL&q=85&s=36963cd7f65aa469c6d5fe2021fa71a7" alt="Three dots menu" width="24" height="34" data-path="images/guides/connectivity/vpn/threedot.png" /> menu for
   that connection and select *Download Configuration*.
4. Select *Generic* from the *Vendor* dropdown list and click the *Download* to
   download the external (S2C) configuration. Use this configuration file to
   configure the tunnels and interfaces in your Fortinet FortiGate firewall.

<a id="fg-s2c-fg-start" />

## FortiGate Configuration

The configuration and screenshots below make the following three assumptions:

* There are two interfaces on the FortiGate:
  * Interface port1 is an externally facing interface.
  * Interface port2 is an internally facing interface.
* You have a subnet in AWS, Azure, or GCP in a VPC/VNet that has an Aviatrix
  Gateway. This subnet is defined as "10.0.0.0/16" for the examples below but it
  can be any valid CIDR range.
  <Note>In the examples below this range is referred to as *AWS\_Cloud*.</Note>
* You have a subnet behind your FortiGate firewall that will be accessible in
  the cloud. This subnet is defined as "172.16.0.0/20" in the examples below but
  it can be any valid CIDR range.
  <Note>
    In the examples below, this range is referred to as *Shared\_With\_AWS*.
  </Note>

### Configuring Named Address Ranges in FortiGate

Access the FortiGate Dashboard. Under *Policy & Objects* > *Addresses*, create
two new addresses: AWS\_Cloud and Shared\_With\_AWS.

#### AWS\_Cloud

| Field                      | Expected Value                                                                  |
| -------------------------- | ------------------------------------------------------------------------------- |
| Name                       | AWS\_Cloud                                                                      |
| Type                       | Subnet                                                                          |
| Subnet / IP Range          | CIDR matching the range specified in tunnel configuration (remote to FortiGate) |
| Interface                  | Any                                                                             |
| Show in Address List       | Enabled                                                                         |
| Static Route Configuration | Enabled                                                                         |

<img src="https://mintcdn.com/aviatrix-14b37c43/1zOMu4WXCFpEtXhJ/images/guides/connectivity/vpn/aws-cloud-config.png?fit=max&auto=format&n=1zOMu4WXCFpEtXhJ&q=85&s=6f5889247ea063fc3e711f49311b05ad" alt="AWS Cloud Configuration" width="1492" height="589" data-path="images/guides/connectivity/vpn/aws-cloud-config.png" />

#### Shared\_With\_AWS

| Field                      | Expected Value                                                                 |
| -------------------------- | ------------------------------------------------------------------------------ |
| Name                       | Shared\_With\_AWS                                                              |
| Type                       | Subnet                                                                         |
| Subnet / IP Range          | CIDR matching the range specified in tunnel configuration (local to FortiGate) |
| Interface                  | Any                                                                            |
| Show in Address List       | Enabled                                                                        |
| Static Route Configuration | Enabled                                                                        |

<img src="https://mintcdn.com/aviatrix-14b37c43/Gre8pdluiL7JmlpL/images/guides/connectivity/vpn/shared-with-aws-config.png?fit=max&auto=format&n=Gre8pdluiL7JmlpL&q=85&s=00e22cc477d2df3d4a1f6d86abf70c31" alt="Shared with AWS Configuration" width="1488" height="608" data-path="images/guides/connectivity/vpn/shared-with-aws-config.png" />

### Creating an IPsec Tunnel on FortiGate

1. Log in to the FortiGate and access the Dashboard.
2. In the VPN menu, select *IPsec Wizard*.
3. Change the Template Type to "Custom."
4. Enter any value as the Name. For this example, we are using "aviatrix-gatew."
5. Click *Next >*.
6. Fill out the Network fields as recommended below:

   | Field         | Expected Value               |
   | ------------- | ---------------------------- |
   | Name          | aviatrix-gatew (for example) |
   | Template Type | Custom                       |

<img src="https://mintcdn.com/aviatrix-14b37c43/1zOMu4WXCFpEtXhJ/images/guides/connectivity/vpn/fortigate5.png?fit=max&auto=format&n=1zOMu4WXCFpEtXhJ&q=85&s=312ea4ebb33b9f492d25065d7e7d518a" alt="FortiGate Configuration" width="1243" height="309" data-path="images/guides/connectivity/vpn/fortigate5.png" />

### New VPN Tunnel Tab

Complete the Network fields on the New VPN Tunnel tab as follows:

*Network section of New VPN Tunnel Tab*

| Field                    | Expected Value                        |
| ------------------------ | ------------------------------------- |
| IP Version               | IPv4                                  |
| Remote Gateway           | Static IP Address                     |
| IP Address               | Public IP address of Aviatrix Gateway |
| Interface                | Select the Appropriate Port/Interface |
| Local Gateway            | Disabled                              |
| Mode Config              | Unmark this checkbox                  |
| NAT Traversal            | Enable                                |
| Keepalive Frequency      | Any value                             |
| Dead Peer Detection      | On Demand                             |
| Forward Error Correction | Unmark this checkbox                  |
| Advanced Options         | Disabled                              |

<img src="https://mintcdn.com/aviatrix-14b37c43/1zOMu4WXCFpEtXhJ/images/guides/connectivity/vpn/fortigate6.png?fit=max&auto=format&n=1zOMu4WXCFpEtXhJ&q=85&s=dd2bbde1afe586bd54e2c9c1684f4816" alt="FortiGate Network Configuration" width="838" height="577" data-path="images/guides/connectivity/vpn/fortigate6.png" />

<a id="auth-vpn-psk" />

*Authentication section of New VPN Tunnel Tab*

| Field          | Expected Value                                                                                              |
| -------------- | ----------------------------------------------------------------------------------------------------------- |
| Method         | Pre-shared Key                                                                                              |
| Pre-shared Key | Enter the value from the downloaded configuration or the value typed in to the field in Aviatrix Site2Cloud |
| IKE Version    | 1                                                                                                           |
| IKE Mode       | Main (ID protection)                                                                                        |

<img src="https://mintcdn.com/aviatrix-14b37c43/1zOMu4WXCFpEtXhJ/images/guides/connectivity/vpn/authentication.png?fit=max&auto=format&n=1zOMu4WXCFpEtXhJ&q=85&s=83f5f309bf3545aa2394cb96e61ac5d2" alt="Authentication Configuration" width="636" height="197" data-path="images/guides/connectivity/vpn/authentication.png" />

*Phase 1 Proposal section of New VPN Tunnel Tab*

| Field                  | Expected Value                                                               |
| ---------------------- | ---------------------------------------------------------------------------- |
| Encryption             | Match value specified in Aviatrix S2C configuration (Phase 1 Encryption)     |
| Authentication         | Match value specified in Aviatrix S2C configuration (Phase 1 Authentication) |
| Diffie-Hellman Group   | Match value specified in Aviatrix S2C configuration (Phase 1 DH Groups)      |
| Key Lifetime (seconds) | 28800                                                                        |
| Local ID               | Leave Blank                                                                  |

<img src="https://mintcdn.com/aviatrix-14b37c43/Gre8pdluiL7JmlpL/images/guides/connectivity/vpn/phase1proposal.png?fit=max&auto=format&n=Gre8pdluiL7JmlpL&q=85&s=8421336736fc1270a30c4bea2e52500f" alt="Phase 1 Proposal" width="1238" height="410" data-path="images/guides/connectivity/vpn/phase1proposal.png" />

*XAUTH section of New VPN Tunnel Tab*

| Field | Expected Value |
| ----- | -------------- |
| Type  | Disabled       |

<img src="https://mintcdn.com/aviatrix-14b37c43/Y73dDPMr0NB7yfrH/images/guides/connectivity/vpn/xauth.png?fit=max&auto=format&n=Y73dDPMr0NB7yfrH&q=85&s=9034a4a0951cfad0b21015686bbdb805" alt="XAUTH Configuration" width="1230" height="124" data-path="images/guides/connectivity/vpn/xauth.png" />

*Phase 2 Selectors > New Phase 2 seciton of New VPN Tunnel Tab*

| Field          | Expected Value                      |
| -------------- | ----------------------------------- |
| Name           | Any String Value                    |
| Comments       | Any String Value                    |
| Local Address  | Named Address - *Shared\_With\_AWS* |
| Remote Address | Named Address - *AWS\_Cloud*        |

<img src="https://mintcdn.com/aviatrix-14b37c43/Gre8pdluiL7JmlpL/images/guides/connectivity/vpn/phase2selector.png?fit=max&auto=format&n=Gre8pdluiL7JmlpL&q=85&s=90bad2f576de5fae1fe85334de745262" alt="Phase 2 Selector" width="1242" height="568" data-path="images/guides/connectivity/vpn/phase2selector.png" />

*Advanced section of New VPN Tunnel Tab*

<Note>Obtain the values from the downloaded configuration file.</Note>

| Field                  | Expected Value                                                               |
| ---------------------- | ---------------------------------------------------------------------------- |
| Encryption             | Match value specified in Aviatrix S2C configuration (Phase 2 Encryption)     |
| Authentication         | Match value specified in Aviatrix S2C configuration (Phase 2 Authentication) |
| Diffie-Hellman Group   | Match value specified in Aviatrix S2C configuration (Phase 2 DH Groups)      |
| Key Lifetime (seconds) | 3600                                                                         |

<img src="https://mintcdn.com/aviatrix-14b37c43/Gre8pdluiL7JmlpL/images/guides/connectivity/vpn/phase2advanced.png?fit=max&auto=format&n=Gre8pdluiL7JmlpL&q=85&s=f08161839d399af0138748928b682bbc" alt="Phase 2 Advanced" width="1234" height="846" data-path="images/guides/connectivity/vpn/phase2advanced.png" />

7. Click *OK*.
8. Navigate to Network > Interfaces.
9. Click on the Tunnel created above (e.g. aviatrix-gatew) and assign the IP
   address from the downloaded configuration file.

   <img src="https://mintcdn.com/aviatrix-14b37c43/1zOMu4WXCFpEtXhJ/images/guides/connectivity/vpn/fortigate14.png?fit=max&auto=format&n=1zOMu4WXCFpEtXhJ&q=85&s=0661ab1c8b47b2cc1a9ac6b19e18a609" alt="FortiGate Interface Configuration" width="1249" height="618" data-path="images/guides/connectivity/vpn/fortigate14.png" />

### Configure IPv4 Policy

1. Go to Policy & Objects > IPv4 DoS Policy.
2. Create two new IPv4 policies:

* Outbound traffic from FortiGate (Shared\_With\_AWS) to Aviatrix (AWS\_Cloud)
  <img src="https://mintcdn.com/aviatrix-14b37c43/Gre8pdluiL7JmlpL/images/guides/connectivity/vpn/ip4outboundpolicy.png?fit=max&auto=format&n=Gre8pdluiL7JmlpL&q=85&s=bf9a8f00d724fb8b08219e0fac4c6e9e" alt="IPv4 Outbound Policy" width="1064" height="776" data-path="images/guides/connectivity/vpn/ip4outboundpolicy.png" />
* Inbound traffic from Aviatrix (AWS\_Cloud) to FortiGate (Shared\_With\_AWS)
  <img src="https://mintcdn.com/aviatrix-14b37c43/Gre8pdluiL7JmlpL/images/guides/connectivity/vpn/ip4inboundpolicy.png?fit=max&auto=format&n=Gre8pdluiL7JmlpL&q=85&s=0f8465e9b2a18c1c646ccd2aa34a905b" alt="IPv4 Inbound Policy" width="1014" height="646" data-path="images/guides/connectivity/vpn/ip4inboundpolicy.png" />

<Note>
  The reference to port2 in the screenshots should be replaced with your own
  interface name that represents the internal facing interface.
</Note>

<Note>
  Be sure to select *ACCEPT* for "action" and select *ALL* for "service."
</Note>

### Adding a Static Route

In the FortiGate UI, go to Network > Static Routes and add a new static route
for traffic destined to "AWS\_Cloud" to use the VPN tunnel.

<img src="https://mintcdn.com/aviatrix-14b37c43/Gre8pdluiL7JmlpL/images/guides/connectivity/vpn/static-route-fortigate.png?fit=max&auto=format&n=Gre8pdluiL7JmlpL&q=85&s=ac7ee1178f32effe18cde40d2a9be362" alt="Static Route Configuration" width="2084" height="808" data-path="images/guides/connectivity/vpn/static-route-fortigate.png" />

<Note>
  If Named Address is disabled, be sure that you enabled Static Route
  Configuration on the Address configuration.

  <img src="https://mintcdn.com/aviatrix-14b37c43/1zOMu4WXCFpEtXhJ/images/guides/connectivity/vpn/address-static-config.png?fit=max&auto=format&n=1zOMu4WXCFpEtXhJ&q=85&s=56851b63650d33421c7662a0dc1bd0bb" alt="Address Static Configuration" width="1494" height="591" data-path="images/guides/connectivity/vpn/address-static-config.png" />
</Note>

### IPsec Monitor

1. In the Fortigate UI, navigate to Dashboard > Network and click the IPsec
   widget.
2. Select the Aviatrix tunnel, and click *Bring Up*.
3. You can then check the tunnel status in CoPilot under Diagnostics > Cloud
   Routes.

## Troubleshoot

*Error Message*

`failed to get valid proposal`

`no suitable proposal found`

*Solution*

Check that the Phase 1 authentication, encryption, and Diffie-Hellman groups
match on both sides.

If you are experiencing low IPsec throughput, you may want to configure two
commands on the Fortigate.

```cli theme={null}
config system global
    set ipsec-asic-offload disable
end

configure system global
    set ipsec-hmac-offload disable
end
```

## Related Topics

* <a href={"/docs/enterprise/" + "10.1" + "/guides/connectivity/gateways/external-connection-settings"}>About External Connection Settings</a>
