IPSec setup blues

I cannot make IPSec to work. I started with this:
www.ipfire.org - Host-to-Net Connections (Roadwarrior)

I wanted to try first with the PSK, figuring it it’s easier.
Well, I am stumped by the local ID and remote ID fields. If I leave them empty, or I put in something there, there is no connection.
On the explanations it says: “See requirement for client”. I am trying this with Android first.

The network field I populated it with 0.0.0.0/0.
This is the log:

12:16:04	charon:	10[NET] received packet: from 172.58.240.224[41861] to 108.26.xxx.xxx1[500] (652 bytes)
12:16:04	charon:	10[ENC] parsed IKE_SA_INIT request 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) N(HASH_ALG) N(REDIR_SUP) ]
12:16:04	charon:	10[IKE] 172.58.240.224 is initiating an IKE_SA
12:16:04	charon:	10[IKE] 172.58.240.224 is initiating an IKE_SA
12:16:04	charon:	10[CFG] selected proposal: IKE:AES_GCM_16_256/PRF_HMAC_SHA2_512/ECP_384
12:16:04	charon:	10[IKE] remote host is behind NAT
12:16:04	charon:	10[IKE] DH group MODP_2048_256 unacceptable, requesting ECP_384
12:16:04	charon:	10[ENC] generating IKE_SA_INIT response 0 [ N(INVAL_KE) ]
12:16:04	charon:	10[NET] sending packet: from 108.26.126.121[500] to 172.58.240.224[41861] (38 bytes)
12:16:04	charon:	15[NET] received packet: from 172.58.240.224[41861] to 108.26.126.121[500] (492 bytes)
12:16:04	charon:	15[ENC] parsed IKE_SA_INIT request 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) N(HASH_ALG) N(REDIR_SUP) ]
12:16:04	charon:	15[IKE] 172.58.240.224 is initiating an IKE_SA
12:16:04	charon:	15[IKE] 172.58.240.224 is initiating an IKE_SA
12:16:04	charon:	15[CFG] selected proposal: IKE:AES_GCM_16_256/PRF_HMAC_SHA2_512/ECP_384
12:16:04	charon:	15[IKE] remote host is behind NAT
12:16:04	charon:	15[IKE] sending cert request for "C=US, ST=VA, L=xxxxxxxxx, O=xxxxx, CN=xxx CA, E=xxxx@xxxx.com"
12:16:04	charon:	15[ENC] generating IKE_SA_INIT response 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) CERTREQ N(HASH_ALG) N(CHDLESS_SUP) N(MULT_AUTH) ]
12:16:04	charon:	15[NET] sending packet: from 108.26.xxx.xxx[500] to 172.58.240.224[41861] (321 bytes)

I think you have not included all the log information.

The log you showed has no error messages but it also has no message indication a successful connection.

There is a message half way down which indicates that the selected DH group was not acceptable for the client and ECP_384 was requested.

Then the connection flow re-started, this time with ECP_384 for the DH group and this was accepted.

The last log line is

12:16:04	charon:	15[NET] sending packet: from 108.26.xxx.xxx[500] to 172.58.240.224[41861] (321 bytes)

but there must either be a reply from the client or the server indicating that it timed out but it just stops with that last line.

It timed out.
On my Android device it just said “Disconnected”.

12:18:38 charon: 08[NET] sending packet: from 108.26.xxx.xxx[500] to 172.58.240.224[38483] (321 bytes)
12:19:08 charon: 11[JOB] deleting half open IKE_SA with 172.58.240.224 after timeout
13:36:09 charon: 05[NET] received packet: from 172.58.240.88[28187] to 108.26.xxx.xxx[500] (652 bytes)
13:36:09 charon: 05[ENC] parsed IKE_SA_INIT request 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) N(HASH_ALG) N(REDIR_SUP) ]
13:36:09 charon: 05[IKE] 172.58.240.88 is initiating an IKE_SA
13:36:09 charon: 05[IKE] 172.58.240.88 is initiating an IKE_SA
13:36:09 charon: 05[CFG] selected proposal: IKE:AES_GCM_16_256/PRF_HMAC_SHA2_512/ECP_384
13:36:09 charon: 05[IKE] remote host is behind NAT
13:36:09 charon: 05[IKE] DH group MODP_2048_256 unacceptable, requesting ECP_384
13:36:09 charon: 05[ENC] generating IKE_SA_INIT response 0 [ N(INVAL_KE) ]
13:36:09 charon: 05[NET] sending packet: from 108.26.xxx.xxx[500] to 172.58.240.88[28187] (38 bytes)
13:36:09 charon: 08[NET] received packet: from 172.58.240.88[28187] to 108.26.xxx.xxx[500] (492 bytes)
13:36:09 charon: 08[ENC] parsed IKE_SA_INIT request 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) N(HASH_ALG) N(REDIR_SUP) ]
13:36:09 charon: 08[IKE] 172.58.240.88 is initiating an IKE_SA
13:36:09 charon: 08[IKE] 172.58.240.88 is initiating an IKE_SA
13:36:09 charon: 08[CFG] selected proposal: IKE:AES_GCM_16_256/PRF_HMAC_SHA2_512/ECP_384
13:36:09 charon: 08[IKE] remote host is behind NAT
13:36:09 charon: 08[IKE] sending cert request for C=US, ST=xx, L=xxx, O=xxx, CN=xxx CA, E=xxx@xxx.com
13:36:09 charon: 08[ENC] generating IKE_SA_INIT response 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) CERTREQ N(HASH_ALG) N(CHDLESS_SUP) N(MULT_AUTH) ]
13:36:09 charon: 08[NET] sending packet: from 108.26.xxx.xxx[500] to 172.58.240.88[28187] (321 bytes)
13:36:39 charon: 06[JOB] deleting half open IKE_SA with 172.58.240.88 after timeout

