{"id":411343,"date":"2024-06-29T21:54:47","date_gmt":"2024-06-29T21:54:47","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=411343"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=411343","title":{"rendered":"<span>GRE + IPSec \u0447\u0442\u043e\u0431\u044b \u0441\u043b\u0443\u0448\u0430\u0442\u044c multicast \u0432 \u043e\u0431\u043b\u0430\u043a\u0435<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043e\u0431\u0438\u043b\u0438\u0435 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u0440\u043e IPsec \u043d\u0430 linux, \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u043b\u0443\u0448\u0430\u0442\u044c multicast \u043d\u0430 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0432 \u043e\u0431\u043b\u0430\u043a\u0435 (\u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 AWS), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0442\u0430\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 IPSec \u0442\u043e\u043d\u043d\u0435\u043b\u044c, \u044f, \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044f\u0441\u044c \u0441 \u043a\u0430\u043a\u0438\u043c\u0438-\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c\u0438 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435, \u0436\u0430\u043b\u0435\u043b, \u0447\u0442\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u043b \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0437\u0430\u043c\u0435\u0442\u043e\u043a \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437. \u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u044f \u0440\u0435\u0448\u0438\u043b \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0438\u043c \u0441 \u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e, \u0432 \u043d\u0430\u0434\u0435\u0436\u0434\u0435, \u0447\u0442\u043e \u044d\u0442\u043e \u043a\u043e\u043c\u0443-\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u0447\u0430\u043b\u043e\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c\u0441\u044f \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u043e\u0439 (\u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0439 <em>DataCenter<\/em>) \u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 IKE (\u0444\u0430\u0437\u04301) \u0438 IPSec (\u0444\u0430\u0437\u04302), \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u0442\u044c PSK (pre-shared key) \u0444\u0440\u0430\u0437\u0443, \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043b\u0438 PFS (perfect forward secrecy), \u0432\u0430\u0448\u0438 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 IP \u0430\u0434\u0440\u0435\u0441\u0430 (peer VPN gateway), \u0432\u0430\u0448\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0434\u0441\u0435\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442\u0435 (interesting traffic), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0430\u0434\u0440\u0435\u0441\u0430\u0446\u0438\u044e \u0434\u043b\u044f GRE \u0442\u043e\u043d\u043d\u0435\u043b\u044f. \u041e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u044b\u043c \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u0430\u0435\u0442\u0435 \u043f\u043e \u043f\u043e\u0447\u0442\u0435, \u0432 \u0438\u0442\u043e\u0433\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0430 \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u0438\u0434\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/718\/47b\/d05\/71847bd0529bfbccef463858cfbaf628.png\" alt=\"\u0441\u0431\u043e\u0440\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0430 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 (\u0432\u0441\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 \u0432\u044b\u043c\u044b\u0448\u043b\u0435\u043d\u044b)\" title=\"\u0441\u0431\u043e\u0440\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0430 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 (\u0432\u0441\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 \u0432\u044b\u043c\u044b\u0448\u043b\u0435\u043d\u044b)\" width=\"732\" height=\"863\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/718\/47b\/d05\/71847bd0529bfbccef463858cfbaf628.png\"\/><\/p>\n<div><figcaption>\u0441\u0431\u043e\u0440\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0430 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 (\u0432\u0441\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 \u0432\u044b\u043c\u044b\u0448\u043b\u0435\u043d\u044b)<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043d\u0430 AWS \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0441 <em>Ubuntu 20.04.3 LTS<\/em> \u0438 <em>Linux strongSwan U5.8.2\/K5.13.0-1028-aws<\/em>.<\/p>\n<p>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f <code>ipsec.conf<\/code>:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c45\/97c\/5e0\/c4597c5e0c11faea1cda41b466caa90a.png\" alt=\"ipsec.conf \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438\" title=\"ipsec.conf \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438\" width=\"1097\" height=\"769\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c45\/97c\/5e0\/c4597c5e0c11faea1cda41b466caa90a.png\"\/><\/p>\n<div><figcaption>ipsec.conf \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0436\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0444\u0438\u043b\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 (\u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f) phase1 \u0438\u043b\u0438 phase2, \u0441\u0442\u043e\u0438\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u043e\u0441\u043a\u043b\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u043d\u0430\u043a (<code>!<\/code>) \u043f\u043e\u0441\u043b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a:<\/p>\n<p><code>ike=aes256-sha256-modp2048! # \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f IKE     esp=aes256-sha256-modp2048! # \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f ESP <\/code><\/p>\n<p>\u0414\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c ipv4 \u0442\u0440\u0430\u0444\u0438\u043a, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c:<\/p>\n<p><code>sysctl net.ipv4.ip_forward=1<\/code><\/p>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c iptables, \u0447\u0442\u043e\u0431\u044b \u0432\u0435\u0441\u044c \u0442\u0440\u0430\u0444\u0438\u043a (interesting traffic) \u043a DataCenter Remote Address (<code>100.15.30.0\/24<\/code>) \u0432\u044b\u0445\u043e\u0434\u0438\u043b \u0441 source IP <code>10.45.8.17<\/code> \u0438 , \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u0443\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u043b\u0441\u044f \u0432 IPSec \u0442\u0443\u043d\u043d\u0435\u043b\u044c \u0441\u043b\u0443\u0436\u0431\u043e\u0439 strongswan:<\/p>\n<p> <code>iptables -t nat -A POSTROUTING -d 100.15.30.0\/24 -j SNAT --to-source 10.45.8.17<\/code><\/p>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0447\u0442\u043e\u0431\u044b \u0432\u0435\u0441\u044c \u0442\u0440\u0430\u0444\u0438\u043a \u043a \u043b\u0443\u043f\u0431\u044d\u043a\u0443 GRE Tunnel source DataCenter (<code>10.44.7.1<\/code>) \u0432\u044b\u0445\u043e\u0434\u0438\u043b \u0441 source IP <code>10.44.6.1<\/code>:<\/p>\n<p><code>iptables -t nat -A POSTROUTING -d 10.44.7.1\/32 -j SNAT --to-source 10.44.6.1<\/code><\/p>\n<p>\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430 strongswan \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>ipsec restart<\/code>.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c GRE \u0442\u0443\u043d\u043d\u0435\u043b\u044c c MTU 1476 \u0438 \u043b\u0443\u043f\u0431\u044d\u043a:<\/p>\n<p><code> ip tunnel add gre1 local 10.44.6.1 remote 10.44.7.1 mode gre ttl 255<br \/> ip link set gre1 up<br \/> ip addr add 10.44.4.6\/30 dev gre1<br \/> ip link set dev gre1 mtu 1476<br \/> ip link set gre1 multicast on<\/code> \/\/ \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e, \u043d\u043e \u043f\u0443\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442<code><br \/> ifconfig gre1 pointopoint 10.44.4.5<\/code><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/53f\/d14\/1e1\/53fd141e17f5a7d2bb450b2722ed7592.png\" alt=\"\u0421\u0445\u0435\u043c\u0430 GRE \u0442\u043e\u043d\u043d\u0435\u043b\u044f\" title=\"\u0421\u0445\u0435\u043c\u0430 GRE \u0442\u043e\u043d\u043d\u0435\u043b\u044f\" width=\"995\" height=\"303\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/53f\/d14\/1e1\/53fd141e17f5a7d2bb450b2722ed7592.png\"\/><\/p>\n<div><figcaption>\u0421\u0445\u0435\u043c\u0430 GRE \u0442\u043e\u043d\u043d\u0435\u043b\u044f<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b linux \u043c\u043e\u0433 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043d\u0430 <strong>GRE keepalive<\/strong>, \u043d\u0443\u0436\u043d\u043e \u043b\u0438\u0431\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/p>\n<p><code>sysctl net.ipv4.conf.default.accept_local=1<\/code><\/p>\n<p><code>sysctl net.ipv4.conf.all.accept_local=1<\/code><\/p>\n<p>\u041b\u0438\u0431\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <a href=\"https:\/\/github.com\/Jamesits\/linux-gre-keepalive\" rel=\"noopener noreferrer nofollow\">\u0431\u043e\u043b\u0435\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u043c reply-only \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c<\/a> \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 GRE keepalive.<\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0435\u0442\u0435\u0432\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u0430\u043a\u0435\u0442 GRE keepalive \u043e\u0442 <code>10.44.7.1<\/code> \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443 <code>10.44.6.1<\/code> , \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0432 \u0441\u0435\u0431\u0435 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 \u043e\u0442 <code>10.44.6.1<\/code> \u043a <code>10.44.7.1<\/code>:<\/p>\n<p><code>tcpdump -n -vv -i eth0 proto 47<br \/> tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes<br \/> 12:53:20.976489 IP (tos 0xc0, ttl 255, id 38364, offset 0, flags [none], proto GRE (47), length 48)<br \/> 10.44.7.1 > 10.44.6.1: GREv0, Flags [none], length 28<br \/> IP (tos 0xc0, ttl 255, id 34625, offset 0, flags [none], proto GRE (47), length 24)<br \/> 10.44.6.1 > 10.44.7.1: GREv0, Flags [none], length 4<br \/> gre-proto-0x0<\/code><\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u0438\u0434\u0435\u0442\u044c \u0434\u0435\u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u0430\u043a\u0435\u0442 \u0432 \u0434\u0430\u043c\u043f\u0435 \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 gre1:<\/p>\n<p><code>tcpdump -i gre1 -n<br \/> 13:01:30.985542 IP 10.44.6.1 > 10.44.7.1: GREv0, length 4: gre-proto-0x0<\/code><\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <strong>Security Associations<\/strong> \u0432\u044b\u0432\u043e\u0434\u0430 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0434\u0435\u043c\u043e\u043d\u0430 strongswan \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0438 \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0438 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u0440\u0430\u0441\u0442\u0443\u0442:<\/p>\n<p><code>ipsec statusall<\/code> &#8212; \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 ipsec<\/p>\n<p>&#8230;<\/p>\n<p><strong>Security Associations<\/strong> (2 up, 0 connecting):<br \/> dc-tun[2]: ESTABLISHED 2 hours ago, 10.1.1.246[222.45.67.1]&#8230;177.54.214.20[177.54.214.20]<br \/> dc-tun[2]: IKEv2 SPIs: a62a46f88ff6e9c2_i* 50d27be1188d653d_r, pre-shared key reauthentication in 104 minutes<br \/> dc-tun[2]: IKE proposal: AES_CBC_256\/HMAC_SHA2_256_128\/PRF_HMAC_SHA2_256\/MODP_2048<br \/> dc-tun-gre{9}:  INSTALLED, TUNNEL, reqid 3, ESP in UDP SPIs: c9788976_i 0e1488b7_o<br \/> <strong>dc-tun-gre<\/strong>{9}:  AES_CBC_256\/HMAC_SHA2_256_128\/MODP_2048, <strong>13872 bytes_i (221 pkts, 8s ago), 3072 bytes_o (121 pkts, 10s ago)<\/strong>, rekeying in 34 minutes<br \/> dc-tun-gre{9}:   10.44.6.1\/32 === 10.44.7.1\/32<br \/> dc-tun-tcp{10}:  INSTALLED, TUNNEL, reqid 1, ESP in UDP SPIs: cb28899e_i ace88e01_o<br \/> dc-tun-tcp{10}:  AES_CBC_256\/HMAC_SHA2_256_128\/MODP_2048, 16800 bytes_i (200 pkts, 30s ago), 16800 bytes_o (200 pkts, 30s ago), rekeying in 34 minutes<br \/> dc-tun-tcp{10}:   10.45.8.17\/28 === 100.15.30.0\/24<\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0440\u0430\u0431\u043e\u0447\u0438\u0439 GRE over IPSec \u0442\u043e\u043d\u043d\u0435\u043b\u044c \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c multicast \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043d\u0430 \u043c\u0443\u043b\u044c\u0442\u0438\u043a\u0430\u0441\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e PIM, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b python \u0441\u043a\u0440\u0438\u043f\u0442, \u0432 \u043e\u0441\u043d\u043e\u0432\u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f \u0432\u0437\u044f\u043b \u0441\u043a\u0440\u0438\u043f\u0442 \u0438\u0437 <a href=\"https:\/\/stackoverflow.com\/a\/59806191\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0441\u0442\u0430\u043a\u043e\u0432\u0435\u0440\u0444\u043b\u043e\u0443<\/a>.<\/p>\n<p>\u0414\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>send_dummy_join(group, rp_addr, neighbor_ip)<\/code> \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430:<\/p>\n<p><code>group<\/code> &#8212; \u044d\u0442\u043e \u0430\u0434\u0440\u0435\u0441 \u043c\u0443\u043b\u044c\u0442\u0438\u043a\u0430\u0441\u0442 \u0433\u0440\u0443\u043f\u043f\u044b \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f<\/p>\n<p><code>rp_addr<\/code> &#8212; \u0430\u0434\u0440\u0435\u0441 Multicast Rendezvous point <code>100.15.30.253<\/code>, \u0434\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u043c \u0441\u0442\u043e\u0440\u043e\u043d\u043e\u0439 \u0414\u0426<\/p>\n<p><code>neighbor_ip<\/code> &#8212; \u0430\u0434\u0440\u0435\u0441 \u0441\u043e\u0441\u0435\u0434\u0430 (\u043f\u0438\u0440\u0430) \u043f\u043e GRE \u0442\u043e\u043d\u043d\u0435\u043b\u044e <code>10.44.4.5<\/code><\/p>\n<p>\u0414\u043b\u044f \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0443\u043b\u044c\u0442\u0438\u043a\u0430\u0441\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/manpages.ubuntu.com\/manpages\/trusty\/man8\/pimd.8.html\" rel=\"noopener noreferrer nofollow\">pimd<\/a>, \u043d\u043e \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0443\u0436\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u043e PIM, \u0442\u043e \u0441\u043e\u0432\u0435\u0442\u0443\u044e <a href=\"https:\/\/radioprog.ru\/post\/624\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e<\/a> (\u0421\u0435\u0442\u0438 \u0434\u043b\u044f \u0441\u0430\u043c\u044b\u0445 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445. \u0427\u0430\u0441\u0442\u044c 9.3. \u041c\u0443\u043b\u044c\u0442\u0438\u043a\u0430\u0441\u0442. \u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b PIM).<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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\/articles\/726426\/\"> https:\/\/habr.com\/ru\/articles\/726426\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043e\u0431\u0438\u043b\u0438\u0435 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u0440\u043e IPsec \u043d\u0430 linux, \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u043b\u0443\u0448\u0430\u0442\u044c multicast \u043d\u0430 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0432 \u043e\u0431\u043b\u0430\u043a\u0435 (\u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 AWS), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0442\u0430\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 IPSec \u0442\u043e\u043d\u043d\u0435\u043b\u044c, \u044f, \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044f\u0441\u044c \u0441 \u043a\u0430\u043a\u0438\u043c\u0438-\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c\u0438 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435, \u0436\u0430\u043b\u0435\u043b, \u0447\u0442\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u043b \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0437\u0430\u043c\u0435\u0442\u043e\u043a \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437. \u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u044f \u0440\u0435\u0448\u0438\u043b \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0438\u043c \u0441 \u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e, \u0432 \u043d\u0430\u0434\u0435\u0436\u0434\u0435, \u0447\u0442\u043e \u044d\u0442\u043e \u043a\u043e\u043c\u0443-\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u0447\u0430\u043b\u043e\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c\u0441\u044f \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u043e\u0439 (\u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0439 <em>DataCenter<\/em>) \u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 IKE (\u0444\u0430\u0437\u04301) \u0438 IPSec (\u0444\u0430\u0437\u04302), \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u0442\u044c PSK (pre-shared key) \u0444\u0440\u0430\u0437\u0443, \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043b\u0438 PFS (perfect forward secrecy), \u0432\u0430\u0448\u0438 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 IP \u0430\u0434\u0440\u0435\u0441\u0430 (peer VPN gateway), \u0432\u0430\u0448\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0434\u0441\u0435\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442\u0435 (interesting traffic), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0430\u0434\u0440\u0435\u0441\u0430\u0446\u0438\u044e \u0434\u043b\u044f GRE \u0442\u043e\u043d\u043d\u0435\u043b\u044f. \u041e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u044b\u043c \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u0430\u0435\u0442\u0435 \u043f\u043e \u043f\u043e\u0447\u0442\u0435, \u0432 \u0438\u0442\u043e\u0433\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0430 \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u0438\u0434\u0430:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0441\u0431\u043e\u0440\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0430 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 (\u0432\u0441\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 \u0432\u044b\u043c\u044b\u0448\u043b\u0435\u043d\u044b)<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043d\u0430 AWS \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0441 <em>Ubuntu 20.04.3 LTS<\/em> \u0438 <em>Linux strongSwan U5.8.2\/K5.13.0-1028-aws<\/em>.<\/p>\n<p>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f <code>ipsec.conf<\/code>:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>ipsec.conf \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0436\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0444\u0438\u043b\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 (\u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f) phase1 \u0438\u043b\u0438 phase2, \u0441\u0442\u043e\u0438\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u043e\u0441\u043a\u043b\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u043d\u0430\u043a (<code>!<\/code>) \u043f\u043e\u0441\u043b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a:<\/p>\n<p><code>ike=aes256-sha256-modp2048! # \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f IKE     esp=aes256-sha256-modp2048! # \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f ESP <\/code><\/p>\n<p>\u0414\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c ipv4 \u0442\u0440\u0430\u0444\u0438\u043a, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c:<\/p>\n<p><code>sysctl net.ipv4.ip_forward=1<\/code><\/p>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c iptables, \u0447\u0442\u043e\u0431\u044b \u0432\u0435\u0441\u044c \u0442\u0440\u0430\u0444\u0438\u043a (interesting traffic) \u043a DataCenter Remote Address (<code>100.15.30.0\/24<\/code>) \u0432\u044b\u0445\u043e\u0434\u0438\u043b \u0441 source IP <code>10.45.8.17<\/code> \u0438 , \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u0443\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u043b\u0441\u044f \u0432 IPSec \u0442\u0443\u043d\u043d\u0435\u043b\u044c \u0441\u043b\u0443\u0436\u0431\u043e\u0439 strongswan:<\/p>\n<p> <code>iptables -t nat -A POSTROUTING -d 100.15.30.0\/24 -j SNAT --to-source 10.45.8.17<\/code><\/p>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0447\u0442\u043e\u0431\u044b \u0432\u0435\u0441\u044c \u0442\u0440\u0430\u0444\u0438\u043a \u043a \u043b\u0443\u043f\u0431\u044d\u043a\u0443 GRE Tunnel source DataCenter (<code>10.44.7.1<\/code>) \u0432\u044b\u0445\u043e\u0434\u0438\u043b \u0441 source IP <code>10.44.6.1<\/code>:<\/p>\n<p><code>iptables -t nat -A POSTROUTING -d 10.44.7.1\/32 -j SNAT --to-source 10.44.6.1<\/code><\/p>\n<p>\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430 strongswan \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>ipsec restart<\/code>.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c GRE \u0442\u0443\u043d\u043d\u0435\u043b\u044c c MTU 1476 \u0438 \u043b\u0443\u043f\u0431\u044d\u043a:<\/p>\n<p><code> ip tunnel add gre1 local 10.44.6.1 remote 10.44.7.1 mode gre ttl 255<br \/> ip link set gre1 up<br \/> ip addr add 10.44.4.6\/30 dev gre1<br \/> ip link set dev gre1 mtu 1476<br \/> ip link set gre1 multicast on<\/code> \/\/ \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e, \u043d\u043e \u043f\u0443\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442<code><br \/> ifconfig gre1 pointopoint 10.44.4.5<\/code><\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u0445\u0435\u043c\u0430 GRE \u0442\u043e\u043d\u043d\u0435\u043b\u044f<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b linux \u043c\u043e\u0433 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043d\u0430 <strong>GRE keepalive<\/strong>, \u043d\u0443\u0436\u043d\u043e \u043b\u0438\u0431\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/p>\n<p><code>sysctl net.ipv4.conf.default.accept_local=1<\/code><\/p>\n<p><code>sysctl net.ipv4.conf.all.accept_local=1<\/code><\/p>\n<p>\u041b\u0438\u0431\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <a href=\"https:\/\/github.com\/Jamesits\/linux-gre-keepalive\" rel=\"noopener noreferrer nofollow\">\u0431\u043e\u043b\u0435\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u043c reply-only \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c<\/a> \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 GRE keepalive.<\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0435\u0442\u0435\u0432\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u0430\u043a\u0435\u0442 GRE keepalive \u043e\u0442 <code>10.44.7.1<\/code> \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443 <code>10.44.6.1<\/code> , \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0432 \u0441\u0435\u0431\u0435 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 \u043e\u0442 <code>10.44.6.1<\/code> \u043a <code>10.44.7.1<\/code>:<\/p>\n<p><code>tcpdump -n -vv -i eth0 proto 47<br \/> tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes<br \/> 12:53:20.976489 IP (tos 0xc0, ttl 255, id 38364, offset 0, flags [none], proto GRE (47), length 48)<br \/> 10.44.7.1 > 10.44.6.1: GREv0, Flags [none], length 28<br \/> IP (tos 0xc0, ttl 255, id 34625, offset 0, flags [none], proto GRE (47), length 24)<br \/> 10.44.6.1 > 10.44.7.1: GREv0, Flags [none], length 4<br \/> gre-proto-0x0<\/code><\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u0438\u0434\u0435\u0442\u044c \u0434\u0435\u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u0430\u043a\u0435\u0442 \u0432 \u0434\u0430\u043c\u043f\u0435 \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 gre1:<\/p>\n<p><code>tcpdump -i gre1 -n<br \/> 13:01:30.985542 IP 10.44.6.1 > 10.44.7.1: GREv0, length 4: gre-proto-0x0<\/code><\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <strong>Security Associations<\/strong> \u0432\u044b\u0432\u043e\u0434\u0430 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0434\u0435\u043c\u043e\u043d\u0430 strongswan \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0438 \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0438 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u0440\u0430\u0441\u0442\u0443\u0442:<\/p>\n<p><code>ipsec statusall<\/code> &#8212; \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 ipsec<\/p>\n<p>&#8230;<\/p>\n<p><strong>Security Associations<\/strong> (2 up, 0 connecting):<br \/> dc-tun[2]: ESTABLISHED 2 hours ago, 10.1.1.246[222.45.67.1]&#8230;177.54.214.20[177.54.214.20]<br \/> dc-tun[2]: IKEv2 SPIs: a62a46f88ff6e9c2_i* 50d27be1188d653d_r, pre-shared key reauthentication in 104 minutes<br \/> dc-tun[2]: IKE proposal: AES_CBC_256\/HMAC_SHA2_256_128\/PRF_HMAC_SHA2_256\/MODP_2048<br \/> dc-tun-gre{9}:  INSTALLED, TUNNEL, reqid 3, ESP in UDP SPIs: c9788976_i 0e1488b7_o<br \/> <strong>dc-tun-gre<\/strong>{9}:  AES_CBC_256\/HMAC_SHA2_256_128\/MODP_2048, <strong>13872 bytes_i (221 pkts, 8s ago), 3072 bytes_o (121 pkts, 10s ago)<\/strong>, rekeying in 34 minutes<br \/> dc-tun-gre{9}:   10.44.6.1\/32 === 10.44.7.1\/32<br \/> dc-tun-tcp{10}:  INSTALLED, TUNNEL, reqid 1, ESP in UDP SPIs: cb28899e_i ace88e01_o<br \/> dc-tun-tcp{10}:  AES_CBC_256\/HMAC_SHA2_256_128\/MODP_2048, 16800 bytes_i (200 pkts, 30s ago), 16800 bytes_o (200 pkts, 30s ago), rekeying in 34 minutes<br \/> dc-tun-tcp{10}:   10.45.8.17\/28 === 100.15.30.0\/24<\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0440\u0430\u0431\u043e\u0447\u0438\u0439 GRE over IPSec \u0442\u043e\u043d\u043d\u0435\u043b\u044c \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c multicast \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043d\u0430 \u043c\u0443\u043b\u044c\u0442\u0438\u043a\u0430\u0441\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e PIM, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b python \u0441\u043a\u0440\u0438\u043f\u0442, \u0432 \u043e\u0441\u043d\u043e\u0432\u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f \u0432\u0437\u044f\u043b \u0441\u043a\u0440\u0438\u043f\u0442 \u0438\u0437 <a href=\"https:\/\/stackoverflow.com\/a\/59806191\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0441\u0442\u0430\u043a\u043e\u0432\u0435\u0440\u0444\u043b\u043e\u0443<\/a>.<\/p>\n<p>\u0414\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>send_dummy_join(group, rp_addr, neighbor_ip)<\/code> \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430:<\/p>\n<p><code>group<\/code> &#8212; \u044d\u0442\u043e \u0430\u0434\u0440\u0435\u0441 \u043c\u0443\u043b\u044c\u0442\u0438\u043a\u0430\u0441\u0442 \u0433\u0440\u0443\u043f\u043f\u044b \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f<\/p>\n<p><code>rp_addr<\/code> &#8212; \u0430\u0434\u0440\u0435\u0441 Multicast Rendezvous point <code>100.15.30.253<\/code>, \u0434\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u043c \u0441\u0442\u043e\u0440\u043e\u043d\u043e\u0439 \u0414\u0426<\/p>\n<p><code>neighbor_ip<\/code> &#8212; \u0430\u0434\u0440\u0435\u0441 \u0441\u043e\u0441\u0435\u0434\u0430 (\u043f\u0438\u0440\u0430) \u043f\u043e GRE \u0442\u043e\u043d\u043d\u0435\u043b\u044e <code>10.44.4.5<\/code><\/p>\n<p>\u0414\u043b\u044f \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0443\u043b\u044c\u0442\u0438\u043a\u0430\u0441\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/manpages.ubuntu.com\/manpages\/trusty\/man8\/pimd.8.html\" rel=\"noopener noreferrer nofollow\">pimd<\/a>, \u043d\u043e \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0443\u0436\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u043e PIM, \u0442\u043e \u0441\u043e\u0432\u0435\u0442\u0443\u044e <a href=\"https:\/\/radioprog.ru\/post\/624\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e<\/a> (\u0421\u0435\u0442\u0438 \u0434\u043b\u044f \u0441\u0430\u043c\u044b\u0445 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445. \u0427\u0430\u0441\u0442\u044c 9.3. \u041c\u0443\u043b\u044c\u0442\u0438\u043a\u0430\u0441\u0442. \u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b PIM).<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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\/articles\/726426\/\"> https:\/\/habr.com\/ru\/articles\/726426\/<\/a><br \/><\/br><\/br><\/p>\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-411343","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/411343","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=411343"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/411343\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=411343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=411343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=411343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}