Changes

Created page with " <p style="color:red">The information in this page is updated in accordance with [https://wiki.teltonika-networks.com/view/FW_%26_SDK_Downloads'''00.07.07.2'''] firmware versi..."
<p style="color:red">The information in this page is updated in accordance with [https://wiki.teltonika-networks.com/view/FW_%26_SDK_Downloads'''00.07.07.2'''] firmware version.</p>
<p style="color:red">The information in this page is updated in accordance with '''Fortigate v7.4.3''' firmware version.</p>
==Introduction==
Normally we configure IPsec for LAN-to-LAN communication, also known as split-tunnel VPN, when only specific hosts or subnets should be reachable via a VPN tunnel. However, we may also take a different approach and configure a VPN tunnel using the full tunnel method. This means that any non-directly connected network (i.e. lan interface) will be reachable only via IPsec tunnel and not via the typical default route.

==Configuration overview and prerequisites==
Before we begin, let's look at the configuration we are attempting to achieve and the prerequisites that make it possible.

'''Prerequisites:'''

* One RUT/RUTX series router or TRB gateway with RUTOS firmware;
* One Fortigate series router;
* An end device (PC, Laptop) for configuration;

If you're having trouble finding this page or some of the parameters described here on your device's WebUI, you should turn on '''"Advanced WebUI" mode.''' You can do that by clicking the "Advanced" button, located at the top of the WebUI.
[[File:Networking_rutos_manual_webui_basic_advanced_mode_75.gif|border|center|class=tlt-border|1102x93px]]

==Site to site configuration RUT public IP==
----
This section provides a guide on how to configure a successful site to site IPsec vpn connection between '''RUT''' and '''Fortigate''' devices.
===Topology===
----
'''RUT''' – '''RUT''' will act as a '''hub'''. A hub is a server (IPsec responder), to which our spoke will be connected. It will be our remote endpoint for the spoke device. RUT has a LAN subnet of 192.168.1.0/24 and a WAN with Public IP, which should be reachable by the spoke.

'''Fortigate''' – '''Fortigate''' will act as a '''spoke'''. A spoke is a client (IPsec initiator), that will be connected to the hub. It will be connected to a '''hub''' to be able to reach RUT LAN subnet. Fortinet has a LAN subnet of 192.168.5.0/24 and a WAN with private IP.

[[File:Fortinet_RUT_IPsec_site_to_site_rut_public.png|border|class=tlt-border|1102x400px|center]]
===Fortigate configuration===
----
Start by configuring the '''Fortigate''' device. Login to the WebUI, navigate to '''1. VPN → 2. IPsec Tunnels → 3. Create new → 4. IPsec Tunnel → 5. Your desired name → 6. Template type: Custom → 7. Click on the button next'''.
----
<table class="nd-othertables_2">
<tr>
<th width=800; style="border-bottom: 1px solid white;" rowspan=2>[[File:Fortinet_Firewall_create_new.png|border|class=tlt-border|497x209px|left]]</th>
</tr>
<tr>
<th width=800; style="border-bottom: 1px solid white;" rowspan=1>[[File:Fortinet_Firewall_type_next_v2.png|border|class=tlt-border|437x209px|right]]</th>
</tr>
</table>
'''Note:''' ''Not specified fields can be left as is or changed according to your needs.''
====Network configuration====
----
Configure everything as follows.

Make the following changes:
# Remote Gateway – '''''Static IP Address;'''''
# IP Address – '''''RUT public IP;'''''
#Interface – '''''wan1;'''''
[[File:Fortinet_IPsec_network_public_ip.png|border|class=tlt-border|center]]
====Authentication configuration====
----
Make the following changes:
# Method – '''''Pre-shared Key;'''''
# Pre-shared Key – '''''your desired password;'''''
# Version – '''''2;'''''
[[File:Fortigate_IPsec_Authentication_Configuration.png|border|class=tlt-border|center]]
====Phase 1 Proposal configuration====
----
'''Note:''' ''This is only an example of a secure configuration. Other algorithms or even combinations of them could be used. However, we strongly recommend refraining from using older encryption and hashing algorithms unless support for certain legacy systems is required.''

Make the following changes:
# Encryption – '''''AES256;'''''
# Authentication - '''''SHA512;'''''
# Diffie-Hellman Group – '''''16;'''''
# Key Lifetime (seconds) – '''''86400;'''''
[[File:Fortigate_IPsec_Phase1_Proposal_Configuration.png|border|class=tlt-border|center]]
====Phase 2 Selectors configuration====
----
'''Note:''' ''This is only an example of a secure configuration. Other algorithms or even combinations of them could be used. However, we strongly recommend refraining from using older encryption and hashing algorithms unless support for certain legacy systems is required.''

Make the following changes:

'''''Click on Advanced settings;'''''
# Encryption – '''''AES256;'''''
# Authentication - '''''SHA512;'''''
# Diffie-Hellman Group – '''''16;'''''
# Key Lifetime – '''''Seconds;'''''
# Seconds – '''''86400;'''''
[[File:Fortigate_IPsec_Phase2_Proposal_Configuration.png|border|class=tlt-border|center]]

====Firewall configuration====
After setting up our IPsec instance, we will need to configure our firewall accordingly. Navigate to '''Policy & Objects → Firewall Policy → and click on a Create new button.'''. Configure everything as follows.
----
In this example, we are allowing all types of traffic through the tunnel, but you can restrict certain traffic by specifying the services that are allowed via the tunnel.

Make the following changes:
# Incoming interface - '''''lan;'''''
# Outgoing interface - '''''IPsec tunnel interface name (In this case it is Teltonika);'''''
# Source - '''''192.168.5.0/255.255.255.0;'''''
# Destination - '''192.168.1.0/255.255.255.0;'''
# Service - '''ALL;'''
# '''NAT disabled;'''
[[File:Fortinet_IPsec_Firewall_Forti_to_RUT_v2.png|border|class=tlt-border|center]]
----
Then create a second firewall rule.

Make the following changes:
# Incoming interface - '''''IPsec tunnel interface name (In this case it is Teltonika);'''''
# Outgoing interface - '''''lan;'''''
# Source - '''''192.168.1.0/255.255.255.0;'''''
# Destination - '''192.168.5.0/255.255.255.0;'''
# Service - '''ALL;'''
# '''NAT disabled;'''
[[File:Fortinet_IPsec_Firewall_RUT_to_Forti_v2.png|border|class=tlt-border|center]]
----
Our firewall should look like this:
[[File:Fortinet_Firewall_ipsec_configuration_overall_v2.png|border|class=tlt-border|center]]
====Static Routes configuration====
After setting up our IPsec instance and firewall, we will need to configure our static route accordingly. Navigate to '''Network → Static routes → and click on a Create new button.'''. For that we will need to create two static routes, one for blackhole and one for accessing our RUT device, configure everything as follows.
----
Make the following changes:
<table class="nd-othertables_2">
<tr>
<th width=330; style="border-bottom: 1px solid white;></th>
<th width=700; style="border-bottom: 1px solid white;" rowspan=2>[[File:Fortinet_IPsec_Add_route_tunnel.png|border|class=tlt-border|center]]</th>
</tr>
<tr>
<td style="border-bottom: 4px solid white>
# Destination - '''''192.168.1.0/255.255.255.0;'''''
# Interface - '''''Tunnel interface name (In this case it is Teltonika);'''''
</td>
</tr>
</table>
----
Then create a new static route for blackhole.

Make the following changes:
<table class="nd-othertables_2">
<tr>
<th width=330; style="border-bottom: 1px solid white;></th>
<th width=800; style="border-bottom: 1px solid white;" rowspan=2>[[File:Fortinet_IPsec_Add_route_to_blackhole.png|border|class=tlt-border|center]]</th>
</tr>
<tr>
<td style="border-bottom: 4px solid white>
# Destination - '''''192.168.1.0/255.255.255.0;'''''
# Interface - '''''Blackhole;'''''
# Administrative distance - '''''254;'''''
</td>
</tr>
</table>
===RUT configuration===
Start by configuring the '''RUT''' device. Login to the WebUI, navigate to '''Services → VPN → IPsec and add a new IPsec instance.''' Configure everything as follows.
'''Note:''' ''Not specified fields can be left as is or changed according to your needs.''
====Instance configuration====
----
Make the following changes:

# '''''Enable''''' instance;
# Authentication method - '''''Pre-shared key;'''''
# Pre-shared key - the '''''same password''''' you have '''''set on Fortigate''''' when configuring the '''''Fortigate IPsec instance;'''''
# Local identifier – '''''RUT LAN IP;'''''
# Remote identifier – '''''%any;'''''
[[File:Rut_IPsec_configuration_instance_site_to_site.png|border|class=tlt-border|center]]
====Connection general section configuration====
----
Make the following changes:

# Mode - '''''Start;'''''
# Type - '''''Tunnel;'''''
# Local subnet – '''''192.168.1.0/24;'''''
# Remote subnet – '''''192.168.5.0/24;'''''
# Key exchange - '''''IKEv2;'''''

[[File:Rut_IPsec_configuration_connection_general_site_to_site.png|border|class=tlt-border|686x482px|center]]
====Proposal configuration====
----
'''Note:''' ''This is only an example of a secure configuration. Other algorithms or even combinations of them could be used. However, we strongly recommend refraining from using older encryption and hashing algorithms unless support for certain legacy systems is required.''

Make the following changes:
<table class="nd-othertables_2">
<tr>
<th width=330; style="border-bottom: 1px solid white;></th>
<th width=700; style="border-bottom: 1px solid white;" rowspan=2>[[File:Networking_webui_manual_IPsec_configuration_proposal_phase1_settings_v1.png|border|class=tlt-border|671x336px|center]]</th>
</tr>
<tr>
<td style="border-bottom: 4px solid white>
# Encryption - '''''AES256;'''''
# Authentication - '''''SHA512;'''''
# DH group - '''''MODP4096;'''''
# IKE lifetime - '''86400s'''.
</td>
</tr>
</table>

----
<table class="nd-othertables_2">
<tr>
<th width=330; style="border-bottom: 1px solid white;></th>
<th width=700; style="border-bottom: 1px solid white;" rowspan=2>[[File:Networking_webui_manual_IPsec_configuration_proposal_phase2_settings_v1.png|border|class=tlt-border|644x331px|center]]</th>
</tr>
<tr>
<td style="border-bottom: 4px solid white>
# Encryption - '''''AES256;'''''
# Authentication - '''''SHA512;'''''
# PFS group - '''''MODP4096;'''''
# Lifetime – '''''86400s;'''''
</td>
</tr>
</table>
==Site to site configuration with multiple LANs==
----
This section provides a guide on how to configure a successful site to site IPsec vpn connection between '''RUT''' and '''Fortigate''' devices with multiple LANs.
===Topology===
----
'''RUT''' – '''RUT''' will act as a '''hub'''. A hub is a server (IPsec responder), to which our spoke will be connected. It will be our remote endpoint for the spoke device. RUT has a LAN1 subnet of 192.168.1.0/24, LAN2 subnet of 192.168.2.0/24 and a WAN with Public IP, which should be reachable by the spoke.

'''Fortigate''' – '''Fortigate''' will act as a '''spoke'''. A spoke is a client (IPsec initiator), that will be connected to the hub. It will be connected to a '''hub''' to be able to reach RUT LAN1 and LAN2 subnet. Fortigate has a LAN1 subnet of 192.168.5.0/24, LAN2 subnet of 192.168.4.0/24 a WAN with private IP.

[[File:Fortinet_RUT_IPsec_site_to_site_rut_public_multiple_lan.png|border|class=tlt-border|1102x400px|center]]

===Fortigate configuration===
----
As for the configuration of IPsec tunnel, everything is the same, only the Phase 2 Selectors, Firewall and static route sections will be configured additionally, so for other sections refer to the guide site to site.

====Phase 2 Selectors configuration====
----
<table class="nd-othertables_2">
<tr>
<th width=330; style="border-bottom: 1px solid white;></th>
<th width=800; style="border-bottom: 1px solid white;" rowspan=2>
[[File:Fortinet_IPsec_Phase2_Selectors_Multiple_lan.png|border|class=tlt-border|center]]</th>
</tr>
<tr>
<td style="border-bottom: 4px solid white>
Make the following changes:
'''Steps 7 8 9 10 are the same for all selectors.'''
# Phase 2 interface - '''''Fortigate LAN1 to RUT LAN2;'''''
# Phase 2 interface - '''''Fortigate LAN2 to RUT LAN1;'''''
# Phase 2 interface - '''''Fortigate LAN2 to RUT LAN2;'''''
# Phase 2 interface – '''''Fortigate LAN1 to RUT LAN1;'''''
# Local address - '''''Write accordingly with the Fortigate LAN;'''''
# Remote address - '''''Write accordingly with the RUT LAN;'''''
# Encryption – '''''AES256;'''''
# Authentication - '''''SHA512;'''''
# Diffie-Hellman Group – '''''16;'''''
# Seconds – '''''86400;'''''
</td>
</tr>
</table>
----
====Static route configuration====
After setting up our IPsec instance and firewall, we will need to configure our static route accordingly. Navigate to '''Network → Static routes → and click on a Create new button.''' For that we will need to create four static route interfaces, two for blackholes and two for accessing our RUT device LAN1/LAN2, configure everything the same as for site to site, just add the LAN2. It should look like this:
[[File:Fortinet_static_route_general.png|border|class=tlt-border|center]]
----
===RUT configuration===
Then configure the '''RUT''' device. Login to the WebUI, navigate to '''Services → VPN → IPsec and add a new IPsec instance.''' Configure everything the same like site to site configuration, only change the '''Connection general section''' accordingly.
====Connection general section configuration====
----
<table class="nd-othertables_2">
<tr>
<th width=330; style="border-bottom: 1px solid white;></th>
<th width=700; style="border-bottom: 1px solid white;" rowspan=2>[[File:Rut_IPsec_configuration_connection_general_site_to_site_multiple_lan.png|border|class=tlt-border|center]]</th>
</tr>
<tr>
<td style="border-bottom: 4px solid white>
Make the following changes:
# Local subnet – '''''192.168.1.0/24;'''''
# '''''Click + button to add another Local subnet;'''''
# Local subnet - '''''192.168.2.0/24;'''''
# Remote subnet – '''''192.168.5.0/24;'''''
# '''''Click + button to add another Remote subnet;'''''
# Remote subnet – '''''192.168.4.0/24;'''''
# Key exchange - '''''IKEv2;'''''
</td>
</tr>
</table>
----
==Site to site configuration Fortigate public IP==
----
This section provides a guide on how to configure a successful site to site IPsec vpn connection between '''RUT''' and '''Fortigate''' when '''Fortigate''' has a public IP and RUT is behind NAT. This setup will be similiar to Site to site configuration RUT public IP, we will need only to change network section on Fortinet and on RUT we will need to add Remote endpoint.
===Topology===
----
Fortigate – Fortigate will act as a hub. A hub is a server (IPsec responder), to which our spoke will be connected. It will be our remote endpoint for the spoke device. Fortinet has a LAN subnet of 192.168.5.0/24 and a WAN with Public IP, which should be reachable by the spoke.

RUT – RUT will act as a spoke. A spoke is a client (IPsec initiator), that will be connected to the hub. It will be connected to a hub to be able to reach Fortigate LAN subnet. RUT has a LAN subnet of 192.168.1.0/24 and a WAN with private IP.
[[File:Fortinet_RUT_IPsec_site_to_site_fortinet_public.png|border|class=tlt-border|1102x400px|center]]
===Fortigate configuration===
----
As for the configuration of IPsec tunnel, everything is the same, only the Network and authentication sections needs to be changed, so for other sections refer to the guide site to site.
Start by configuring the '''Fortigate''' device. Login to the WebUI, navigate to '''1. VPN → 2. IPsec Tunnels → 3. Create new → 4. IPsec Tunnel → 5. Your desired name → 6. Template type: Custom → 7. Click on the button next'''.
----
<table class="nd-othertables_2">
<tr>
<th width=800; style="border-bottom: 1px solid white;" rowspan=2>[[File:Fortinet_Firewall_create_new.png|border|class=tlt-border|497x209px|left]]</th>
</tr>
<tr>
<th width=800; style="border-bottom: 1px solid white;" rowspan=1>[[File:Fortinet_Firewall_type_next_v2.png|border|class=tlt-border|437x209px|right]]</th>
</tr>
</table>
'''Note:''' ''Not specified fields can be left as is or changed according to your needs.''
====Network configuration====
----
Make the following changes:
# Remote Gateway – '''''Dialup User;'''''
# Interface – '''''wan1;'''''
[[File:Fortinet_IPsec_network_public_rut_private.png|border|class=tlt-border|center]]
====Authentication configuration====
----
Make the following changes:
# Method – '''''Pre-shared Key;'''''
# Pre-shared Key – '''''your desired password;'''''
# Version – '''''2;'''''
# Accept Types - '''''Any peer ID;'''''

[[File:Fortinet_IPsec_authentication_public_rut_private.png|border|class=tlt-border|center]]
----
===RUT configuration===
Start by configuring the '''RUT''' device. Login to the WebUI, navigate to '''Services → VPN → IPsec and add a new IPsec instance.''' Configure everything as follows. For other sections refer to the '''"Site to site configuration RUT public IP"'''
'''Note:''' ''Not specified fields can be left as is or changed according to your needs.''
====Instance configuration====
----
Make the following changes:
# '''''Enable''''' instance;
# Remote endpoint - '''''Public IP of Fortigate device'''''
# Authentication method - '''''Pre-shared key;'''''
# Pre-shared key - the '''''same password''''' you have '''''set on Fortigate''''' when configuring the '''''Fortigate IPsec instance;'''''
# Local identifier – '''''RUT LAN IP;'''''
# Remote identifier – '''''%any;'''''
[[File:Rut_IPsec_configuration_instance_site_to_site_private_ip.png|border|class=tlt-border|center]]
==Testing the configuration==
----
If you have followed all the above steps, your configuration should be finished. But as with any other configuration, it is always wise to test the setup in order to make sure that it works properly.

Using the <code><span class="highlight">'''ipsec status'''</span></code> or we can use <code><span class="highlight">'''ipsec statusall'''</span></code> command for a more verbose output. With these commands we can see that the IPsec tunnel is successfully established on RUT router. The command output on a '''RUT''' device:

[[File:Networking_ssh_manual_IPsec_configuration_IPsec_statusall_test_v1.png|border|class=tlt-border|971x135px|center]]
----
Also, we should be able to ping '''Fortigate''' device, we can check it out by executing this command via command line on RUT device: <code><span class="highlight" >'''ping 192.168.5.99'''</span></code>:
[[File:Networking_ssh_manual_IPsec_configuration_test_ping_v1.png|border|class=tlt-border|506x133px|center]]
----
To check if IPsec tunnel is working properly from '''Fortinet''', we can try pinging our '''RUT''' device by using this command in command line interface on Fortigate<code><span class="highlight" >'''exec ping 192.168.1.1'''</span></code>, if you are not able to ping '''RUT''' device, try changing the source interface from which we try pinging, by executing this command <code><span class="highlight" >'''exec ping-options source 192.168.5.99'''</span></code>:
[[File:Fortinet_IPsec_test_ping.png|border|class=tlt-border|center]]
----
We can also check if IPsec tunnel is working properly from '''Fortigate''' WebUI, navigate to '''VPN → IPSec Tunnels''' and there you will see if the tunnel is working:
[[File:Fortinet_IPsec_WebUI_tunnel_status.png|border|class=tlt-border|center]]
==See also==
----
[https://wiki.teltonika-networks.com/view/RUTX12_VPN#IPsec IPsec on Teltonika Networks devices]

==External links==
----
[https://openwrt.org/docs/guide-user/services/vpn/strongswan/basics OpenWrt Ipsec basics]

[https://docs.fortinet.com/document/fortigate/7.4.2/administration-guide/762500/general-ipsec-vpn-configuration Fortigate Ipsec configuration]

Navigation menu