Skip to content

How to connect a FortiGate to a VPSnet private network over IPsec

For FortiGate (FortiOS) 8.0.2Steps: 12

To connect a FortiGate to a VPSnet private network, add the site in the VPSnet control panel, then create a custom route-based IPsec IKEv2 tunnel on the FortiGate with the values from the panel’s router recipe, add address objects, a static route and two firewall policies. This guide was tested on FortiOS 8.0.2 with a fixed public IPv4 address.

Before you start

  • In the VPSnet control panel open your VPN, choose Connect a site (router), pick FortiGate and click Next. Enter the site’s networks and your router’s public IPv4 address.
  • Copy the pre-shared key right away: it is shown once.
  • Keep the site’s Router recipe open, tab In the browser: it has your VPN address, tunnel addresses and networks filled in.

The pictures show example values from documentation ranges. Enter the values from your own router recipe.

1. Create the tunnel

FortiGate (FortiOS) 8.0.2: VPN > VPN Tunnels > Create new – Create the tunnel

VPN > VPN Tunnels > Create new

Click Create new and choose Custom IPsec tunnel: the tunnel form opens.

#FieldValue
1Custom IPsec tunnelchoose it

2. Tunnel: Network

FortiGate (FortiOS) 8.0.2: VPN > VPN Tunnels > Custom IPsec tunnel > Network – Tunnel: Network

VPN > VPN Tunnels > Custom IPsec tunnel > Network

The name is at most 15 characters: it is also the name of the tunnel interface. Device creation is under Advanced network settings.

#FieldValue
1Namethe tunnel name from the router recipe
2IP versionIPv4
3Remote gatewayStatic IP address
4IP addressthe VPN address from the router recipe
5Interfaceyour WAN interface
6Local gatewayOff
7Mode configOff
8NAT traversalEnable
9Keepalive frequency10
10Dead peer detectionOn Idle
11DPD retry count3
12DPD retry interval30 (or the value in the recipe)
13Device creationDisable

3. Tunnel: Authentication

FortiGate (FortiOS) 8.0.2: VPN > VPN Tunnels > Custom IPsec tunnel > Authentication – Tunnel: Authentication

VPN > VPN Tunnels > Custom IPsec tunnel > Authentication

Paste the pre-shared key from the panel and choose IKE version 2.

#FieldValue
1MethodPre-shared Key
2Pre-shared keythe pre-shared key (shown once)
3IKEVersion 2

4. Tunnel: Phase 1 proposal

FortiGate (FortiOS) 8.0.2: VPN > VPN Tunnels > Custom IPsec tunnel > Phase 1 proposal – Tunnel: Phase 1 proposal

VPN > VPN Tunnels > Custom IPsec tunnel > Phase 1 proposal

Keep one encryption row and remove the others with ×. Tick only the two Diffie-Hellman groups.

#FieldValue
1Encryption - authenticationAES256GCM - PRFSHA384
2Diffie-Hellman groups19, 20
3Key lifetime86400 (or the value in the recipe)
4Local IDyour public IPv4 address (needed when the FortiGate is behind NAT)

5. Phase 2 selector

FortiGate (FortiOS) 8.0.2: VPN > VPN Tunnels > Custom IPsec tunnel > Phase 2 selectors > Create new – Phase 2 selector

VPN > VPN Tunnels > Custom IPsec tunnel > Phase 2 selectors > Create new

The encryption and the rest are under Advanced. OK closes the selector; then click OK on the tunnel form as well.

#FieldValue
1Namethe tunnel name from the router recipe
2Local addressSubnet Address 0.0.0.0/0.0.0.0
3Remote addressSubnet Address 0.0.0.0/0.0.0.0
4Encryption - authenticationAES256GCM
5Replay detectionEnable
6Perfect forward secrecy (PFS)Enable
7Diffie-Hellman groups19, 20
8Local portAll
9Remote portAll
10ProtocolAll
11Auto-negotiateEnable
12Key lifetimeSeconds: 3600 (or the value in the recipe)

6. Address of the office network

FortiGate (FortiOS) 8.0.2: Policy & Objects > Addresses > Create new – Address of the office network

Policy & Objects > Addresses > Create new

One address object per office network: the recipe numbers them -office-1, -office-2 and so on.

#FieldValue
1Namethe tunnel name with -office-1
2TypeSubnet
3IP/Netmaskyour office network
4CommentsVPSnet VPN: office network

