{"id":301615,"date":"2020-04-10T03:00:14","date_gmt":"2020-04-10T03:00:14","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=301615"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-04-10T03:00:14","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=301615","title":{"rendered":"IPIP IPsec VPN \u0442\u0443\u043d\u043d\u0435\u043b\u044c \u043c\u0435\u0436\u0434\u0443 Linux \u043c\u0430\u0448\u0438\u043d\u043e\u0439 \u0438 Mikrotik \u0437\u0430 NAT \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/496514\/\">\n<p><strong>Linux: <\/strong>Ubuntu 18.04.4 LTS (GNU\/Linux 4.15.0-91-generic x86_64)<\/p>\n<p>  <\/p>\n<ul>\n<li>Eth0 1.1.1.1\/32 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 IP<\/li>\n<li>ipip-ipsec0 192.168.0.1\/30 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0448 \u0442\u0443\u043d\u043d\u0435\u043b\u044c<\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>Miktoik: <\/strong>CCR 1009, RouterOS 6.46.5<\/p>\n<p>  <\/p>\n<ul>\n<li>Eth0 10.0.0.2\/30 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 IP \u043e\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430. \u0412\u043d\u0435\u0448\u043d\u0438\u0439 IP NAT \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439.<\/li>\n<li>ipip-ipsec0 192.168.0.2\/30 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0448 \u0442\u0443\u043d\u043d\u0435\u043b\u044c<\/li>\n<\/ul>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>IPsec \u0442\u0443\u043d\u043d\u0435\u043b\u044c \u043d\u0430 Linux \u043c\u0430\u0448\u0438\u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e racoon. \u041d\u0435 \u0431\u0443\u0434\u0443 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438, \u0435\u0441\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0430\u044f <a href=\"https:\/\/habr.com\/ru\/post\/425079\/\">\u0441\u0442\u0430\u0442\u044c\u044f<\/a> \u0443 <a href=\"https:\/\/habr.com\/ru\/users\/vvpoloskin\/\" class=\"user_link\">vvpoloskin<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">sudo install racoon ipsec-tools<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c racoon, \u043e\u043d \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0432 \u0440\u043e\u043b\u0438 ipsec \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0422\u0430\u043a \u043a\u0430\u043a mikrotik \u0432 main \u0440\u0435\u0436\u0438\u043c\u0435 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u0430 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 ip \u0430\u0434\u0440\u0435\u0441 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043d \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u0438\u0442\u0441\u044f \u043a Linux \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c preshared key (\u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u043e \u043f\u0430\u0440\u043e\u043b\u044e) \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u0430\u0440\u043e\u043b\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043b\u0438\u0431\u043e \u0441 ip \u0430\u0434\u0440\u0435\u0441\u043e\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u0445\u043e\u0441\u0442\u0430, \u043b\u0438\u0431\u043e \u0441 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c.<\/p>\n<p>  <\/p>\n<p>\u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u043e RSA \u043a\u043b\u044e\u0447\u0430\u043c.<\/p>\n<p>  <\/p>\n<p>\u0414\u0435\u043c\u043e\u043d racoon \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043a\u043b\u044e\u0447\u0438 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 RSA, \u0430 miktork \u2014 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 PEM. \u0415\u0441\u043b\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0438 \u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439 plainrsa-gen \u0438\u0434\u0443\u0449\u0435\u0439 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 racoon, \u0442\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u0434\u043b\u044f Mikrotika \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 PEM \u0441 \u0435\u0435 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u2014 \u043e\u043d\u0430 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u043e\u0440\u043e\u043d\u0443: PEM \u0432 RSA. \u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 plainrsa-gen \u043a\u043b\u044e\u0447 \u043d\u0435 \u0441\u043c\u043e\u0433\u043b\u0438 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0438 openssl, \u043d\u0438 ssh-keygen, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441 \u0438\u0445 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e.<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c PEM \u043a\u043b\u044e\u0447 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e openssl, \u0430 \u0437\u0430\u0442\u0435\u043c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e \u0434\u043b\u044f racoon \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e plainrsa-gen:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">#  \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u044e\u0447 openssl genrsa -out server-name.pem 1024 # \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 openssl rsa -in server-name.pem -pubout &gt; server-name.pub.pem # \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c plainrsa-gen -i server-name.pem -f server-name.privet.key plainrsa-gen -i server-name.pub.pem -f server-name.pub.key<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443: \/etc\/racoon\/certs\/server. \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043e\u0442 \u0447\u044c\u0435\u0433\u043e \u0438\u043c\u0435\u043d\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0434\u0435\u043c\u043e\u043d racoon (\u043e\u0431\u044b\u0447\u043d\u043e root), \u043f\u0440\u0430\u0432\u0430 600.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 mikrotik \u043e\u043f\u0438\u0448\u0443 \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 WinBox.<\/p>\n<p>  <\/p>\n<p>\u041a\u043b\u044e\u0447 server-name.pub.pem \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0432 mikrotik: \u041c\u0435\u043d\u044e \u00abFiles\u00bb \u2014 \u00abUpload\u00bb.<\/p>\n<p>  <\/p>\n<p>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b \u00abIP\u00bb \u2014 \u00abIP sec\u00bb \u2014 \u0432\u043a\u043b\u0430\u0434\u043a\u0430 \u00abKeys\u00bb. \u0422\u0435\u043f\u0435\u0440\u044c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u044e\u0447\u0438 \u2014 \u043a\u043d\u043e\u043f\u043a\u0430 \u00abGenerate Key\u00bb, \u0437\u0430\u0442\u0435\u043c \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 mikrotika \u00abExpor Pub. Key\u00bb, \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0437 \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u00abFiles\u00bb, \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043f\u043e \u0444\u0430\u0439\u043b\u0443 \u2014 \u00abDownload\u00bb.<\/p>\n<p>  <\/p>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 racoon, \u00abImport\u00bb, \u0432 \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0435\u043c \u0441\u043f\u0438\u0441\u043a\u0435 \u043f\u043e\u043b\u044f \u00abFile name\u00bb \u0438\u0449\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0439 \u0440\u0430\u043d\u0435\u0435 \u043d\u0430\u043c\u0438 server-name.pub.pem.<\/p>\n<p>  <\/p>\n<p>\u041f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 mikrotik \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c <\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">plainrsa-gen -i mikrotik.pub.pem -f mikrotik.pub.key<\/code><\/pre>\n<p>  <\/p>\n<p>\u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0432 \u043f\u0430\u043f\u043a\u0443 \/etc\/racoon\/certs \u043d\u0435 \u0437\u0430\u0431\u044b\u0432 \u043f\u0440\u043e \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0430 \u0438 \u043f\u0440\u0430\u0432\u0430.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u043d\u0444\u0438\u0433 racoon \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438: \/etc\/racoon\/racoon.conf<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">log info; # \u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u0440\u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c Debug \u0438\u043b\u0438 Debug2.  listen {      isakmp 1.1.1.1 [500]; # \u0410\u0434\u0440\u0435\u0441 \u0438 \u043f\u043e\u0440\u0442, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u0434\u0435\u043c\u043e\u043d.     isakmp_natt 1.1.1.1 [4500]; # \u0410\u0434\u0440\u0435\u0441 \u0438 \u043f\u043e\u0440\u0442, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u0434\u0435\u043c\u043e\u043d \u0434\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0437\u0430 NAT.     strict_address; # \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438 \u043a \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0432\u044b\u0448\u0435 IP. }  path certificate &quot;\/etc\/racoon\/certs&quot;; # \u041f\u0443\u0442\u044c \u0434\u043e \u043f\u0430\u043f\u043a\u0438 \u0441 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u043c\u0438.  remote anonymous { # \u0421\u0435\u043a\u0446\u0438\u044f, \u0437\u0430\u0434\u0430\u044e\u0449\u0430\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u0435\u043c\u043e\u043d\u0430 \u0441 ISAKMP \u0438 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0441 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u043c\u0438\u0441\u044f \u0445\u043e\u0441\u0442\u0430\u043c\u0438. \u0422\u0430\u043a \u043a\u0430\u043a IP, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f Mikrotik, \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439, \u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c anonymous, \u0447\u0442\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441 \u043b\u044e\u0431\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430. \u0415\u0441\u043b\u0438 IP \u0443 \u0445\u043e\u0441\u0442\u043e\u0432 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u0438 \u043f\u043e\u0440\u0442.      passive on; # \u0417\u0430\u0434\u0430\u0435\u0442 &quot;\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439&quot; \u0440\u0435\u0436\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u0435\u043c\u043e\u043d\u0430, \u043e\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.     nat_traversal on; # \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0436\u0438\u043c\u0430 NAT-T \u0434\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0437\u0430 NAT.      exchange_mode main; # \u0420\u0435\u0436\u0438\u043c \u043e\u0431\u043c\u0435\u043d\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 ---\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0435.     my_identifier address 1.1.1.1; # \u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448 linux \u0445\u043e\u0441\u0442 \u043f\u043e \u0435\u0433\u043e ip \u0430\u0434\u0440\u0435\u0441\u0443.     certificate_type plain_rsa &quot;server\/server-name.priv.key&quot;; # \u041f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.     peers_certfile plain_rsa &quot;mikrotik.pub.key&quot;; # \u041f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 Mikrotik.      proposal_check claim; # \u0420\u0435\u0436\u0438\u043c \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 ISAKMP \u0442\u0443\u043d\u043d\u0435\u043b\u044f. Racoon \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u0445\u043e\u0441\u0442\u0430 (\u0438\u043d\u0438\u0446\u0438\u0430\u0442\u043e\u0440\u0430) \u0434\u043b\u044f \u0441\u0440\u043e\u043a\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u0435\u0441\u0441\u0438\u0438                   \u0438 \u0434\u043b\u0438\u043d\u044b \u043a\u043b\u044e\u0447\u0430, \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u0441\u0440\u043e\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u0435\u0441\u0441\u0438\u0438 \u0431\u043e\u043b\u044c\u0448\u0435, \u0438\u043b\u0438 \u0434\u043b\u0438\u043d\u0430 \u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u043a\u043e\u0440\u043e\u0447\u0435, \u0447\u0435\u043c \u0443 \u0438\u043d\u0438\u0446\u0438\u0430\u0442\u043e\u0440\u0430. \u0415\u0441\u043b\u0438 \u0441\u0440\u043e\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u0435\u0441\u0441\u0438\u0438 \u043a\u043e\u0440\u043e\u0447\u0435, \u0447\u0435\u043c \u0443 \u0438\u043d\u0438\u0446\u0438\u0430\u0442\u043e\u0440\u0430, racoon \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0440\u043e\u043a\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u0435\u0441\u0441\u0438\u0438 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 RESPONDER-LIFETIME.     proposal { # \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b ISAKMP \u0442\u0443\u043d\u043d\u0435\u043b\u044f.          encryption_algorithm aes; # \u041c\u0435\u0442\u043e\u0434 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f ISAKMP \u0442\u0443\u043d\u043d\u0435\u043b\u044f.         hash_algorithm sha512; # \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0445\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u043b\u044f ISAKMP \u0442\u0443\u043d\u043d\u0435\u043b\u044f.         authentication_method rsasig; # \u0420\u0435\u0436\u0438\u043c \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0434\u043b\u044f ISAKMP \u0442\u0443\u043d\u043d\u0435\u043b\u044f - \u043f\u043e RSA \u043a\u043b\u044e\u0447\u0430\u043c.         dh_group modp2048; # \u0414\u043b\u0438\u043d\u0430 \u043a\u043b\u044e\u0447\u0430 \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0414\u0438\u0444\u0444\u0438-\u0425\u0435\u043b\u043b\u043c\u0430\u043d\u0430 \u043f\u0440\u0438 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0438 ISAKMP \u0442\u0443\u043d\u043d\u0435\u043b\u044f.         lifetime time 86400 sec; \u0412\u0440\u0435\u043c\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u0435\u0441\u0441\u0438\u0438.     }      generate_policy on; # \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 ESP \u0442\u0443\u043d\u043d\u0435\u043b\u0435\u0439 \u0438\u0437 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0435\u0433\u043e \u043e\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u0445\u043e\u0441\u0442\u0430. }  sainfo anonymous { # \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b ESP \u0442\u0443\u043d\u043d\u0435\u043b\u0435\u0439, anonymous - \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0414\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u043f\u043e\u0440\u0442\u043e\u0432, \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432 \u043c\u043e\u0436\u043d\u043e              \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e ip \u0430\u0434\u0440\u0435\u0441\u0430\u043c, \u043f\u043e\u0440\u0442\u0430\u043c, \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430\u043c.      pfs_group modp2048; # \u0414\u043b\u0438\u043d\u0430 \u043a\u043b\u044e\u0447\u0430 \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0414\u0438\u0444\u0444\u0438-\u0425\u0435\u043b\u043b\u043c\u0430\u043d\u0430 \u0434\u043b\u044f ESP \u0442\u0443\u043d\u043d\u0435\u043b\u0435\u0439.     lifetime time 28800 sec; # \u0421\u0440\u043e\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f ESP \u0442\u0443\u043d\u043d\u0435\u043b\u0435\u0439.     encryption_algorithm aes; # \u041c\u0435\u0442\u043e\u0434 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f ESP \u0442\u0443\u043d\u043d\u0435\u043b\u0435\u0439.     authentication_algorithm hmac_sha512; # \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0445\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 ESP \u0442\u0443\u043d\u043d\u0435\u043b\u0435\u0439.     compression_algorithm deflate; # \u0421\u0436\u0438\u043c\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0436\u0430\u0442\u0438\u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d. } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u043d\u0444\u0438\u0433 mikrotik<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u0432 \u0440\u0430\u0437\u0434\u0435\u043b &quot;IP&quot; \u2014 &quot;IPsec&quot;<\/p>\n<p>  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<thead>\n<tr>\n<th>\u0412\u043a\u043b\u0430\u0434\u043a\u0430 &quot;Profiles&quot;<br \/>  \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440<\/th>\n<th>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Name<\/td>\n<td>\u041d\u0430 \u0432\u0430\u0448\u0435 \u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0435 (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e default)<\/td>\n<\/tr>\n<tr>\n<td>Hash Algorithm<\/td>\n<td>sha512<\/td>\n<\/tr>\n<tr>\n<td>Encryption Algorithm<\/td>\n<td>aes-128<\/td>\n<\/tr>\n<tr>\n<td>DH-Group<\/td>\n<td>modp2048<\/td>\n<\/tr>\n<tr>\n<td>Proposhal_check<\/td>\n<td>claim<\/td>\n<\/tr>\n<tr>\n<td>Lifetime<\/td>\n<td>1d 00:00:00<\/td>\n<\/tr>\n<tr>\n<td>NAT Traversal<\/td>\n<td>true (\u0441\u0442\u0430\u0432\u0438\u043c \u0433\u0430\u043b\u043e\u0447\u043a\u0443)<\/td>\n<\/tr>\n<tr>\n<td>DPD<\/td>\n<td>120<\/td>\n<\/tr>\n<tr>\n<td>DPD Maximum failure<\/td>\n<td>5<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<thead>\n<tr>\n<th>\u0412\u043a\u043b\u0430\u0434\u043a\u0430 &quot;Peers&quot;<br \/>  \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440<\/th>\n<th>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Name<\/td>\n<td>\u041d\u0430 \u0432\u0430\u0448\u0435 \u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0435 (\u0434\u0430\u043b\u0435\u0435 MyPeer)<\/td>\n<\/tr>\n<tr>\n<td>Address<\/td>\n<td>1.1.1.1 (IP linux \u043c\u0430\u0448\u0438\u043d\u044b)<\/td>\n<\/tr>\n<tr>\n<td>Local Address<\/td>\n<td>10.0.0.2 (IP WAN \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 mikrotik)<\/td>\n<\/tr>\n<tr>\n<td>Profile<\/td>\n<td>default<\/td>\n<\/tr>\n<tr>\n<td>Exchange Mode<\/td>\n<td>main<\/td>\n<\/tr>\n<tr>\n<td>Passive<\/td>\n<td>false<\/td>\n<\/tr>\n<tr>\n<td>Send INITIAL_CONTACT<\/td>\n<td>true<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<thead>\n<tr>\n<th>\u0412\u043a\u043b\u0430\u0434\u043a\u0430 &quot;Proposal&quot;<br \/>  \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440<\/th>\n<th>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Name<\/td>\n<td>\u041d\u0430 \u0432\u0430\u0448\u0435 \u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0435 (\u0434\u0430\u043b\u0435\u0435 MyPeerProposal)<\/td>\n<\/tr>\n<tr>\n<td>Auth. Algorithms<\/td>\n<td>sha512<\/td>\n<\/tr>\n<tr>\n<td>Encr. Algorithms<\/td>\n<td>aes-128-cbc<\/td>\n<\/tr>\n<tr>\n<td>Lifetime<\/td>\n<td>08:00:00<\/td>\n<\/tr>\n<tr>\n<td>PFS Group<\/td>\n<td>modp2048<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<thead>\n<tr>\n<th>\u0412\u043a\u043b\u0430\u0434\u043a\u0430 &quot;Identities&quot;<br \/>  \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440<\/th>\n<th>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Peer<\/td>\n<td>MyPeer<\/td>\n<\/tr>\n<tr>\n<td>Atuh. Method<\/td>\n<td>rsa key<\/td>\n<\/tr>\n<tr>\n<td>Key<\/td>\n<td>mikrotik.privet.key<\/td>\n<\/tr>\n<tr>\n<td>Remote Key<\/td>\n<td>server-name.pub.pem<\/td>\n<\/tr>\n<tr>\n<td>Policy Tamplate Group<\/td>\n<td>default<\/td>\n<\/tr>\n<tr>\n<td>Notrack Chain<\/td>\n<td>\u043f\u0443\u0441\u0442\u043e<\/td>\n<\/tr>\n<tr>\n<td>My ID Type<\/td>\n<td>auto<\/td>\n<\/tr>\n<tr>\n<td>Remote ID Type<\/td>\n<td>auto<\/td>\n<\/tr>\n<tr>\n<td>Match By<\/td>\n<td>remote id<\/td>\n<\/tr>\n<tr>\n<td>Mode Configuration<\/td>\n<td>\u043f\u0443\u0441\u0442\u043e<\/td>\n<\/tr>\n<tr>\n<td>Generate Policy<\/td>\n<td>no<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<thead>\n<tr>\n<th>\u0412\u043a\u043b\u0430\u0434\u043a\u0430 &quot;Policies \u2014 General&quot;<br \/>  \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440<\/th>\n<th>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Peer<\/td>\n<td>MyPeer<\/td>\n<\/tr>\n<tr>\n<td>Tunnel<\/td>\n<td>true<\/td>\n<\/tr>\n<tr>\n<td>Src. Address<\/td>\n<td>192.168.0.0\/30<\/td>\n<\/tr>\n<tr>\n<td>Dest. Address<\/td>\n<td>192.168.0.0\/30<\/td>\n<\/tr>\n<tr>\n<td>Protocol<\/td>\n<td>255 (all)<\/td>\n<\/tr>\n<tr>\n<td>Template<\/td>\n<td>false<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<thead>\n<tr>\n<th>\u0412\u043a\u043b\u0430\u0434\u043a\u0430 &quot;Policies \u2014 Action&quot;<br \/>  \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440<\/th>\n<th>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Action<\/td>\n<td>encrypt<\/td>\n<\/tr>\n<tr>\n<td>Level<\/td>\n<td>requier<\/td>\n<\/tr>\n<tr>\n<td>IPsec Protocols<\/td>\n<td>esp<\/td>\n<\/tr>\n<tr>\n<td>Proposal<\/td>\n<td>MyPeerProposal<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0420\u0435\u0441\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u0434\u0435\u043c\u043e\u043d\u0430 racoon<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">sudo systemctl restart racoon<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u0438 \u0440\u0435\u0441\u0442\u0430\u0440\u0442\u0435 racoon \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f, \u0437\u043d\u0430\u0447\u0438\u0442 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0430, \u0432 syslog racoon \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u043e\u043c\u0435\u0440\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0430.<\/p>\n<p>  <\/p>\n<p>\u0414\u0435\u043c\u043e\u043d racoon \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u041e\u0421 \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u0440\u0430\u043d\u044c\u0448\u0435 \u043f\u043e\u0434\u043d\u044f\u0442\u0438\u044f \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432, \u0430 \u043c\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0432 \u0441\u0435\u043a\u0446\u0438\u0438 listen \u043e\u043f\u0446\u0438\u044e strict_address, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0444\u0430\u0439\u043b systemd \u044e\u043d\u0438\u0442\u0430 racoon<br \/>  \/lib\/systemd\/system\/racoon.service, \u0432 \u0441\u0435\u043a\u0446\u0438\u044e [Unit], \u0441\u0442\u0440\u043e\u043a\u0443 After=network.target.<\/p>\n<p>  <\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043d\u0430\u0448\u0438 ipsec \u0442\u0443\u043d\u043d\u0435\u043b\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u0434\u043d\u044f\u0442\u044c\u0441\u044f, \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u044b\u0432\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">sudo ip xfrm policy  src 192.168.255.0\/30 dst 192.168.255.0\/30      dir out priority 2147483648      tmpl src 1.1.1.1 dst &quot;IP NAT \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f mikrotik&quot;         proto esp reqid 0 mode tunnel src 192.168.255.0\/30 dst 192.168.255.0\/30      dir fwd priority 2147483648      tmpl src &quot;IP NAT \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f mikrotik&quot; dst 1.1.1.1         proto esp reqid 0 mode tunnel src 192.168.255.0\/30 dst 192.168.255.0\/30      dir in priority 2147483648      tmpl src &quot;IP NAT \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f mikrotik&quot; dst 1.1.1.1         proto esp reqid 0 mode tunnel<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0443\u043d\u043d\u0435\u043b\u0438 \u043d\u0435 \u043f\u043e\u0434\u043d\u044f\u043b\u0438\u0441\u044c, \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 syslog, \u043b\u0438\u0431\u043e journalctl -u racoon.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c L3 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0440\u0430\u0444\u0438\u043a. \u0415\u0441\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c IPIP, \u0442\u0430\u043a \u043a\u0430\u043a \u0435\u0433\u043e mikrotik \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442, \u044f \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b vti, \u043d\u043e, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0432 mikrotik \u0435\u0433\u043e \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438. \u041e\u0442 IPIP \u043e\u043d \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c multicast \u0438 \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043c\u0435\u0442\u043a\u0438 (fwmark) \u043d\u0430 \u043f\u0430\u043a\u0435\u0442\u044b, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u0438\u0445 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0432 iptables \u0438 iproute2 (policy-based routing). \u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u2014 \u0442\u043e\u0433\u0434\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, GRE. \u041d\u043e \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0437\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043b\u0430\u0442\u0438\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043e\u0432\u0435\u0440\u0445\u0435\u0434\u043e\u043c.<\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0433\u043e \u043e\u0431\u0437\u043e\u0440\u0430 \u0442\u0443\u043d\u043d\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/457386\/\">\u0442\u0443\u0442<\/a>.<\/p>\n<p>  <\/p>\n<p><strong>\u041d\u0430 Linux:<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"bash\"># \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 sudo ip tunnel add ipip-ipsec0 local 192.168.255.1 remote 192.168.255.2 mode ipip # \u0410\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u043c sudo ip link set ipip-ipsec0 up # \u041d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u043c \u0430\u0434\u0440\u0435\u0441 sudo ip addr add 192.168.255.1\/30 dev ipip-ipsec0<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u044b \u0434\u043b\u044f \u0441\u0435\u0442\u0435\u0439 \u0437\u0430 mikrotik<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">sudo ip route add A.B.C.D\/Prefix via 192.168.255.2<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0448 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u044b \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u044c \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432 \/etc\/network\/interfaces \u0438 \u0442\u0430\u043c \u0436\u0435 \u0432 post-up \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u044b, \u043b\u0438\u0431\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0441\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \/etc\/ipip-ipsec0.conf \u0438 \u0434\u0435\u0440\u0433\u0430\u0442\u044c \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 post-up, \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043f\u0440\u043e \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0430 \u0444\u0430\u0439\u043b\u0430, \u043f\u0440\u0430\u0432\u0430 \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u043c.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">#!\/bin\/bash ip tunnel add ipip-ipsec0 local 192.168.255.1 remote 192.168.255.2 mode ipip ip link set ipip-ipsec0 up ip addr add 192.168.255.1\/30 dev ipip-ipsec0  ip route add A.B.C.D\/Prefix via 192.168.255.2<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><strong>\u041d\u0430 Mikrotik:<\/strong><\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0434\u0435\u043b \u00abInterfaces\u00bb, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u00abIP tunnel\u00bb:<\/p>\n<p>  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<thead>\n<tr>\n<th>\u0412\u043a\u0430\u043b\u0430\u0434\u043a\u0430 \u00abIP tunnel\u00bb \u2014 \u00abGeneral\u00bb<br \/>  \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440<\/th>\n<th>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Name<\/td>\n<td>\u041d\u0430 \u0432\u0430\u0448\u0435 \u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0435 (\u0434\u0430\u043b\u0435\u0435 IPIP-IPsec0)<\/td>\n<\/tr>\n<tr>\n<td>MTU<\/td>\n<td>1480 (\u0435\u0441\u043b\u0438 \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u0442\u043e mikrotik \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0435\u0437\u0430\u0442\u044c mtu \u0434\u043e 68)<\/td>\n<\/tr>\n<tr>\n<td>Local Address<\/td>\n<td>192.168.0.2<\/td>\n<\/tr>\n<tr>\n<td>Remote Address<\/td>\n<td>192.168.0.1<\/td>\n<\/tr>\n<tr>\n<td>Ipsec Secret<\/td>\n<td>\u0414\u0435\u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u043b\u0435 (\u0438\u043d\u0430\u0447\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u043d\u043e\u0432\u044b\u0439 Peer)<\/td>\n<\/tr>\n<tr>\n<td>Keepalive<\/td>\n<td>\u0414\u0435\u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u043b\u0435 (\u0438\u043d\u0430\u0447\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u0443 mikrotika \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0441\u0432\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u044d\u0442\u0438\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0438 \u0441 linux \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442)<\/td>\n<\/tr>\n<tr>\n<td>DSCP<\/td>\n<td>inherit<\/td>\n<\/tr>\n<tr>\n<td>Dont Fragment<\/td>\n<td>no<\/td>\n<\/tr>\n<tr>\n<td>Clamp TCP MSS<\/td>\n<td>true<\/td>\n<\/tr>\n<tr>\n<td>Allow Fast Path<\/td>\n<td>true<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0434\u0435\u043b \u00abIP\u00bb \u2014 \u00abAddresses\u00bb, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u0434\u0440\u0435\u0441:<\/p>\n<p>  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<thead>\n<tr>\n<th>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440<\/th>\n<th>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Address<\/td>\n<td>192.168.0.2\/30<\/td>\n<\/tr>\n<tr>\n<td>Interface<\/td>\n<td>IPIP-IPsec0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u044b \u0432 \u0441\u0435\u0442\u0438 \u0437\u0430 linux \u043c\u0430\u0448\u0438\u043d\u043e\u0439, \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430, gateway \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0448 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 IPIP-IPsec0.<\/p>\n<p>  <\/p>\n<p><strong>PS<\/strong><\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0435\u0440 linux \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0440\u0430\u043d\u0437\u0438\u0442\u043d\u044b\u043c, \u0442\u043e \u043d\u0430 \u043d\u0435\u043c \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0437\u0430\u0434\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 Clamp TCP MSS \u0434\u043b\u044f ipip \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432:<\/p>\n<p>  <\/p>\n<p>\u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b \/etc\/iptables.conf \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">*mangle -A POSTROUTING -o ipip+ -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu COMMIT<\/code><\/pre>\n<p>  <\/p>\n<p>\u0438 \u0432 \/etc\/network\/interfaces<br \/>  post-up iptables-restore &lt; \/etc\/iptables.conf<\/p>\n<p>  <\/p>\n<p>\u0412 \u0441\u0435\u0442\u0438 \u0437\u0430 mikrotik \u0443 \u043c\u0435\u043d\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 nginx (ip 10.10.10.1), \u0434\u0435\u043b\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c \u0435\u0433\u043e \u0438\u0437 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \/etc\/iptables.conf:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">*nat -A PREROUTING -d 1.1.1.1\/32 -p tcp -m multiport --dports 80,443 -j DNAT --to-destination 10.10.10.1 # \u0422\u0430\u043a \u0436\u0435 \u043d\u0430 linux \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 OpenVPN \u0441\u0435\u0440\u0432\u0435\u0440 172.16.0.1\/24, \u0434\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u043d\u0435\u043c\u0443 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0448\u043b\u044e\u0437\u0430 \u0434\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 -A POSTROUTING -s 172.16.0.0\/24 -o eth0 -j SNAT --to-source 1.1.1.1 COMMIT <\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432 iptables, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u043f\u0430\u043a\u0435\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0411\u0443\u0434\u044c\u0442\u0435 \u0437\u0434\u043e\u0440\u043e\u0432\u044b!<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/496514\/\"> https:\/\/habr.com\/ru\/post\/496514\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/496514\/\">\n<p><strong>Linux: <\/strong>Ubuntu 18.04.4 LTS (GNU\/Linux 4.15.0-91-generic x86_64)<\/p>\n<p>  <\/p>\n<ul>\n<li>Eth0 1.1.1.1\/32 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 IP<\/li>\n<li>ipip-ipsec0 192.168.0.1\/30 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0448 \u0442\u0443\u043d\u043d\u0435\u043b\u044c<\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>Miktoik: <\/strong>CCR 1009, RouterOS 6.46.5<\/p>\n<p>  <\/p>\n<ul>\n<li>Eth0 10.0.0.2\/30 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 IP \u043e\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430. \u0412\u043d\u0435\u0448\u043d\u0438\u0439 IP NAT \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439.<\/li>\n<li>ipip-ipsec0 192.168.0.2\/30 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0448 \u0442\u0443\u043d\u043d\u0435\u043b\u044c<\/li>\n<\/ul>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-301615","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301615","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=301615"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301615\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=301615"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=301615"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=301615"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}