Fortigate IKEv1 IPsec VPN CLI Templates

Fortigate IKEv1 IPsec VPN CLI Templates
IKEv1 (Internet Key Exchange version 1) is a widely used protocol for establishing IPsec VPN tunnels. This blog post provides a comprehensive guide to configuring IKEv1 VPN tunnels on FortiGate firewalls, including templates for various scenarios and security requirements.

To configure an IKEv1 VPN tunnel on a FortiGate firewall, you need the following information for the precheck list:

Phase 1 Configuration

  • Encryption: The encryption algorithm (e.g., AES-256, 3DES) to secure the IKE negotiation.
  • Authentication: The hash algorithm (e.g., SHA-256, SHA-1) for authentication.
  • Diffie-Hellman Group: The DH group (e.g., 14, 5) for key exchange.
  • Lifetime: The lifetime of the Phase 1 key in seconds or kilobytes.
  • Pre-Shared Key (PSK): The shared secret key for authentication.

Phase 2 Configuration

  • Encryption: The encryption algorithm (e.g., AES-256, 3DES) for data encryption.
  • Authentication: The hash algorithm (e.g., SHA-256, SHA-1) for data authentication.
  • PFS (Perfect Forward Secrecy): Enable or disable PFS for additional key exchange.
  • Lifetime: The lifetime of the Phase 2 key in seconds or kilobytes.
  • Encryption Domain: The local and remote subnets to be included in the VPN tunnel.

Route Based VS Policy Based VPN

  • A FortiGate firewall supports both policy-based and route-based IPsec VPN tunnels for IKEv1. Here are the key differences between the two approaches:

Policy-Based VPN

  • Uses security policies to define which traffic goes through the VPN tunnel
  • Requires creating a separate policy for each VPN tunnel, specifying the source, destination, service, and action as "IPSEC"
  • Needs a manual-key interface to be defined for each policy-based VPN
  • Does not use routing to determine which traffic goes into the tunnel
  • Cannot directly exchange dynamic routing information over the tunnel
  • Limited by the number of policies the FortiGate supports

Route-Based VPN

  • Uses static routes or dynamic routing protocols (BGP, OSPF etc.) to determine which traffic goes into the VPN tunnel
  • Creates a virtual IPsec interface for the VPN tunnel
  • Traffic matching the routes gets encrypted/decrypted by the virtual interface
  • Requires firewall policies allowing traffic to/from the virtual interface
  • Supports exchanging dynamic routing information through the tunnel interface
  • Limited by the number of virtual interfaces/routes the FortiGate supports

Other key differences:

  • Route-based VPNs support NAT for the virtual tunnel interface, policy-based VPNs cannot use NAT
  • Policy-based is easier to configure for simple point-to-point VPNs
  • Route-based is more scalable for complex topologies like hub-and-spoke
So in summary, policy-based uses separate security policies per tunnel, while route-based utilizes routing to direct traffic into the VPN tunnel interface. Route-based is generally recommended for greater flexibility and scalability

VPN Customer Template Request

Hello <customer>,

Please provide the necessary information below to complete this site-to-site VPN tunnel request:

Phase 1:
------------------
Encryption: (e.g., AES-256, AES-192, AES-128, 3DES)
Hash: (e.g., SHA-256, SHA-1, MD5)
Authentication: (Pre-Shared Key or RSA Signature)
Lifetime: (e.g., 28800 seconds, 86400 kilobytes)
DH Group: (e.g., 14, 5, 2, 1)

Phase 2:
------------------
Encryption: (e.g., AES-256, AES-192, AES-128, 3DES)
Hash: (e.g., SHA-256, SHA-1, MD5)
PFS: (Enable [DH Group 14, 5, 2] or Disable)
Lifetime: (e.g., 3600 seconds, 4608000 kilobytes)

Encryption Domain:
------------------
Local Networks: (e.g., 10.1.1.0/24, 192.168.1.0/24)
Remote Networks: (e.g., 10.2.2.0/24, 172.16.0.0/16)

