Troubleshooting IPsec Connections | pfSense Documentation (2024)

IPsec connection names

IPsec tunnels follow a consistent naming pattern when forming connection namesused in the strongSwan configuration. These names are printed in the IPsecstatus and can also be found in the IPsec configuration file(/var/etc/ipsec/swanctl.conf), the IPsec log, and the output of variousswanctl commands.

Non-mobile tunnels all use an IKE connection named conX where X is thephase 1 IKE ID.

Phase 2 child definitions use slightly different names based on the tunnelsettings:

For normal IKEv2 tunnels without Split Connections enabled all phase 2entries are combined into a single child definition. In this case theconnections are named conX where X is the phase 1 IKE ID and this isidentical to the name of the IKE portion of the connection.

For IKEv1 tunnels and for IKEv2 tunnels with Split Connections enabled eachphase 2 entry is defined as a separate child. In this case the child definitionsare named conX_Y where X is the phase 1 IKE ID and Y is the phase 2reqid.

Note

The phase 1 IKE ID and phase 2 reqid are printed in the IPsec tunnel list andon the page when editing those entries.

To see a list of current connections, run the following command from the shell:

# swanctl --list-conns

The output of that command lists the IKE connection name first (e.g. con1)with no indentation. Child definitions are listed at the end of a tunnel entryand are indented.

Manually connect IPsec from the shell

Connections can be manually initiated and terminated from the shell using theswanctl command.

Tip

When initiating a tunnel in this way, swanctl will output only therelevant logs to the terminal. This is much easier than attempting to followthe log file contents in other ways.

The connection name for a tunnel must be used in this case, such as con1 orcon2_1.

Note

To locate the correct con identifier, see IPsec connection names.

The following command will attempt to initiate the IKE portion of a tunnel(phase 1):

# swanctl --initiate --ike conX

The following command will attempt to initiate the child SA portion of a tunnel(phase 2) as well as IKE if it is not already connected:

# swanctl --initiate --child conX

Terminating a tunnel uses similar syntax.

Terminate IKE connection (also terminates all child connections):

# swanctl --terminate --ike conX

Terminate a child connection:

# swanctl --terminate --child conX

Tunnel does not establish

First check the service status at Status > Services. If the IPsec service isstopped, check if there is at least one configured and enabled IPsec tunnel(IPsec Tunnels Tab).

If the service is running, check the firewall logs at Status > System Logs,Firewall tab. Look for entries that indicate that the connection is beingblocked. If the tunnel is not establishing, check for UDP entries for ports500 and 4500. Rules are normally added automatically for IPsec(IPsec and firewall rules), but that feature can be disabled or theremay be edge cases where the firewall cannot identify the remote IPsec gateway.Add rules to pass traffic if needed.

The single most common cause of failed IPsec tunnel connections is aconfiguration mismatch. Often it is something small, such as a DH group setdifferently, or perhaps a subnet mask of /24 on one side and /32 on the other inthe phase 2 networks. Some routers (Linksys, for one) also like to hide certainoptions behind “Advanced” buttons or make assumptions. A lot of trial and errormay be involved, and a lot of log reading, but ensuring that both sides matchprecisely will help the most.

Depending on the Internet connections on either end of the tunnel, it is alsopossible that a router involved on one side or the other does not properlyhandle IPsec traffic. This is a larger concern with mobile clients and networkswhere NAT is involved outside of the actual IPsec endpoints. The problems aregenerally with the ESP protocol and problems with it being blocked or mishandledalong the way. NAT Traversal (NAT-T) encapsulates ESP in UDP port 4500traffic to work around these issues. Typically this situation is detectedautomatically but in some edge cases it can help to force NAT traversal forIKEv1 tunnels.

“Random” tunnel disconnects/DPD failures on low-end routers

If IPsec tunnels are dropped on low-end hardware that is pushing the limits ofits CPU, DPD on the tunnel may need disabled. Such failures tend to correlatewith times of high bandwidth usage. This happens when the CPU on a low-powersystem is tied up with sending IPsec traffic or is otherwise occupied. Due tothe CPU overload it may not take the time to respond to DPD requests or see aresponse to a request of its own. As a consequence, the tunnel will fail a DPDcheck and be disconnected. This is a clear sign that the hardware is beingdriven beyond its capacity. If this happens, consider replacing the firewallwith a more powerful model.

Tunnels establish and work but fail to renegotiate

In some cases a tunnel will function properly but once the phase 1 or phase 2lifetime expires the tunnel will fail to renegotiate properly. This can manifestit*elf in a few different ways, each with a different resolution.

DPD is unsupported and one side drops while the other remains

Consider this scenario, which DPD is designed to prevent, but can happen inplaces where DPD is unsupported:

  • A tunnel is established from Site A to Site B, from traffic initiated at SiteA.

  • Site B expires the phase 1 or phase 2 before Site A

  • Site A will believe the tunnel is up and continue to send traffic as thoughthe tunnel is working properly.

  • Only when the Site A phase 1 or phase 2 lifetime expires will it renegotiateas expected.