Use OpenVPN for your Android Client not IPSec

I am using this for years without Problems

I am using that, and it works. I was just curious about IPSec.

remote host is behind NAT

I am confused by this statement. What NAT? I thought the IPSec resides on the RED network?

then stick with it.

if you are trying to connect from your IPFire IPSec to your Handy within mobile Network it would not Work. You don’t get a publicly accessible IP on the mobile Network.

I was using my phone, with wifi off. You can see up different IP’s.

Why would I NOT get a publicly accessible IP from cellular? That’s absurd.

please read my Post carefully

from IPFire to mobile Network is not possible

from Mobile Network to IPFire it works

most Provider does not use public accessible IPs and routing

Of course you are online with your phone and can surf
but you can’t access your phone “from outside”.

I didn’t want THAT.
I just want to setup a IPSec VPN server on my ipfire device.
Like I do with OpenVPN.

I didn’t say that at all, it just shows the problems that can arise

IPSec is completely different in terms of connection setup

You have OpenVPN running so use it…

This is missing a few fields.

This might help:

https://www.ipfire.org/docs/configuration/services/ipsec/host-to-net#creating-a-new-connection

I use IPsec with a Mac or an iPad. (I don’t have an Android device)

What is that @example.ddn.org and @myLaptop ?

Those are identifications for your server and for your remote client.

I believe that some clients such as MAC OS expect to have the ID defined. You can use any name for the ID, it just needs to start with an @

I have set up the IPSec RW with PSK for my Linux Laptop, using Network Manager with the Strongswan IPSec plugin.

With that client, I was able to leave the Local and Remote ID’s blank on the server and also on the client. The Network Manager client just uses the name or IP of the server that you specify and the username or hostname.

The IPSec VPN connection worked fine.

I also then added an @ID for the local and remote on the server configuration. If you do that then you must enter those ID values into your client if you want the connection to be made successfully. I added them into my Network Manager client and the IPSec PSK connection was again successfully made.

You need to identify if the client you are using accepts blank ID’s and fills them with default values or if you need to specify them on the server.
The simplest would be to always specify them.

One thing I have realised while checking some of this is that the bug fix I did for the IPSec PSK in CU190 has a slight bug in it. If you go into the edit page for the PSK connection then if you press the Save button, it should only do a Base 64 Encoding of the password that was previously entered if it is defined as not yet being encoded via a variable.
That appears not to be working as if you go into the edit page and change nothing but press the Save button, in all cases it converts the PSK via Base 64 Encoding. This means that each time you press the Save button the PSK is changed into another PSK by being Base 64 Encoded again.

So the workaround for this in the short term is that if you go into the edit page and want to press the Save button then before doing so, copy your original PSK back into the PSK entry box and then press the Save button. This way you get the correct Base 64 Encoded PSK saved in the ipsec.config file.

I will raise a bug report for myself to have a look at what is not working right under which situations and fix it.

3 Likes

I get in the logs:

remote host is behind NAT

I am confused why.

I am trying this on my laptop, connected to my cell hotspot.
Different issues…

