<div dir="ltr"><div>Hi Paul,</div><div><br></div><div>I have some general security-policies that just allow the traffic to pass through the system (i.e., no IPsec is applied to those traffic). Say for example, allow all traffic of of certain source and destination IP and source and destination port as 5060 (SIP traffic) not processed by IPsec. </div><div><br></div><div>In that case, how do I convey this security-policy behavior to Libreswan via the script? What parameters need to be configured? Should I create a separate connection section?</div><div><br></div><div>Thanks,</div><div>Balaji</div></div><br><div class="gmail_quote"><div class="gmail_attr" dir="ltr">On Sat, May 16, 2020 at 1:38 PM Balaji Thoguluva <<a href="mailto:tbbalaji@gmail.com">tbbalaji@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr">Thanks Paul for the information.</div><br><div class="gmail_quote"><div class="gmail_attr" dir="ltr">On Mon, May 11, 2020 at 1:29 PM Paul Wouters <<a href="mailto:paul@nohats.ca" target="_blank">paul@nohats.ca</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">On Mon, 11 May 2020, Balaji Thoguluva wrote:<br>
<br>
> I am a newbie to Libreswan. I am working on a Linux based application project where we need IKEv2 and IPsec stack to support sending traffic over IKEv2/IPsec established tunnel. <br>
> <br>
> Do you have some guidelines or detailed steps on how to <br>
> 1. Initialize and integrate the Libreswan stack with the application (user-space of Linux)<br>
<br>
What do you mean with "libreswan stack"?<br>
<br>
There are two ways to initiate tunnels. One is packet triggered, and one<br>
is command triggered. The packet trigger works if your conncetion has<br>
been loaded using the auto=start keyword in the connection configuration<br>
file (the "conn" section). To bring defined connections in connection<br>
files up using a command, you can use the "ipsec auto --up" and "ipsec<br>
auto --down" commands. A more low level command is "ipsec whack", which<br>
is basically an (undocumented internal only) API using a socket in<br>
/run/pluto/pluto.ctl with the message format defined in whack.h<br>
<br>
> 2. any documents on Libreswan API's and how to trigger IKEv2 negotiation from the application via Libreswan, how to install SA's and SPD's via Libreswan to Linux etc.<br>
<br>
If you can do it packet triggered, that is the best way. It requires no<br>
modification of your application. If you want to specifically trigger<br>
it, and the connections are fairly static with respect to configuration,<br>
use the ipsec auto command. If you are looking at large scale mesh<br>
dpeloyment, look at "opportunistic IPsec".<br>
<br>
You should not need to install IPsec SA's or IPsec SPD's in the kernel<br>
manually. All of that is handled by libreswan's IKE daemon pluto.<br>
<br>
See further:<br>
<br>
<a href="https://libreswan.org/wiki/Configuration_examples" target="_blank" rel="noreferrer">https://libreswan.org/wiki/Configuration_examples</a><br>
<br>
<a href="https://libreswan.org/man/" target="_blank" rel="noreferrer">https://libreswan.org/man/</a><br>
<br>
You need to decide what to use for authentication, PSK or raw public<br>
keys or certificates. Depending on that choice, you might need to<br>
look into the integration of libreswan with NSS for certificate<br>
handling: <a href="https://libreswan.org/wiki/HOWTO:_Using_NSS_with_libreswan" target="_blank" rel="noreferrer">https://libreswan.org/wiki/HOWTO:_Using_NSS_with_libreswan</a><br>
<br>
Opportunistic IPsec for enterprise mesh: <a href="https://libreswan.org/wiki/HOWTO:_Opportunistic_IPsec" target="_blank" rel="noreferrer">https://libreswan.org/wiki/HOWTO:_Opportunistic_IPsec</a><br>
<br>
To integrate tunnel status in your application, you can use "ipsec trafficstatus"<br>
<br>
Paul<br>
</blockquote></div>
</blockquote></div>