{"id":2618,"date":"2021-10-14T20:09:43","date_gmt":"2021-10-15T03:09:43","guid":{"rendered":"https:\/\/www.xh86.me\/?p=2618"},"modified":"2021-10-14T20:09:43","modified_gmt":"2021-10-15T03:09:43","slug":"routeros%e5%9c%a8%e4%b8%80%e7%ab%af%e5%8a%a8%e6%80%81ip%e6%83%85%e5%86%b5%e4%b8%8b%e9%85%8d%e7%bd%aegre-over-ipsec-vpn","status":"publish","type":"post","link":"https:\/\/www.xh86.me\/?p=2618","title":{"rendered":"RouterOS\u5728\u4e00\u7aef\u52a8\u6001IP\u60c5\u51b5\u4e0b\u914d\u7f6eGRE over IPSec VPN"},"content":{"rendered":"<p>PSec\u6709\u4e24\u79cd\u6a21\u5f0f\uff1atransport\u548ctunnel\u3002Transport\u6a21\u5f0f\u53cc\u65b9\u4ecd\u7136\u4f7f\u7528\u5404\u81ea\u7684\u516c\u7f51IP\u4e92\u8054\uff0c\u53ea\u4e0d\u8fc7\u4f20\u9001\u7684\u6570\u636e\u4f1a\u88ab\u81ea\u52a8\u52a0\u5bc6\uff0c\u5fc5\u987b\u4e24\u7aef\u7684IP\u56fa\u5b9a\uff08\u5426\u5219\u670d\u52a1\u5668\u7aef\u4e5f\u8981\u52a8\u6001\u66f4\u65b0\u5ba2\u6237\u7aefIP\uff09\uff0ctunnel\u6a21\u5f0f\u5219\u662f\u5efa\u7acb\u4e00\u4e2a\u7c7b\u4f3cVPN\u7684\u70b9\u5bf9\u70b9\u901a\u9053\uff0c\u9700\u8981\u7ed9\u901a\u9053\u5206\u914d\u5185\u7f51IP\uff0c\u5728\u516c\u7f51IP\u7684\u8981\u6c42\u4e0a\u5219\u76f8\u5bf9\u6bd4\u8f83\u5bbd\u677e\uff08\u53ea\u9700\u8981\u5ba2\u6237\u7aef\u66f4\u65b0\u81ea\u5df1\u7684IP\uff09\uff0c\u7f3a\u70b9\u662f\u6d6a\u8d3920MTU\uff0c\u4f20\u8f93\u6548\u7387\u7a0d\u4f4e\u3002\u672c\u6587\u8bb2\u89e3\u5982\u4f55\u914d\u7f6eIPSec tunnel\u8fde\u63a5\uff0c\u4ee5\u53ca\u5728\u5176\u4e0a\u914d\u7f6e\u4e00\u4e2aGRE\u96a7\u9053\u3002<\/p>\n<p>&nbsp;<\/p>\n<h1>\u914d\u7f6eIPSec<\/h1>\n<p>\u8fd9\u91cc\u6211\u4eec\u7edf\u4e00\u628a\u56fa\u5b9aIP\u7684\u4e00\u4fa7\u53eb\u505a\u670d\u52a1\u7aef\uff0c\u52a8\u6001IP\u7684\u4e00\u4fa7\u53eb\u505a\u5ba2\u6237\u7aef\u3002\u9700\u8981\u51c6\u5907\u4e24\u7ec4IP\u5730\u5740\uff1a<\/p>\n<ul>\n<li>\u670d\u52a1\u7aef\u7684\u516c\u7f51IP<\/li>\n<li>\u5ba2\u6237\u7aef\u5f53\u524d\u7684\u516c\u7f51IP<\/li>\n<li>\u670d\u52a1\u7aef\u7684\u96a7\u9053\u5185\u7f51IP<\/li>\n<li>\u5ba2\u6237\u7aef\u7684\u96a7\u9053\u5185\u7f51IP\uff08\u5982\u679c\u4f60\u6709\u591a\u4e2a\u5ba2\u6237\u7aef\uff0c\u5728\u670d\u52a1\u5668\u90a3\u4fa7\u53ef\u4ee5\u586b\u5199\u4e00\u4e2aIP\u6bb5\uff1b\u800c\u5bf9\u4e8e\u6bcf\u53f0\u5ba2\u6237\u7aef\u9700\u8981\u586b\u5199\u51c6\u786eIP\uff09<\/li>\n<\/ul>\n<p>\u6ce8\uff1a\u8bf7\u4e0d\u8981\u628a\u8fd9\u91cc\u6240\u8ff0\u96a7\u9053\u5185\u7f51IP\u6bb5\u52a0\u5165OSPF\u7b49\u52a8\u6001\u8def\u7531\u534f\u8bae\u7684\u7f51\u6bb5\u3002\u5982\u679c\u9700\u8981\u8dd1\u52a8\u6001\u8def\u7531\u534f\u8bae\uff0c\u53ef\u4ee5\u5728GRE\u96a7\u9053\u4e0a\u53e6\u914d\u4e00\u7ec4IP\u3002<\/p>\n<p>\u5728\u5efa\u7acb\u5b8cIPSec\u96a7\u9053\u4ee5\u540e\uff0c\u4e24\u53f0\u8bbe\u5907\u5c31\u53ef\u4ee5\u4f7f\u7528\u8fd9\u91cc\u89c4\u5b9a\u7684\u5185\u7f51IP\u4e92\u76f8\u901a\u4fe1\uff08\u5373\u5efa\u7acbVPN\uff09\u4e86\u3002<\/p>\n<h2>\u670d\u52a1\u7aef<\/h2>\n<p>&nbsp;<\/p>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670\" class=\"urvanov-syntax-highlighter-syntax crayon-theme-classic urvanov-syntax-highlighter-font-monaco urvanov-syntax-highlighter-os-mac print-yes notranslate\" data-settings=\" minimize scroll-mouseover\">\n<div class=\"crayon-toolbar\" data-settings=\" show\">\n<div class=\"crayon-tools\">\n<div class=\"crayon-button urvanov-syntax-highlighter-nums-button crayon-pressed\" title=\"\u5207\u6362\u662f\u5426\u663e\u793a\u884c\u7f16\u53f7\">\n<div class=\"urvanov-syntax-highlighter-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button urvanov-syntax-highlighter-plain-button\" title=\"\u7eaf\u6587\u672c\u663e\u793a\u4ee3\u7801\">\n<div class=\"urvanov-syntax-highlighter-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button urvanov-syntax-highlighter-wrap-button\" title=\"\u5207\u6362\u81ea\u52a8\u6362\u884c\">\n<div class=\"urvanov-syntax-highlighter-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button urvanov-syntax-highlighter-expand-button\" title=\"\u70b9\u51fb\u5c55\u5f00\u4ee3\u7801\">\n<div class=\"urvanov-syntax-highlighter-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button urvanov-syntax-highlighter-copy-button\" title=\"\u590d\u5236\u4ee3\u7801\">\n<div class=\"urvanov-syntax-highlighter-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button urvanov-syntax-highlighter-popup-button\" title=\"\u5728\u65b0\u7a97\u53e3\u4e2d\u663e\u793a\u4ee3\u7801\">\n<div class=\"urvanov-syntax-highlighter-button-icon\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"urvanov-syntax-highlighter-plain-wrap\"><\/div>\n<div class=\"urvanov-syntax-highlighter-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"urvanov-syntax-highlighter-row\">\n<td class=\"crayon-nums \" data-settings=\"show\">\n<div class=\"urvanov-syntax-highlighter-nums-content\">\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-1\">1<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-2\">2<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-3\">3<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-4\">4<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-5\">5<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-6\">6<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-7\">7<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-8\">8<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-9\">9<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-10\">10<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-11\">11<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-12\">12<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-13\">13<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-14\">14<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-15\">15<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-16\">16<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-17\">17<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-18\">18<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-19\">19<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-20\">20<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-21\">21<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-22\">22<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-23\">23<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-24\">24<\/div>\n<\/div>\n<\/td>\n<td class=\"urvanov-syntax-highlighter-code\">\n<div class=\"crayon-pre\">\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-1\" class=\"crayon-line\"># \u7981\u6b62 IPSec \u96a7\u9053\u5185\u90e8\u6d41\u91cf\u88ab NAT<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-2\" class=\"crayon-line crayon-striped-line\"># \uff08\u4ec5 RouterOS 6.42 \u4e4b\u524d\uff09<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-3\" class=\"crayon-line\">\/ip firewall nat add action=return chain=srcnat comment=&#8221;IPSec Roadwarrior&#8221; src-address=&lt;\u670d\u52a1\u5668\u96a7\u9053\u5185\u7f51 IP \u6bb5&gt; dst-address=&lt;\u5ba2\u6237\u7aef\u96a7\u9053\u5185\u7f51 IP&gt; place-before=0<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-4\" class=\"crayon-line crayon-striped-line\"><\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-5\" class=\"crayon-line\"># \u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684 policy group\uff0c \u540d\u5b57\u968f\u4fbf\u53d6\uff0c\u7528\u9ed8\u8ba4\u90a3\u4e2a default \u4e5f\u884c<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-6\" class=\"crayon-line crayon-striped-line\">\/ip ipsec policy group add name=internal<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-7\" class=\"crayon-line\"><\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-8\" class=\"crayon-line crayon-striped-line\"># \u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684 proposal\uff0c\u89c4\u5b9a\u52a0\u5bc6\u65b9\u5f0f<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-9\" class=\"crayon-line\">\/ip ipsec proposal add auth-algorithms=sha256 enc-algorithms=aes-128-cbc name=internal pfs-group=modp3072<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-10\" class=\"crayon-line crayon-striped-line\"><\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-11\" class=\"crayon-line\"># \u6dfb\u52a0\u4e00\u4e2a\u901a\u914d\u7b26 peer<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-12\" class=\"crayon-line crayon-striped-line\"># 6.42 \u4e4b\u524d<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-13\" class=\"crayon-line\">\/ip ipsec peer add dh-group=modp3072 enc-algorithm=aes-128 exchange-mode=ike2 generate-policy=port-strict hash-algorithm=sha256 policy-template-group=internal secret=&lt;\u5bc6\u7801&gt;<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-14\" class=\"crayon-line crayon-striped-line\"># 6.42 \u4e4b\u540e<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-15\" class=\"crayon-line\">\/ip ipsec peer add dh-group=modp3072 enc-algorithm=aes-128 exchange-mode=ike2 generate-policy=port-strict hash-algorithm=sha256 policy-template-group=internal notrack-chain=prerouting secret=&lt;\u5bc6\u7801&gt;<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-16\" class=\"crayon-line crayon-striped-line\"># \u7981\u7528\u9ed8\u8ba4\u7684 policy \u6a21\u677f<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-17\" class=\"crayon-line\">\/ip ipsec policy set 0 disabled=yes<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-18\" class=\"crayon-line crayon-striped-line\"><\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-19\" class=\"crayon-line\"># \u6dfb\u52a0\u4e00\u4e2a policy \u6a21\u677f<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-20\" class=\"crayon-line crayon-striped-line\">\/ip ipsec policy add dst-address=&lt;\u5ba2\u6237\u7aef\u96a7\u9053\u5185\u7f51 IP \u6bb5&gt; group=internal proposal=internal protocol=gre src-address=&lt;\u670d\u52a1\u5668\u96a7\u9053\u5185\u7f51 IP&gt; template=yes<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-21\" class=\"crayon-line\"><\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-22\" class=\"crayon-line crayon-striped-line\"># \u5982\u679c\u670d\u52a1\u5668\u96a7\u9053\u5185\u7f51 IP \u5730\u5740\u5728 \/ip addr \u91cc\u9762\u6ca1\u6709\u7684\u8bdd\uff0c\u9700\u8981\u624b\u5de5\u914d\u7f6e\u5230\u4e00\u4e2a loopback \u7aef\u53e3\u4e0a<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-23\" class=\"crayon-line\">\/interface bridge add name=lo<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ab9176730670-24\" class=\"crayon-line crayon-striped-line\">\/ip addr add address=&lt;\u670d\u52a1\u5668\u96a7\u9053\u5185\u7f51 IP&gt; interface=lo<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<h2>\u5ba2\u6237\u7aef<\/h2>\n<p>&nbsp;<\/p>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484\" class=\"urvanov-syntax-highlighter-syntax crayon-theme-classic urvanov-syntax-highlighter-font-monaco urvanov-syntax-highlighter-os-mac print-yes notranslate\" data-settings=\" minimize scroll-mouseover\">\n<div class=\"crayon-toolbar\" data-settings=\" show\">\n<div class=\"crayon-tools\">\n<div class=\"crayon-button urvanov-syntax-highlighter-nums-button crayon-pressed\" title=\"\u5207\u6362\u662f\u5426\u663e\u793a\u884c\u7f16\u53f7\">\n<div class=\"urvanov-syntax-highlighter-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button urvanov-syntax-highlighter-plain-button\" title=\"\u7eaf\u6587\u672c\u663e\u793a\u4ee3\u7801\">\n<div class=\"urvanov-syntax-highlighter-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button urvanov-syntax-highlighter-wrap-button\" title=\"\u5207\u6362\u81ea\u52a8\u6362\u884c\">\n<div class=\"urvanov-syntax-highlighter-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button urvanov-syntax-highlighter-expand-button\" title=\"\u70b9\u51fb\u5c55\u5f00\u4ee3\u7801\">\n<div class=\"urvanov-syntax-highlighter-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button urvanov-syntax-highlighter-copy-button\" title=\"\u590d\u5236\u4ee3\u7801\">\n<div class=\"urvanov-syntax-highlighter-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button urvanov-syntax-highlighter-popup-button\" title=\"\u5728\u65b0\u7a97\u53e3\u4e2d\u663e\u793a\u4ee3\u7801\">\n<div class=\"urvanov-syntax-highlighter-button-icon\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"urvanov-syntax-highlighter-plain-wrap\"><\/div>\n<div class=\"urvanov-syntax-highlighter-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"urvanov-syntax-highlighter-row\">\n<td class=\"crayon-nums \" data-settings=\"show\">\n<div class=\"urvanov-syntax-highlighter-nums-content\">\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-1\">1<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-2\">2<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-3\">3<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-4\">4<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-5\">5<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-6\">6<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-7\">7<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-8\">8<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-9\">9<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-10\">10<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-11\">11<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-12\">12<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-13\">13<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-14\">14<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-15\">15<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-16\">16<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-17\">17<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-18\">18<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-19\">19<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-20\">20<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-21\">21<\/div>\n<\/div>\n<\/td>\n<td class=\"urvanov-syntax-highlighter-code\">\n<div class=\"crayon-pre\">\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-1\" class=\"crayon-line\"># \u7981\u6b62 IPSec \u96a7\u9053\u5185\u90e8\u6d41\u91cf\u88ab NAT<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-2\" class=\"crayon-line crayon-striped-line\"># \uff08\u4ec5 RouterOS 6.42 \u4e4b\u524d\uff09<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-3\" class=\"crayon-line\">\/ip firewall nat add action=return chain=srcnat comment=&#8221;IPSec Roadwarrior&#8221; src-address=&lt;\u5ba2\u6237\u7aef\u96a7\u9053\u5185\u7f51 IP&gt; dst-address=&lt;\u670d\u52a1\u5668\u96a7\u9053\u5185\u7f51 IP&gt; place-before=0<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-4\" class=\"crayon-line crayon-striped-line\"><\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-5\" class=\"crayon-line\"># \u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684 policy group\uff08\u5176\u5b9e\u9ed8\u8ba4\u7684\u90a3\u4e2a\u4e5f\u884c\uff09<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-6\" class=\"crayon-line crayon-striped-line\">\/ip ipsec policy group add name=internal<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-7\" class=\"crayon-line\"><\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-8\" class=\"crayon-line crayon-striped-line\"># \u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684 proposal<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-9\" class=\"crayon-line\">\/ip ipsec proposal add auth-algorithms=sha256 enc-algorithms=aes-128-cbc name=internal pfs-group=modp3072<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-10\" class=\"crayon-line crayon-striped-line\"><\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-11\" class=\"crayon-line\"># \u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684 peer<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-12\" class=\"crayon-line crayon-striped-line\"># RouterOS 6.42 \u4ee5\u524d\uff1a<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-13\" class=\"crayon-line\">\/ip ipsec peer add address=&lt;\u670d\u52a1\u5668\u516c\u7f51 IP&gt; dh-group=modp3072 enc-algorithm=aes-128 exchange-mode=ike2 hash-algorithm=sha256 policy-template-group=internal secret=&lt;\u5bc6\u7801&gt;<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-14\" class=\"crayon-line crayon-striped-line\"># 6.42 \u4ee5\u540e\uff08\u53ef\u4ee5\u5728\u8fd9\u91cc\u76f4\u63a5\u7ed5\u8fc7 NAT\uff0c\u4e0d\u9700\u8981\u663e\u5f0f\u589e\u52a0\u9632\u706b\u5899\u89c4\u5219\uff09<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-15\" class=\"crayon-line\">\/ip ipsec peer add address=&lt;\u670d\u52a1\u5668\u516c\u7f51 IP&gt; dh-group=modp3072 enc-algorithm=aes-128 exchange-mode=ike2 hash-algorithm=sha256 policy-template-group=internal notrack-chain=prerouting secret=&lt;\u5bc6\u7801&gt;<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-16\" class=\"crayon-line crayon-striped-line\"># \u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684 policy<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-17\" class=\"crayon-line\">\/ip ipsec policy add dst-address=&lt;\u670d\u52a1\u5668\u7684\u96a7\u9053\u5185\u7f51 IP&gt; proposal=internal protocol=gre sa-dst-address=&lt;\u670d\u52a1\u5668\u7684\u516c\u7f51 IP&gt; sa-src-address=&lt;\u4f60\u7684\u516c\u7f51 IP&gt; src-address=&lt;\u4f60\u7684\u96a7\u9053\u5185\u7f51 IP&gt; tunnel=yes<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-18\" class=\"crayon-line crayon-striped-line\"><\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-19\" class=\"crayon-line\"># \u5982\u679c\u5ba2\u6237\u7aef\u96a7\u9053\u5185\u7f51 IP \u5730\u5740\u5728 \/ip addr \u91cc\u9762\u6ca1\u6709\u7684\u8bdd\uff0c\u9700\u8981\u624b\u5de5\u914d\u7f6e\u5230\u4e00\u4e2a loopback \u7aef\u53e3\u4e0a<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-20\" class=\"crayon-line crayon-striped-line\">\/interface bridge add name=lo<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ad5052728484-21\" class=\"crayon-line\">\/ip addr add address=&lt;\u5ba2\u6237\u7aef\u96a7\u9053\u5185\u7f51 IP&gt; interface=lo<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u5b8c\u6210\u4ee5\u4e0a\u4e24\u90e8\u5206\u8bbe\u7f6e\u4ee5\u540e\uff0c\u5728\u4efb\u610f\u4e00\u4fa7\u7684IPSec Policies\u91cc\u5e94\u8be5\u53ef\u4ee5\u770b\u5230\u4e00\u6761\u8fde\u63a5\uff0cPH2 state\u4e3aestablished\uff0c\u8868\u793aIPSec\u63e1\u624b\u6210\u529f\u3002<\/p>\n<p>\u6ce8\uff1a<\/p>\n<ul>\n<li>\u5982\u679c\u4f60\u4f7f\u7528\u56fe\u5f62\u754c\u9762\u65b9\u5f0f\u6765\u8bbe\u7f6e\u7684\u8bdd\uff0c\u5728\u6dfb\u52a0policy\u65f6protocol\u8bf7\u586b\u5165\u6570\u5b5747\uff08GRE\u534f\u8bae\u53f7\uff09\uff1b<\/li>\n<li>\u5982\u679c\u4f60\u5728\u914d\u7f6e\u4e4b\u524d\u5df2\u6709\u5bf9\u8be5\u5185\u7f51\u7f51\u6bb5\u7684NAT\u89c4\u5219\u5e76\u4e14\u6709\u8bbe\u5907\u5c1d\u8bd5\u8fde\u63a5\u8fc7\u8be5IP\uff0cNAT\u89c4\u5219\u53ef\u80fd\u5df2\u88abconntrack\u7f13\u5b58\uff1b\u6b64\u65f6\u4f1a\u51fa\u73b0IPSec Policy\u663e\u793aestablished\u4f46\u662fGRE\u96a7\u9053\u4e0d\u901a\u7684\u60c5\u51b5\u3002\u6e05\u7a7aconntrack\u7f13\u5b58\u6216\u8005\u91cd\u542f\u8def\u7531\u5668\u5373\u53ef\u89e3\u51b3\u3002<\/li>\n<\/ul>\n<h2>IPSec\u8c03\u8bd5<\/h2>\n<div id=\"urvanov-syntax-highlighter-6168ed5297adf269753543\" class=\"urvanov-syntax-highlighter-syntax crayon-theme-classic urvanov-syntax-highlighter-font-monaco urvanov-syntax-highlighter-os-mac print-yes notranslate\" data-settings=\" minimize scroll-mouseover\">\n<div class=\"urvanov-syntax-highlighter-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"urvanov-syntax-highlighter-row\">\n<td class=\"crayon-nums \" data-settings=\"show\">\n<div class=\"urvanov-syntax-highlighter-nums-content\">\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297adf269753543-1\">1<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297adf269753543-2\">2<\/div>\n<\/div>\n<\/td>\n<td class=\"urvanov-syntax-highlighter-code\">\n<div class=\"crayon-pre\">\n<div id=\"urvanov-syntax-highlighter-6168ed5297adf269753543-1\" class=\"crayon-line\"><span class=\"crayon-o\">\/<\/span><span class=\"crayon-e\">system <\/span><span class=\"crayon-e\">logging<\/span><\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297adf269753543-2\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-e\">add <\/span><span class=\"crayon-v\">topics<\/span><span class=\"crayon-o\">=<\/span><span class=\"crayon-v\">ipsec<\/span><span class=\"crayon-sy\">,<\/span><span class=\"crayon-o\">!<\/span><span class=\"crayon-e\">debug <\/span><span class=\"crayon-v\">action<\/span><span class=\"crayon-o\">=<\/span><span class=\"crayon-v\">memory<\/span><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h2>\u5ba2\u6237\u7aef\u52a8\u6001\u66f4\u65b0IP<\/h2>\n<p>\u628a\u4ee5\u4e0b\u811a\u672c\u4f5c\u4e3a\u4f60PPPoE\u62e8\u53f7\u7aef\u53e3\u5bf9\u5e94PPP Profile\u7684On Up\u89e6\u53d1\u811a\u672c\u3002<\/p>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ae6356948700\" class=\"urvanov-syntax-highlighter-syntax crayon-theme-classic urvanov-syntax-highlighter-font-monaco urvanov-syntax-highlighter-os-mac print-yes notranslate\" data-settings=\" minimize scroll-mouseover\">\n<div class=\"crayon-toolbar\" data-settings=\" show\">\n<div class=\"crayon-tools\">\n<div class=\"crayon-button urvanov-syntax-highlighter-nums-button crayon-pressed\" title=\"\u5207\u6362\u662f\u5426\u663e\u793a\u884c\u7f16\u53f7\">\n<div class=\"urvanov-syntax-highlighter-button-icon\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"urvanov-syntax-highlighter-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"urvanov-syntax-highlighter-row\">\n<td class=\"crayon-nums \" data-settings=\"show\">\n<div class=\"urvanov-syntax-highlighter-nums-content\">\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-1\">1<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-2\">2<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-3\">3<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-4\">4<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-5\">5<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-6\">6<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-7\">7<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-8\">8<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-9\">9<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-10\">10<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-11\">11<\/div>\n<div class=\"crayon-num crayon-striped-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-12\">12<\/div>\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-13\">13<\/div>\n<\/div>\n<\/td>\n<td class=\"urvanov-syntax-highlighter-code\">\n<div class=\"crayon-pre\">\n<div id=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-1\" class=\"crayon-line\">:local WANip [\/ip address get [find interface=&#8221;&lt;\u4f60\u7684 PPPoE interface \u540d\u5b57&gt;&#8221;] address]<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-2\" class=\"crayon-line crayon-striped-line\">:global oldWANip<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-3\" class=\"crayon-line\">:set WANip [:pick &#8220;$WANip&#8221; 0 ([:len $WANip] &#8211; 3)]<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-4\" class=\"crayon-line crayon-striped-line\"><\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-5\" class=\"crayon-line\">if ($WANip != $oldWANip) do={<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-6\" class=\"crayon-line crayon-striped-line\"><\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-7\" class=\"crayon-line\">\u00a0\u00a0:log info &#8220;WAN IP changed, fixing IPSec&#8221;<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-8\" class=\"crayon-line crayon-striped-line\"><\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-9\" class=\"crayon-line\">\u00a0\u00a0# \u5982\u679c\u6709\u591a\u4e2a IPSec \u94fe\u63a5\u5c31\u591a\u5199\u51e0\u884c<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-10\" class=\"crayon-line crayon-striped-line\">\u00a0\u00a0\/ip ipsec policy set [find sa-dst-address=&lt;\u670d\u52a1\u5668\u516c\u7f51 IP&gt;] sa-src-address=$WANip<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-11\" class=\"crayon-line\"><\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-12\" class=\"crayon-line crayon-striped-line\">\u00a0\u00a0:set oldWANip $WANip<\/div>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ae6356948700-13\" class=\"crayon-line\">}<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<h1>\u5efa\u7acbGRE\u96a7\u9053<\/h1>\n<p>\u521a\u624d\u7684IPSec\u96a7\u9053\u53ea\u662f\u70b9\u5bf9\u70b9\u8fde\u63a5\u3002\u5982\u679c\u6211\u4eec\u8981\u628a\u70b9\u5bf9\u70b9\u4ee5\u5916\u7684\u6d41\u91cf\u4e5f\u8def\u7531\u5230\u96a7\u9053\u90a3\u5934\uff0c\u5c31\u9700\u8981GRE\u534f\u8bae\u7684\u5e2e\u52a9\u3002<\/p>\n<p>\u56e0\u4e3a\u5df2\u7ecf\u5efa\u7acb\u4e86IPSec\u96a7\u9053\uff0cGRE\u96a7\u9053\u7684\u914d\u7f6e\u5c31\u53d8\u5f97\u5f88\u7b80\u5355\uff1a<\/p>\n<h2>\u670d\u52a1\u7aef<\/h2>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ae8518954497\" class=\"urvanov-syntax-highlighter-syntax crayon-theme-classic urvanov-syntax-highlighter-font-monaco urvanov-syntax-highlighter-os-mac print-yes notranslate\" data-settings=\" minimize scroll-mouseover\">\n<div class=\"urvanov-syntax-highlighter-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"urvanov-syntax-highlighter-row\">\n<td class=\"crayon-nums \" data-settings=\"show\">\n<div class=\"urvanov-syntax-highlighter-nums-content\">\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ae8518954497-1\">1<\/div>\n<\/div>\n<\/td>\n<td class=\"urvanov-syntax-highlighter-code\">\n<div class=\"crayon-pre\">\n<div id=\"urvanov-syntax-highlighter-6168ed5297ae8518954497-1\" class=\"crayon-line\">\/interface gre add local-address=&lt;\u670d\u52a1\u7aef\u96a7\u9053\u5185\u7f51 IP&gt; mtu=1382 name=gre-out1 remote-address=&lt;\u5ba2\u6237\u7aef\u96a7\u9053\u5185\u7f51 IP&gt;<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h2>\u5ba2\u6237\u7aef<\/h2>\n<div id=\"urvanov-syntax-highlighter-6168ed5297ae9791848482\" class=\"urvanov-syntax-highlighter-syntax crayon-theme-classic urvanov-syntax-highlighter-font-monaco urvanov-syntax-highlighter-os-mac print-yes notranslate\" data-settings=\" minimize scroll-mouseover\">\n<div class=\"urvanov-syntax-highlighter-main\">\n<table class=\"crayon-table\">\n<tbody>\n<tr class=\"urvanov-syntax-highlighter-row\">\n<td class=\"crayon-nums \" data-settings=\"show\">\n<div class=\"urvanov-syntax-highlighter-nums-content\">\n<div class=\"crayon-num\" data-line=\"urvanov-syntax-highlighter-6168ed5297ae9791848482-1\">1<\/div>\n<\/div>\n<\/td>\n<td class=\"urvanov-syntax-highlighter-code\">\n<div class=\"crayon-pre\">\n<div id=\"urvanov-syntax-highlighter-6168ed5297ae9791848482-1\" class=\"crayon-line\">\/interface gre add local-address=&lt;\u5ba2\u6237\u7aef\u96a7\u9053\u5185\u7f51 IP&gt; mtu=1382 name=gre-out1 remote-address=&lt;\u670d\u52a1\u5668\u7aef\u96a7\u9053\u5185\u7f51 IP&gt;<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u7136\u540e\uff0c\u4f60\u5c31\u53ef\u4ee5\u628a\u8def\u7531\u8868\u91cc\u9762\u7684\u90e8\u5206\u6761\u76ee\u6307\u5411\u8fd9\u4e2aGRE\u96a7\u9053\u5566\u3002<\/p>\n<p>\u6ce8\uff1a\u8fd9\u8fb9\u5199\u6b7b\u4e86MTU\uff0c\u4f60\u53ef\u4ee5\u8bd5\u8bd5\u4e0d\u586b\u8ba9\u8def\u7531\u5668\u81ea\u52a8\u8ba1\u7b97\uff08\u63d0\u9192\uff1aRouterOS\u7684MTU\u6c38\u8fdc\u7b97\u4e0d\u5bf9\uff09\u6216\u8005\u81ea\u5df1\u53bb\u7b97\u4e00\u4e2a\u66f4\u4f18\u7684\u503c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PSec\u6709\u4e24\u79cd\u6a21\u5f0f\uff1atransport\u548ctunnel\u3002Transport\u6a21\u5f0f\u53cc\u65b9\u4ecd\u7136\u4f7f\u7528\u5404\u81ea\u7684\u516c\u7f51IP\u4e92\u8054\uff0c\u53ea [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-2618","post","type-post","status-publish","format-standard","hentry","category-mikrotik"],"_links":{"self":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/2618","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2618"}],"version-history":[{"count":1,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/2618\/revisions"}],"predecessor-version":[{"id":2619,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/2618\/revisions\/2619"}],"wp:attachment":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}