Please provide the requested information, and I'll be happy to assist you further with configuring the IKEv1 VPN tunnel on your FortiGate firewall.

Route Based IKEv1 VPN Template using Static Routing

Possible encryption & Hash combinations: # des-md5, des-sha1, des-sha256, des-sha384, des-sha512, 3des-md5, 3des-sha1, 3des-sha256, 3des-sha384, 3des-sha512, aes128-md5, aes128-sha1, aes128-sha256, aes128-sha384, aes128-sha512, aes192-md5, aes192-sha1, aes192-sha256, aes192-sha384, aes192-sha512, aes256-md5, aes256-sha1, aes256-sha256, aes256-sha384, aes256-sha512, aria128-md5, aria128-sha1, aria128-sha256, aria128-sha384, aria128-sha512, aria192-md5, aria192-sha1, aria192-sha256, aria192-sha384, aria192-sha512, aria256-md5, aria256-sha1, aria256-sha256, aria256-sha384, aria256-sha512, seed-md5, seed-sha1, seed-sha256, seed-sha384, seed-sha512Configuration Template:config firewall address edit "local_net1" set subnet 10.1.1.0 255.255.255.0 next edit "local_net2" set subnet 10.1.2.0 255.255.255.0 next edit "remote_net1" set subnet 192.168.1.0 255.255.255.0 next edit "remote_net2" set subnet 192.168.2.0 255.255.255.0 nextendconfig firewall addrgrp edit "local_networks" set member "local_net1" "local_net2" next edit "remote_networks" set member "remote_net1" "remote_net2" nextendconfig vpn ipsec phase1-interface edit "ike_route_vpn" set interface "wan1" set dpd disable set nattraversal enable set keylife 28800 set proposal aes256-sha256 set remote-gw set psksecret nextendconfig vpn ipsec phase2-interface edit "ike_route_vpn" set phase1name "ike_route_vpn" set proposal aes256-sha256 set dhgrp 14 set pfs <[enabled/disabled]> set keylifeseconds 3600 set src-addr-type name set src-name "local_networks" set dst-addr-type name set dst-name "remote_networks" nextendconfig system interface edit "ike_route_vpn" set vdom "root" set ip 10.10.10.1 255.255.255.255 set remote-ip 10.10.10.2 255.255.255.255 set interface "wan1" nextendconfig router static edit 1 set device "ike_route_vpn" set dst nextendconfig firewall policy edit 1 set name "VPN-Traffic" set srcintf "lan" set dstintf "ike_route_vpn" set srcaddr "local_networks" set dstaddr "remote_networks" set action accept set schedule "always" set service "ALL" nextend

Route Based IKEv1 VPN Template using BGP Dynamic Routing

Possible encryption & Hash combinations: # des-md5, des-sha1, des-sha256, des-sha384, des-sha512, 3des-md5, 3des-sha1, 3des-sha256, 3des-sha384, 3des-sha512, aes128-md5, aes128-sha1, aes128-sha256, aes128-sha384, aes128-sha512, aes192-md5, aes192-sha1, aes192-sha256, aes192-sha384, aes192-sha512, aes256-md5, aes256-sha1, aes256-sha256, aes256-sha384, aes256-sha512, aria128-md5, aria128-sha1, aria128-sha256, aria128-sha384, aria128-sha512, aria192-md5, aria192-sha1, aria192-sha256, aria192-sha384, aria192-sha512, aria256-md5, aria256-sha1, aria256-sha256, aria256-sha384, aria256-sha512, seed-md5, seed-sha1, seed-sha256, seed-sha384, seed-sha512Configuration Template:config firewall address edit "local_net1" set subnet 10.1.1.0 255.255.255.0 next edit "local_net2" set subnet 10.1.2.0 255.255.255.0 next edit "remote_net1" set subnet 192.168.1.0 255.255.255.0 next edit "remote_net2" set subnet 192.168.2.0 255.255.255.0 nextendconfig firewall addrgrpedit "local_networks"set member "local_net1" "local_net2"nextedit "remote_networks"set member "remote_net1" "remote_net2"nextendconfig vpn ipsec phase1-interfaceedit "ike_route_vpn"set interface "wan1"set dpd disableset nattraversal enableset keylife 28800set proposal aes256-sha256set remote-gw set psksecret nextendconfig vpn ipsec phase2-interfaceedit "ike_route_vpn"set phase1name "ike_route_vpn"set proposal aes256-sha256set dhgrp 14set pfs <[enabled/disabled]>set keylifeseconds 3600set src-addr-type nameset src-name "local_networks"set dst-addr-type nameset dst-name "remote_networks"nextendconfig system interfaceedit "ike_route_vpn"set vdom "root"set ip 10.10.10.1 255.255.255.255set remote-ip 10.10.10.2 255.255.255.255set interface "wan1"nextendconfig router bgpset as set router-id config neighboredit set remote-as set interface "ike_route_vpn"nextendconfig firewall policyedit 1set name "VPN-Traffic"set srcintf "lan"set dstintf "ike_route_vpn"set srcaddr "local_networks"set dstaddr "remote_networks"set action acceptset schedule "always"set service "ALL"nextend