In this scenario, the likely things resolutions are:

  • Check to make sure all of the settings match on both sides, especially thephase 1 DH Group and phase 2 PFS values.

  • Enable DPD, or Site B must send traffic to Site A which will cause the entiretunnel to renegotiate. The easiest way to make this happen is to enable a keepalive mechanism on both sides of the tunnel.

  • Enable the periodic check keep alive method on one end(Configuring IPsec Keep Alive)

Tunnel establishes when initiating but not when responding

If a tunnel will establish sometimes, but not always, generally there is asettings mismatch. The tunnel may still establish because if the settingspresented by one side are more secure the other may accept them, but not theother way around.

Lifetime mismatches do not cause a failure in phase 1 or phase 2.

To track down these failures, configure the logs as shown inTroubleshooting IPsec Logs and attempt to initiate the tunnel from each side, thencheck the logs.

Tunnel establishes at start but not when disconnected

An IPsec tunnel can be disconnected for a variety of reasons. For example,connectivity being interrupted to the far side, the remote being down or offlinefor an extended time, or even a manual or policy action on the far side.

Note

This is not the same scenario as a rekey or reauthentication event, whichwill rebuild the appropriate parts of the tunnel and remain active.

A tunnel mode IPsec instance will connect at start and when it disconnects, willconnect again on demand. This happens due to trap policies which triggerinitiation when traffic attempts to use the tunnel. A tunnel mode IPsecconnection can be reconnected without manual intervention by the automatic pingkeep alive function on a phase 2 entry.

VTI mode IPsec cannot support trap policies so it is not capable of using thistactic. As such, a VTI tunnel may need help to stay up and running at all times.

There are a two workarounds that may help in this case:

Keep Alive - Periodic Check:

The IPsec phase 2 Keep Alive option toperform a periodic IPsec status check is ideally suited to this case. Whenenabled, if a given phase 2 is down it will trigger an initiation directly.

This works with VTI because it does not rely on trap policies.

Note

This feature is new in pfSense® Plus software version 22.01 and CE 2.6.0.

Child SA Actions:

Another tactic to keep a tunnel up is to set it to initiate immediately atstart and automatically reconnect if it gets disconnected. This should only beset on one side of a tunnel.

Child SA Start Action:

Set the start action to Initiate at start. This will trigger a tunnelinitiation when the IPsec daemon starts, such as at boot time.

Note

This does not trigger when the IPsec configuration is changed andreloaded, only when the daemon loads the configuration the first time atstartup.

Child SA Close Action:

Set the close action to Restart/Reconnect which will attempt toimmediately reconnect the child SA if it gets disconnected.

Depending on the reason the tunnel was disconnected, this may or may not behelpful. For example, if the reason the tunnel disconnected was a local cause,these events may not trigger. The periodic check keep alive method is muchmore reliable, but only available on current versions of pfSense software.

Tunnel stops attempting connections after timeout

If the remote end of an IPsec tunnel is down when the tunnel attempts toinitiate at start, but fails, it may eventually times out and stop trying toconnect.

The solution here is similar to the previous scenario above, which is to enablekeep alive options for the tunnel which will trigger a fresh initiationperiodically if the tunnel is down.

Troubleshooting IPsec Connections | pfSense Documentation (2024)

FAQs

How do I troubleshoot IPsec? ›

Let's begin by verifying basic connectivity and systematically move towards more complex aspects of the VPN configuration and operation.
  1. Verify Basic Connectivity.
  2. Review Configuration.
  3. Examine Logs and Debug Output.
  4. Use Diagnostic Commands.
  5. Check for Common Issues.
  6. Test Phase-by-Phase.
  7. Review Software and Firmware Versions.
Jun 27, 2024

How to test an IPsec connection? ›

The easiest test for an IPsec tunnel is a ping from one client station behind the firewall to another on the opposite side. If that works, the tunnel is up and working properly.

How to check IPsec traffic? ›

To just check if traffic is going through the VPN I just use the "show crypto ipsec sa". Then you will be able to see if traffic is being encrypted and decrypted.

How to check if IPsec is enabled? ›

To view status information about active IPsec tunnels, use the show ipsec tunnel command. This command prints status output for all IPsec tunnels, and it also supports printing tunnel information individually by providing the tunnel ID.

What are the challenges of IPSec? ›

While IPSec provides robust security for IP communications, its major drawback lies in its complexity and the administrative burden it places on network administrators.

What is IPSec concerned with? ›

IPSec is a set of communication rules or protocols for setting up secure connections over a network. Internet Protocol (IP) is the common standard that determines how data travels over the internet. IPSec adds encryption and authentication to make the protocol more secure.