09:03:45 charon: 13[IKE] 172.58.244.211 is initiating an IKE_SA
09:03:45 charon: 13[IKE] 172.58.244.211 is initiating an IKE_SA
09:03:45 charon: 13[CFG] received proposals: IKE:3DES_CBC/HMAC_SHA1_96/PRF_HMAC_SHA1/MODP_1024, IKE:3DES_CBC/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/MODP_1024, IKE:3DES_CBC/HMAC_SHA2_384_192/PRF_HMAC_SHA2_384/MODP_1024, IKE:AES_CBC_128/HMAC_SHA1_96/PRF_HMAC_SHA1/MODP_1024, IKE:AES_CBC_128/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/MODP_1024, IKE:AES_CBC_128/HMAC_SHA2_384_192/PRF_HMAC_SHA2_384/MODP_1024, IKE:AES_CBC_192/HMAC_SHA1_96/PRF_HMAC_SHA1/MODP_1024, IKE:AES_CBC_192/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/MODP_1024, IKE:AES_CBC_192/HMAC_SHA2_384_192/PRF_HMAC_SHA2_384/MODP_1024, IKE:AES_CBC_256/HMAC_SHA1_96/PRF_HMAC_SHA1/MODP_1024, IKE:AES_CBC_256/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/MODP_1024, IKE:AES_CBC_256/HMAC_SHA2_384_192/PRF_HMAC_SHA2_384/MODP_1024, IKE:AES_GCM_16_128/PRF_HMAC_SHA1/MODP_1024, IKE:AES_GCM_16_128/PRF_HMAC_SHA2_256/MODP_1024, IKE:AES_GCM_16_128/PRF_HMAC_SHA2_384/MODP_1024, IKE:AES_GCM_16_256/PRF_HMAC_SHA1/MODP_1024, IKE:AES_GCM_16_256/PRF_HMAC_SHA2_256/MODP_1024, IKE:AES_GCM_16_256/PRF_
09:03:45 charon: 13[CFG] configured proposals: IKE:CHACHA20_POLY1305/PRF_HMAC_SHA2_512/CURVE_448, IKE:CHACHA20_POLY1305/PRF_HMAC_SHA2_512/CURVE_25519, IKE:CHACHA20_POLY1305/PRF_HMAC_SHA2_512/ECP_521, IKE:CHACHA20_POLY1305/PRF_HMAC_SHA2_512/ECP_512_BP, IKE:CHACHA20_POLY1305/PRF_HMAC_SHA2_512/ECP_384, IKE:CHACHA20_POLY1305/PRF_HMAC_SHA2_512/MODP_4096, IKE:CHACHA20_POLY1305/PRF_HMAC_SHA2_512/MODP_3072, IKE:CHACHA20_POLY1305/PRF_HMAC_SHA2_384/CURVE_448, IKE:CHACHA20_POLY1305/PRF_HMAC_SHA2_384/CURVE_25519, IKE:CHACHA20_POLY1305/PRF_HMAC_SHA2_384/ECP_521, IKE:CHACHA20_POLY1305/PRF_HMAC_SHA2_384/ECP_512_BP, IKE:CHACHA20_POLY1305/PRF_HMAC_SHA2_384/ECP_384, IKE:CHACHA20_POLY1305/PRF_HMAC_SHA2_384/MODP_4096, IKE:CHACHA20_POLY1305/PRF_HMAC_SHA2_384/MODP_3072, IKE:CHACHA20_POLY1305/PRF_HMAC_SHA2_256/CURVE_448, IKE:CHACHA20_POLY1305/PRF_HMAC_SHA2_256/CURVE_25519, IKE:CHACHA20_POLY1305/PRF_HMAC_SHA2_256/ECP_521, IKE:CHACHA20_POLY1305/PRF_HMAC_SHA2_256/ECP_512_BP, IKE:CHACHA20_POLY1305/PRF_HMAC_SHA2_256/ECP_384
09:03:45 charon: 13[IKE] local host is behind NAT, sending keep alives
09:03:45 charon: 13[IKE] remote host is behind NAT
09:03:45 charon: 13[IKE] received proposals unacceptable
09:03:45 charon: 13[ENC] generating IKE_SA_INIT response 0 [ N(NO_PROP) ]

You have it explained in the following post

I don’t understand this. I don’t try to access my phone from “outside”, but to access my ipfire VPN from my phone.
The server ipfire is on landline fiber.
Also, the OpenVPN works on my phone data, so why the IPSec VPN won’t work?

In Core Update 170 (Sept 2022) MODP-2048 was removed from the IPFire IPSec code as that Diffie Hellman group (2048 bits) was at that time considered to be too weak as it was too short.

https://www.ipfire.org/blog/ipfire-2-27-core-update-170-released

In your log from the setup with your laptop you can see that your laptop IPSec client was proposing to use MODP-1024 (1024 bits) with all its ciphers and that is even shorter, and therefore more vulnerable, than the modp-2048, which is also no longer accepted.

Therefore there was no overlap between the proposed groups and ciphers from your laptop and the ones that are available on IPFire.

Is your laptop running with Windows. I have seen other people on this forum having problems with older versions of windows as their DH groups and ciphers have not been updated from the older vulnerable versions.

If you are using Windows, what version are you using?

If it is not Windows, what OS is on your laptop and at what version or update status?

I suspect because the IPSec client on your Android phone is using older, vulnerable ciphers etc.

Maybe try installing the StrongSwan app on your Android phone. StrongSwan is the IPSec package running in IPFire and that StrongSwan app is kept up to date.

1 Like

It looks like lots of ciphers are enabled.

Can you post a screenshot of your Advanced page?

Each client device has supported ciphers. From the Wiki these are the ones supported by Apple:

this above is a screenshot from this IPFire Wiki:
https://www.ipfire.org/docs/configuration/services/ipsec/host-to-net/apple


And for Windows (from the Wiki):

this above is a screenshot from this IPFire Wiki:
https://www.ipfire.org/docs/configuration/services/ipsec/host-to-net/windows


I do not know the ciphers from an Android device.

We need to match the device ciphers to the Advanced WebGUI to make sure things are correct and work.

This is from the Wiki page (and was my original setup for my iPad)