# VPN not connecting, IPSec - required

**URL:** <https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240>\
**Category:** General\
**Created:** [July 6, 2022, 1:32pm UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240 "2022-07-06T13:32:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Baktery](https://forum.mikrotik.com/letter_avatar/baktery/32/6_449c533f586939b6e5f246632a46421f.png) [@Baktery](https://forum.mikrotik.com/u/Baktery)\
**Post date:** [July 6, 2022, 1:32pm UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240/1 "2022-07-06T13:32:25Z")

</div>

Hello,

I have vpn L2TP Server, in settings I use IPSec - required. The problem is that the client does not connect from any Windows.  
In the log on Mikrotik writes error: L2TP connection rejected no IPsec encryption while it was required.  
On the windows the client writes error: Cannot connect to the remote computer, so the connection port is closed.

On Mikrotik I have permission rules Firewall: Input udp 500,1701, 4500 and 50 (ipsec-esp).

When I change - use IPSec: yes. Connection is working.  
Tell me what could be the reason?

---

<div class="post-metadata">

**Author:** ![sindy](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/sindy/32/55716_2.png) [@sindy](https://forum.mikrotik.com/u/sindy)\
**Post date:** [July 6, 2022, 1:53pm UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240/2 "2022-07-06T13:53:53Z")

</div>

_use-ipsec=yes_ permits use of IPsec to protect L2TP sessions, but does not enforce it, so if the client tries to establish the L2TP connection without previously establishing an IPsec security association, Mikrotik accepts that unprotected session.

By default, the Windows native VPN client has the same setting - it prefers an IPsec-protected connection but if it cannot be established, it connects using bare L2TP anyway.

Now there are two possible reasons - either the encryption and authentication algorithm sets (proposals) are incompatible between the client and the server, or your ISP is blocking IPsec ports (the dialect of English you use suggests it could be the case). But let’s be optimistic and belive it is just a configuration issue. As you say that “client does not connect from any Windows”, does it mean Android, Mikrotik, iOS, or Linux clients do connect successfully even if _use-ipsec_ is set to _required_?

---

<div class="post-metadata">

**Author:** ![Baktery](https://forum.mikrotik.com/letter_avatar/baktery/32/6_449c533f586939b6e5f246632a46421f.png) [@Baktery](https://forum.mikrotik.com/u/Baktery)\
**Post date:** [July 6, 2022, 2:14pm UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240/3 "2022-07-06T14:14:31Z")

</div>

> [@](#):
>
> _use-ipsec=yes_ permits use of IPsec to protect L2TP sessions, but does not enforce it, so if the client tries to establish the L2TP connection without previously establishing an IPsec security association, Mikrotik accepts that unprotected session.
> 
> By default, the Windows native VPN client has the same setting - it prefers an IPsec-protected connection but if it cannot be established, it connects using bare L2TP anyway.
> 
> Now there are two possible reasons - either the encryption and authentication algorithm sets (proposals) are incompatible between the client and the server, or your ISP is blocking IPsec ports (the dialect of English you use suggests it could be the case). But let’s be optimistic and belive it is just a configuration issue. As you say that “client does not connect from any Windows”, does it mean Android, Mikrotik, iOS, or Linux clients do connect successfully even if _use-ipsec_ is set to _required_?

Yes, you are right, it connects from Android. What encryption settings on Mikrotik will be compatible with Windows 10/11 ?

---

<div class="post-metadata">

**Author:** ![sindy](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/sindy/32/55716_2.png) [@sindy](https://forum.mikrotik.com/u/sindy)\
**Post date:** [July 6, 2022, 2:46pm UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240/4 "2022-07-06T14:46:30Z")

</div>

> [@](#):
>
> What encryption settings on Mikrotik will be compatible with Windows 10/11 ?

The default ones (which the L2TP server uses to generate the IPsec settings dynamically if _use-ipsec_ is set to _yes_ or _required_) normally do. So you have probably changed them to make the Android happy?

/ip ipsec profile:  
_dh-group=modp2048,modp1024 dpd-interval=2m dpd-maximum-failures=5 enc-algorithm=aes-128,3des hash-algorithm=sha1 lifetime=1d name=default nat-traversal=yes proposal-check=obey_

/ip ipsec proposal:  
_auth-algorithms=sha1 disabled=no enc-algorithms=aes-256-cbc,aes-192-cbc,aes-128-cbc lifetime=30m name=default pfs-group=modp1024_

You should enable logging and see what is the strongest encryption and authentication algorithm offered by Windows. Also something is telling me that WIndows do not support _pfs_ by default and you need PowerShell to tell them otherwise.

---

<div class="post-metadata">

**Author:** ![Baktery](https://forum.mikrotik.com/letter_avatar/baktery/32/6_449c533f586939b6e5f246632a46421f.png) [@Baktery](https://forum.mikrotik.com/u/Baktery)\
**Post date:** [July 6, 2022, 3:14pm UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240/5 "2022-07-06T15:14:00Z")

</div>

> [@](#):
>
> > [@](#):
> >
> > What encryption settings on Mikrotik will be compatible with Windows 10/11 ?
> 
> The default ones (which the L2TP server uses to generate the IPsec settings dynamically if _use-ipsec_ is set to _yes_ or _required_) normally do. So you have probably changed them to make the Android happy?
> 
> /ip ipsec profile:  
> _dh-group=modp2048,modp1024 dpd-interval=2m dpd-maximum-failures=5 enc-algorithm=aes-128,3des hash-algorithm=sha1 lifetime=1d name=default nat-traversal=yes proposal-check=obey_
> 
> /ip ipsec proposal:  
> _auth-algorithms=sha1 disabled=no enc-algorithms=aes-256-cbc,aes-192-cbc,aes-128-cbc lifetime=30m name=default pfs-group=modp1024_
> 
> You should enable logging and see what is the strongest encryption and authentication algorithm offered by Windows. Also something is telling me that WIndows do not support _pfs_ by default and you need PowerShell to tell them otherwise.

for Android, I did not specifically configure anything on the router, it worked automatically

These are my default profile settings (in the attachment)  
How to find out what encryption is used Windows?

 ![IPsec Proposal.png](https://data-discourse.cdn.mikrotik.com/original/3X/0/0/0087566884b0adbee88b63b884b1942b4d882a28.png)  
 ![IPsec profile.png](https://data-discourse.cdn.mikrotik.com/original/3X/9/d/9da7209e1e6a6360de69035442b02c522c72bf6d.png)

---

<div class="post-metadata">

**Author:** ![sindy](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/sindy/32/55716_2.png) [@sindy](https://forum.mikrotik.com/u/sindy)\
**Post date:** [July 6, 2022, 3:29pm UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240/6 "2022-07-06T15:29:30Z")

</div>

_/system logging add topics=ipsec,!packet_

Then run _/log print follow-only file=ipsec-start where topics~“ipsec”_, make a single connection attempt from the client, stop the _/log print …_, download the file _ipsec-start.txt_ and look for “proposal” in it.

---

<div class="post-metadata">

**Author:** ![Baktery](https://forum.mikrotik.com/letter_avatar/baktery/32/6_449c533f586939b6e5f246632a46421f.png) [@Baktery](https://forum.mikrotik.com/u/Baktery)\
**Post date:** [July 6, 2022, 3:52pm UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240/7 "2022-07-06T15:52:29Z")

</div>

> [@](#):
>
> _/system logging add topics=ipsec,!packet_
> 
> Then run _/log print follow-only file=ipsec-start where topics~“ipsec”_, make a single connection attempt from the client, stop the _/log print …_, download the file _ipsec-start.txt_ and look for “proposal” in it.

Here is what I get

 ![2022-07-06_18-51-12.png](https://data-discourse.cdn.mikrotik.com/original/3X/2/6/262f277e5d4d19f3049da541d7bb10eff497e4f4.png)

---

<div class="post-metadata">

**Author:** ![sindy](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/sindy/32/55716_2.png) [@sindy](https://forum.mikrotik.com/u/sindy)\
**Post date:** [July 6, 2022, 5:31pm UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240/8 "2022-07-06T17:31:02Z")

</div>

Unfortunately you have to open the terminal window and use the text commands I gave. The GUI will not show you what you need as too many lines of log are generated to fit into the memory buffer.

---

<div class="post-metadata">

**Author:** ![Baktery](https://forum.mikrotik.com/letter_avatar/baktery/32/6_449c533f586939b6e5f246632a46421f.png) [@Baktery](https://forum.mikrotik.com/u/Baktery)\
**Post date:** [July 6, 2022, 5:57pm UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240/9 "2022-07-06T17:57:31Z")

</div>

> [@](#):
>
> Unfortunately you have to open the terminal window and use the text commands I gave. The GUI will not show you what you need as too many lines of log are generated to fit into the memory buffer.

I’m trying to connect but no new entries appear  
 ![1111png.png](https://data-discourse.cdn.mikrotik.com/original/3X/f/9/f9468bceb0ff7cd4efbcfaf24b975919acb23028.png)

---

<div class="post-metadata">

**Author:** ![sindy](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/sindy/32/55716_2.png) [@sindy](https://forum.mikrotik.com/u/sindy)\
**Post date:** [July 6, 2022, 6:00pm UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240/10 "2022-07-06T18:00:48Z")

</div>

> [@](#):
>
> I’m trying to connect but no new entries appear

Now press Ctrl-C and open the file _ipsec-start.txt_ that has appeared in the file list.

---

<div class="post-metadata">

**Author:** ![chechito](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/chechito/32/1416_2.png) [@chechito](https://forum.mikrotik.com/u/chechito)\
**Post date:** [July 6, 2022, 6:09pm UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240/11 "2022-07-06T18:09:24Z")

</div>

in windows you have to go to security settings of the vpn connection and introduce ipsec PSK (pre shared key)

---

<div class="post-metadata">

**Author:** ![Baktery](https://forum.mikrotik.com/letter_avatar/baktery/32/6_449c533f586939b6e5f246632a46421f.png) [@Baktery](https://forum.mikrotik.com/u/Baktery)\
**Post date:** [July 6, 2022, 6:49pm UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240/12 "2022-07-06T18:49:41Z")

</div>

> [@](#):
>
> > [@](#):
> >
> > I'm trying to connect but no new entries appear
> 
> Now press Ctrl-C and open the file _ipsec-start.txt_ that has appeared in the file list.

That's all it has

# jul/ 6/2022 18:48:45 by RouterOS 6.49.5

# software id = ZJ3M-ESHW

#

---

<div class="post-metadata">

**Author:** ![sindy](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/sindy/32/55716_2.png) [@sindy](https://forum.mikrotik.com/u/sindy)\
**Post date:** [July 6, 2022, 6:53pm UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240/13 "2022-07-06T18:53:22Z")

</div>

In that case, @chechito is right and you haven’t configured the Windows to use IPsec (while still assuming that the ISP doesn’t interfere given that Android connects allright).

---

<div class="post-metadata">

**Author:** ![Baktery](https://forum.mikrotik.com/letter_avatar/baktery/32/6_449c533f586939b6e5f246632a46421f.png) [@Baktery](https://forum.mikrotik.com/u/Baktery)\
**Post date:** [July 6, 2022, 6:55pm UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240/14 "2022-07-06T18:55:54Z")

</div>

> [@](#):
>
> In that case, @chechito is right and you haven’t configured the Windows to use IPsec (while still assuming that the ISP doesn’t interfere given that Android connects allright).

tell me how to configure Windows to use IPsec ? where can i read about it

---

<div class="post-metadata">

**Author:** ![sindy](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/sindy/32/55716_2.png) [@sindy](https://forum.mikrotik.com/u/sindy)\
**Post date:** [July 6, 2022, 7:01pm UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240/15 "2022-07-06T19:01:12Z")

</div>

Well, rather you tell me how you’ve managed to configure it **without** IPsec 🙂

When I add a VPN connection the “new” (Win10) way, I can choose between “L2TP/IPsec with certificate” and “L2TP/IPsec with pre-shared key” (plus a few other possibilities not related to L2TP), but there’s no choice of bare L2TP. So I choose the “L2TP/IPsec with PSK”, fill in the PSK, and that’s it.

---

<div class="post-metadata">

**Author:** ![Baktery](https://forum.mikrotik.com/letter_avatar/baktery/32/6_449c533f586939b6e5f246632a46421f.png) [@Baktery](https://forum.mikrotik.com/u/Baktery)\
**Post date:** [July 7, 2022, 8:08am UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240/16 "2022-07-07T08:08:56Z")

</div>

> [@](#):
>
> Well, rather you tell me how you’ve managed to configure it **without** IPsec 🙂
> 
> When I add a VPN connection the “new” (Win10) way, I can choose between “L2TP/IPsec with certificate” and “L2TP/IPsec with pre-shared key” (plus a few other possibilities not related to L2TP), but there’s no choice of bare L2TP. So I choose the “L2TP/IPsec with PSK”, fill in the PSK, and that’s it.

I do everything exactly the same, it’s very strange, but it doesn’t work

---

<div class="post-metadata">

**Author:** ![sindy](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/sindy/32/55716_2.png) [@sindy](https://forum.mikrotik.com/u/sindy)\
**Post date:** [July 7, 2022, 8:46am UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240/17 "2022-07-07T08:46:48Z")

</div>

Is the Android client connecting from the same network like the Windows? I.e. could it be that connections to port 500 and 4500 are indeed blocked somewhere on the path between the Windows and the Mikrotik, but not on the path between the Android and the Mikrotik?

Can you run Wireshark on the Windows to see whether they are sending packets to UDP port 500 on the Mikrotik address?

---

<div class="post-metadata">

**Author:** ![Baktery](https://forum.mikrotik.com/letter_avatar/baktery/32/6_449c533f586939b6e5f246632a46421f.png) [@Baktery](https://forum.mikrotik.com/u/Baktery)\
**Post date:** [July 7, 2022, 12:58pm UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240/18 "2022-07-07T12:58:13Z")

</div>

> [@](#):
>
> Is the Android client connecting from the same network like the Windows? I.e. could it be that connections to port 500 and 4500 are indeed blocked somewhere on the path between the Windows and the Mikrotik, but not on the path between the Android and the Mikrotik?
> 
> Can you run Wireshark on the Windows to see whether they are sending packets to UDP port 500 on the Mikrotik address?

Android is on the same network as Windows.  
launched Wireshark, I see that during the connection attempt is used port 1701. I can’t find the port 500 in the list

---

<div class="post-metadata">

**Author:** ![Baktery](https://forum.mikrotik.com/letter_avatar/baktery/32/6_449c533f586939b6e5f246632a46421f.png) [@Baktery](https://forum.mikrotik.com/u/Baktery)\
**Post date:** [July 7, 2022, 4:33pm UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240/19 "2022-07-07T16:33:13Z")

</div>

> [@](#):
>
> Is the Android client connecting from the same network like the Windows? I.e. could it be that connections to port 500 and 4500 are indeed blocked somewhere on the path between the Windows and the Mikrotik, but not on the path between the Android and the Mikrotik?
> 
> Can you run Wireshark on the Windows to see whether they are sending packets to UDP port 500 on the Mikrotik address?

Maybe I did not indicate an important detail, RouterOS is installed on a virtual machine. There is no such problem on the hardware Mikrotik.  
And yet, the connection between routers with IPSec works, the policy is established. It turns out that IPSec does not work in the client-server version.

---

<div class="post-metadata">

**Author:** ![sindy](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/sindy/32/55716_2.png) [@sindy](https://forum.mikrotik.com/u/sindy)\
**Post date:** [July 9, 2022, 9:06am UTC](https://forum.mikrotik.com/t/vpn-not-connecting-ipsec-required/159240/20 "2022-07-09T09:06:48Z")

</div>

Does the Android client connect to this virtual RouterOS?

Could it be that there is an external firewall between the virtual RouterOS and the internet? The thing is that for a site-to-site IPsec, both routers actively initiate the connection, so the virtual RouterOS opens a pinhole in the external firewall and thus the firewall lets through packets from the remote router.