How do I refresh my IPSec tunnel? ›

  1. Select. Network. IPSec Tunnels. and select the tunnel you want to refresh or restart.
  2. In the row for that tunnel, under the Status column, click. Tunnel Info. .
  3. At the bottom of the Tunnel Info screen, click the action you want: Refresh. —Updates the onscreen statistics. Restart.

How do I test my VPN connection? ›

Open your VPN client and connect to a VPN server. Once connected to the VPN server, revisit the same IP address checking website. If your IP address is different, then the VPN is working. Otherwise, your VPN has issues if your IP address remains the same as the original.

How to check IPSec tunnel up time? ›

Technical Tip: How to identify the uptime of an IPsec tunnel

FortiGate. Navigate to Dashboard -> Network -> IPsec widget -> Right-click on the available columns and add the 'created' field as shown in the above screenshot. diag vpn ike gateway list <- For all tunnels.

Is IPSec traffic TCP or UDP? ›

Transmission: Encrypted IPsec packets travel across one or more networks to their destination using a transport protocol. At this stage, IPsec traffic differs from regular IP traffic in that it most often uses UDP as its transport protocol, rather than TCP.

How do I view IPSec logs? ›

Log on to the VPN Gateway console. In the left-side navigation pane, choose Interconnections > VPN > IPsec Connections. In the top navigation bar, select the region of the IPsec-VPN connection. icon in the Actions column, and then select View Logs.

How do I check my IPSec Phase 1 status? ›

Answer: Use the command `show crypto isakmp sa` for Phase 1 and `show crypto ipsec sa` for Phase 2 to check the status of the tunnel's phases on a Cisco device. Checking the status of an IPSec VPN tunnel involves two phases, Phase 1 (IKE or ISAKMP) and Phase 2 (IPSec).

How to troubleshoot IPSec? ›

Troubleshoot IPsec/VPN/Firewall Connections Last Updated May 2, 2023
  1. Verify that the IPsec tunnel is established.
  2. Verify that the peer IP address for your tunnel is correct.
  3. Verify that peer IP address is reachable from the router.
  4. Verify that the Preshare Key (PSK) is correct.
  5. Dead Peer Connections must be enabled.
May 2, 2023

How do I connect to IPSec? ›

How to Set Up an IPsec VPN Client
  1. Right-click on the wireless/network icon in your system tray.
  2. Select Open Network and Sharing Center. ...
  3. Click Set up a new connection or network.
  4. Select Connect to a workplace and click Next.
  5. Click Use my Internet connection (VPN).
  6. Enter Your VPN Server IP in the Internet address field.
Aug 26, 2021

How do I allow IPSec through my firewall? ›

To set up an IPSec session, the firewall needs to allow UDP protocol on specifically defined IANA port 500 for IKE (Internet Key exchange) and port 4500 for encrypted packets. ESP and AH are also protocols that are designated with IANA standardized numbers 50 and 51, respectively.

How do I reset my IPsec? ›

In the portal, go to the virtual network gateway that you want to reset. On the Virtual network gateway page, in the left pane, scroll and locate Help -> Reset. On the Reset page, select Reset. After the command is issued, the current active instance of Azure VPN gateway is rebooted immediately.

How do I keep my IPsec tunnel alive? ›

There are two methods which can make the firewall attempt to keep a non-mobile IPsec tunnel up and active at all times: automatic ping and periodic check. These options are available in the settings for each IPsec phase 2 entry. See Keep Alive for additional details on these settings.

How to troubleshoot a tunnel? ›

Troubleshoot IPsec/VPN/Firewall Connections Last Updated May 2, 2023
  1. Verify that the IPsec tunnel is established.
  2. Verify that the peer IP address for your tunnel is correct.
  3. Verify that peer IP address is reachable from the router.
  4. Verify that the Preshare Key (PSK) is correct.
  5. Dead Peer Connections must be enabled.
May 2, 2023

What to do if a VPN tunnel is down? ›

Make sure all machines participating in the tunnel (including the SmartCenter server) have the same time, and correct time zones configured. If possible, disable Office Mode and try IP Pool NAT instead. If you are using Office Mode or IP Pool NAT, verify routing from the LAN to Office Mode addresses.

Top Articles
What to do if you click on a phishing link - Hayes Connor
The 3 Essentials Customers Want Most | Entrepreneur
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Selly Medaline
Latest Posts
Article information

Author: Twana Towne Ret

Last Updated:

Views: 5639

Rating: 4.3 / 5 (64 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Twana Towne Ret

Birthday: 1994-03-19

Address: Apt. 990 97439 Corwin Motorway, Port Eliseoburgh, NM 99144-2618

Phone: +5958753152963

Job: National Specialist

Hobby: Kayaking, Photography, Skydiving, Embroidery, Leather crafting, Orienteering, Cooking

Introduction: My name is Twana Towne Ret, I am a famous, talented, joyous, perfect, powerful, inquisitive, lovely person who loves writing and wants to share my knowledge and understanding with you.