7. Address of the VPSnet network

FortiGate (FortiOS) 8.0.2: Policy & Objects > Addresses > Create new – Address of the VPSnet network

Policy & Objects > Addresses > Create new

One address object per VPSnet network in the recipe.

#FieldValue
1Namethe tunnel name with -vpsnet-1
2TypeSubnet
3IP/Netmaska VPSnet network from the recipe
4CommentsVPSnet VPN: network behind the VPSnet gateway

8. Address group of the office

FortiGate (FortiOS) 8.0.2: Policy & Objects > Addresses > Address Group > Create new – Address group of the office

Policy & Objects > Addresses > Address Group > Create new

Make one group of the office address objects: the policies in steps 11 and 12 use it.

FieldValue
Namethe tunnel name with -office
TypeGroup
Membersevery -office-N address

9. Address group of VPSnet

FortiGate (FortiOS) 8.0.2: Policy & Objects > Addresses > Address Group > Create new – Address group of VPSnet

Policy & Objects > Addresses > Address Group > Create new

Make one group of the VPSnet address objects.

FieldValue
Namethe tunnel name with -vpsnet
TypeGroup
Membersevery -vpsnet-N address

10. Route the VPSnet networks

FortiGate (FortiOS) 8.0.2: Network > Static Routes > Create new – Route the VPSnet networks

Network > Static Routes > Create new

One route per VPSnet network, through the tunnel interface. No gateway address is needed.

#FieldValue
1Destinationa VPSnet network from the recipe
2Interfacethe tunnel
3Administrative Distance10
4CommentsVPSnet VPN

11. Policy: office to VPSnet

FortiGate (FortiOS) 8.0.2: Policy & Objects > Firewall Policy > Create new – Policy: office to VPSnet

Policy & Objects > Firewall Policy > Create new

NAT stays off: the VPSnet servers see the office computers’ own addresses.

#FieldValue
1Namethe tunnel name with -out
2Schedulealways
3ActionACCEPT
4Incoming interfaceyour LAN interface
5Outgoing interfacethe tunnel
6Sourcethe office group
7Destinationthe VPSnet group
8ServiceALL
9NATOff
10Log allowed trafficAll sessions
11CommentsVPSnet VPN: office -> VPSnet

12. Policy: VPSnet to office

FortiGate (FortiOS) 8.0.2: Policy & Objects > Firewall Policy > Create new – Policy: VPSnet to office

Policy & Objects > Firewall Policy > Create new

The same policy in the other direction.

#FieldValue
1Namethe tunnel name with -in
2Schedulealways
3ActionACCEPT
4Incoming interfacethe tunnel
5Outgoing interfaceyour LAN interface
6Sourcethe VPSnet group
7Destinationthe office group
8ServiceALL
9NATOff
10Log allowed trafficAll sessions
11CommentsVPSnet VPN: VPSnet -> office

Check and troubleshoot

  • In the panel, open the site and click Test tunnel: it checks that the router answers, the keys match and traffic passes.
  • VPN > VPN Tunnels shows the tunnel as Up. If it stays down, select it and choose Bring up. On the command line, diagnose vpn ike gateway list name TUNNEL (TUNNEL = the tunnel name) shows the negotiation.
  • Up but no ping: check the static route to the tunnel, both policies and that NAT is off.

FAQ

Which FortiGate (FortiOS) versions does this guide cover?

It was set up and tested on FortiGate (FortiOS) 8.0.2 with a fixed public IPv4 address. Other versions may name or place some fields differently.

Can I use the command line instead?

Yes. The router recipe has a “Commands” tab with the same settings, ready to paste; choose your FortiOS version there.

Why is the tunnel name at most 15 characters?

FortiOS uses it as the name of the tunnel interface, and interface names are at most 15 characters.

My router’s public address changes. Can I still connect?

This guide covers a fixed address, the case we tested. Tick “The address changes” when you add the site: the router recipe then shows the settings for that case, with the identity to enter as Local ID; the FortiGate starts the tunnel itself.

I lost the pre-shared key. What now?

The key is shown once. In the panel, open the site and choose “Rotate key”: a new key is made and shown once, and the old one stops working the next time the router connects.

Do I need NAT for the tunnel?

No. The VPSnet servers see the office computers’ own addresses.