Policy Based IKEv1 VPN Template

Possible encryption & Hash combinations: # des-md5, des-sha1, des-sha256, des-sha384, des-sha512, 3des-md5, 3des-sha1, 3des-sha256, 3des-sha384, 3des-sha512, aes128-md5, aes128-sha1, aes128-sha256, aes128-sha384, aes128-sha512, aes192-md5, aes192-sha1, aes192-sha256, aes192-sha384, aes192-sha512, aes256-md5, aes256-sha1, aes256-sha256, aes256-sha384, aes256-sha512, aria128-md5, aria128-sha1, aria128-sha256, aria128-sha384, aria128-sha512, aria192-md5, aria192-sha1, aria192-sha256, aria192-sha384, aria192-sha512, aria256-md5, aria256-sha1, aria256-sha256, aria256-sha384, aria256-sha512, seed-md5, seed-sha1, seed-sha256, seed-sha384, seed-sha512Configuration Template:config firewall address edit "local_net1" set subnet 10.1.1.0 255.255.255.0 next edit "local_net2" set subnet 10.1.2.0 255.255.255.0 next edit "remote_net1" set subnet 192.168.1.0 255.255.255.0 next edit "remote_net2" set subnet 192.168.2.0 255.255.255.0 nextendconfig firewall addrgrp edit "local_networks" set member "local_net1" "local_net2" next edit "remote_networks" set member "remote_net1" "remote_net2" nextendconfig vpn ipsec phase1-interface edit "ike_policy_vpn" set interface "wan1" set dpd disable set nattraversal enable set keylife 28800 set proposal aes256-sha256 set remote-gw set psksecret nextendconfig vpn ipsec phase2-interface edit "ike_policy_vpn" set phase1name "ike_policy_vpn" set proposal aes256-sha256 set dhgrp 14 set pfs <[enabled/disabled]> set keylifeseconds 3600 set src-addr-type name set src-name "local_networks" set dst-addr-type name set dst-name "remote_networks" nextendconfig vpn ipsec manualkey-interface edit "ike_policy_vpn" set interface "wan1" set remote-gw set auth-alg set encr-alg set auto-negotiate enable nextendconfig vpn ipsec phase2 edit "ike_policy_vpn" set phase1name "ike_policy_vpn" set src-addr-type name set src-name "local_networks" set dst-addr-type name set dst-name "remote_networks" nextendconfig firewall policy edit 1 set name "Inbound-VPN-Traffic" set srcintf "wan1" set dstintf "lan" set srcaddr "remote_networks" set dstaddr "local_networks" set action ipsec set schedule "always" set service "ALL" set vpntunnel "vpn_tunnel_name" set inbound enable nextendconfig firewall policy edit 2 set name "Outbound-VPN-Traffic" set srcintf "lan" set dstintf "wan1" set srcaddr "local_networks" set dstaddr "remote_networks" set action ipsec set schedule "always" set service "ALL" set vpntunnel "vpn_tunnel_name" nextend

Read more