حذف تنظیمات قدیمی ForestVPN از MikroTik
یک اسکریپت تنظیمات قدیمی با کانتینر qproxy و رابط WireGuard با نام fvpn0 را، همراه با kill switch و قانونهای mangle آن، حذف میکند تا اپلیکیشن ForestVPN تمیز نصب شود.
در این صفحه (7)
چه چیزی به دست میآورید
تنظیمات قبلی ForestVPN از میان میرود: کانتینر qproxy، رابط WireGuard با نام fvpn0، فهرست نشانی under_fvpn، جدول مسیریابی fvpn با قانون «ForestVPN Kill Switch» و قانونهای mangle آنها. اگر باقی بمانند، این kill switch و این قانونهای mangle شبکهٔ محلی شما را همچنان به تونلی که دیگر وجود ندارد هدایت میکنند؛ برای همین تا وقتی چیزی از آنها باقی است نصب از اجرا خودداری میکند. این اسکریپت جدا جایگذاری میشود، پیش از نصب.
پیش از شروع
- دستگاه: یک MikroTik که هنوز تنظیمات قبلی ForestVPN را دارد. مطمئن نیستید؟ باز هم اسکریپت را جایگذاری کنید: روی روتری که آن را ندارد همین را میگوید و چیزی را تغییر نمیدهد.
- سیستمافزار: RouterOS نسخهٔ 7.21 یا جدیدتر، با بستهٔ
containerو حالت دستگاه برای کانتینرها فعال. - زمان: پنج دقیقه.
- چه چیزی ممکن است خراب شود: میان حذف و اتصال کانتینر جدید، شبکهٔ محلی تونل ندارد. حساب تنظیمات قدیمی منتقل نمیشود: روتر را دوباره با یک کد پیوند دهید (کد جفتسازی در
/logظاهر میشود).
گامها
-
این را در ترمینال روتر جایگذاری کنید (WinBox یا WebFig، New Terminal).
تنظیمات قبلی ForestVPN را حذف میکند
{ :local old [:toarray ""] :if ([:len [/container/find where name~"qproxy"]] > 0) do={ :set old ($old , "the qproxy container") } :if ([:len [/interface/wireguard/find where name="fvpn0"]] > 0) do={ :set old ($old , "WireGuard interface fvpn0") } :if ([:len [/ip/firewall/address-list/find where list="under_fvpn"]] > 0) do={ :set old ($old , "address list under_fvpn") } :if ([:len [/routing/table/find where name="fvpn"]] > 0) do={ :set old ($old , "routing table fvpn") } :if ([:len [/routing/rule/find where table="fvpn" or comment~"ForestVPN Kill Switch"]] > 0) do={ :set old ($old , "the ForestVPN Kill Switch rule") } :if ([:len [/ip/firewall/mangle/find where src-address-list="under_fvpn" or connection-mark="under_fvpn" or out-interface="fvpn0" or in-interface="fvpn0"]] > 0) do={ :set old ($old , "its mangle rules") } :if ([:len [/interface/list/member/find where interface="fvpn0"]] > 0) do={ :set old ($old , "fvpn0 in an interface list") } :if ([:len $old] = 0) do={ :put "ForestVPN: this router has no previous ForestVPN setup. Nothing was changed." } :if ([:len $old] > 0) do={ :put ("ForestVPN: removing the previous ForestVPN setup: " . [:tostr $old] . ". Your configuration before this is saved as forestvpn-before-removal.rsc.") /export file=forestvpn-before-removal :foreach c in=[/container/find where name~"qproxy"] do={ :do { /container/stop $c } on-error={} :local n 0 :while ([/container/get $c running] && $n < 30) do={ :delay 1s; :set n ($n + 1) } :delay 2s /container/remove $c } # A mark into table fvpn, which goes below, would route by the main table, out the WAN, once it is gone. /ip/firewall/mangle/remove [find where src-address-list="under_fvpn" or connection-mark="under_fvpn" or out-interface="fvpn0" or in-interface="fvpn0" or (chain="prerouting" and action="accept" and dst-address="192.168.88.1") or new-routing-mark="fvpn"] /ipv6/firewall/mangle/remove [find where src-address-list="under_fvpn" or connection-mark="under_fvpn"] /routing/rule/remove [find where table="fvpn" or comment~"ForestVPN Kill Switch"] /ip/route/remove [find where routing-table="fvpn"] /ipv6/route/remove [find where routing-table="fvpn"] /interface/wireguard/peers/remove [find where interface="fvpn0"] /interface/list/member/remove [find where interface="fvpn0"] /ip/address/remove [find where interface="fvpn0"] /ipv6/address/remove [find where interface="fvpn0" and !dynamic] /interface/wireguard/remove [find where name="fvpn0"] /routing/table/remove [find where name="fvpn"] /ip/firewall/address-list/remove [find where list="under_fvpn"] /interface/bridge/port/remove [find where interface~"veth-qproxy"] /interface/veth/remove [find where name~"veth-qproxy"] # The "containers" bridge, its address and its 172.17.0.0/24 masquerade only if nothing else is # still on it: MikroTik's own container guide uses the same names, so other containers may share them. :if ([:len [/interface/bridge/find where name="containers"]] = 1 and [:len [/interface/bridge/port/find where bridge="containers"]] = 0) do={ /ip/firewall/nat/remove [find where src-address="172.17.0.0/24"] /ip/address/remove [find where interface="containers"] /interface/list/member/remove [find where interface="containers"] /interface/bridge/remove [find where name="containers"] } # The same check the install makes before it runs. :if ([:len [/container/find where name~"qproxy"]] + [:len [/interface/wireguard/find where name="fvpn0"]] + [:len [/ip/firewall/address-list/find where list="under_fvpn"]] + [:len [/routing/table/find where name="fvpn"]] + [:len [/routing/rule/find where comment~"ForestVPN Kill Switch"]] > 0) do={ :error "ForestVPN: the previous setup could not be removed completely. See /export and fvpn.net/help/mikrotik-remove-old/." } :put "ForestVPN: the previous setup is removed. Now paste the install from fvpn.net/download/mikrotik/." } }پیکربندی شما را در
forestvpn-before-removal.rscذخیره میکند، دقیقاً اشیایی را که در بالا نام برده شد حذف میکند، پلcontainersرا که کانتینرهای دیگر هنوز از آن استفاده میکنند باقی میگذارد (با نشانی آن و masquerade آن یعنی172.17.0.0/24، که راهنمای کانتینر خود MikroTik هم میسازد) و بررسی میکند که چیزی باقی نمانده باشد. با «the previous setup is removed» پایان مییابد. -
نصب را از دریافت اپلیکیشن: Router جایگذاری کنید، با تنظیماتی که بالای آن انتخاب کردهاید.
بررسی اینکه کار کرد
در خروجی export نباید هیچیک از qproxy، under_fvpn یا fvpn0 دیده شود، و 172.17.0. هم نباید دیده شود مگر اینکه کانتینرهای دیگر هنوز از پل containers استفاده کنند.
کل پیکربندی را نشان میدهد
/export terseبازگرداندن
خروجی ذخیرهشده یک سابقه است، نه پشتیبان: رازها در آن نیست. برای برگشتن، اشیای آن را دستی دوباره اضافه کنید یا آن را روی روتری که بازنشانی شده وارد کنید.
پیکربندی ذخیرهشده را وارد میکند
/import file-name=forestvpn-before-removal.rscاگر مشکلی هست
| نشانه | علت | راهحل |
|---|---|---|
| نصب میگوید «this router still has the previous ForestVPN setup» | تنظیمات قدیمی هنوز هست | چیزی تغییر نکرد. اسکریپت گام 1 و سپس دوباره نصب را جایگذاری کنید. |
| «the previous setup could not be removed completely» | چیزی که دستی تغییر داده شده هنوز هست | /export را بخوانید و باقیمانده را با نام حذف کنید، سپس اسکریپت را دوباره جایگذاری کنید. |
| پس از حذف، شبکهٔ محلی اینترنت ندارد | کانتینر جدید هنوز متصل نشده است | منتظر صفحهٔ وضعیت بمانید یا روتر را از تلفنی با دادههای همراه پیوند دهید. عیبیابی را ببینید. |
محدودیتها
- فقط نامهای بالا را جستوجو میکند: تنظیمات قدیمی که دستی تغییر داده شده باشد باید توسط یک انسان از روی
/exportخوانده شود. - حساب قدیمی را منتقل نمیکند. روتر را دوباره با یک کد پیوند دهید.
- پل
containers، نشانی و masquerade آن را فقط وقتی حذف میکند که چیز دیگری روی آن نباشد.