Remover a configuração antiga do ForestVPN de um MikroTik
Um script remove a configuração antiga com o contêiner qproxy e a interface WireGuard fvpn0, com seu kill switch e suas regras mangle, para que o app do ForestVPN seja instalado sem resíduos.
Nesta página (7)
O que você obtém
A configuração anterior do ForestVPN some: o contêiner qproxy, a interface WireGuard fvpn0, a lista de endereços under_fvpn, a tabela de roteamento fvpn com a sua regra “ForestVPN Kill Switch” e as regras mangle delas. Se ficassem, esse kill switch e essas regras mangle continuariam levando a sua LAN para um túnel que não existe mais, e por isso a instalação se recusa a rodar enquanto algo disso estiver lá. Este script é colado à parte, antes da instalação.
Antes de começar
- Dispositivo: um MikroTik que ainda tem a configuração anterior do ForestVPN. Não tem certeza? Cole o script mesmo assim: em um roteador sem ela, ele avisa e não muda nada.
- Firmware: RouterOS 7.21 ou mais recente, com o pacote
containere o modo de dispositivo para contêineres ativado. - Tempo: cinco minutos.
- O que pode dar errado: a LAN fica sem túnel entre a remoção e a conexão do novo contêiner. A conta da configuração antiga não é transferida: vincule o roteador de novo com um código (o código de pareamento aparece em
/log).
Passos
-
Cole isto no terminal do roteador (WinBox ou WebFig, New Terminal).
Remove a configuração anterior do 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/." } }Ele salva a sua configuração em
forestvpn-before-removal.rsc, remove exatamente os objetos citados acima, deixa uma bridgecontainersque outros contêineres ainda usam (com o seu endereço e o seu masquerade172.17.0.0/24, que o próprio guia de contêineres da MikroTik também cria) e confere que nada sobrou. Termina com “the previous setup is removed”. -
Cole a instalação de Baixe o aplicativo → Roteador, com as configurações que você escolheu acima dela.
Conferir se funcionou
Nenhum de qproxy, under_fvpn ou fvpn0 deve aparecer na exportação, nem 172.17.0., a menos que outros contêineres ainda usem a bridge containers.
Mostra toda a configuração
/export terseDesfazer
A exportação salva é um registro, não um backup: os segredos não estão nela. Para voltar, recrie os objetos dela à mão, ou importe-a em um roteador que foi redefinido.
Importa a configuração salva
/import file-name=forestvpn-before-removal.rscSe algo der errado
| Sintoma | Causa | Solução |
|---|---|---|
| A instalação diz “this router still has the previous ForestVPN setup” | A configuração anterior ainda está lá | Nada foi alterado. Cole o script do passo 1 e depois a instalação de novo. |
| “the previous setup could not be removed completely” | Algo personalizado à mão ainda está lá | Leia /export e remova o que sobrou pelo nome; depois cole o script de novo. |
| A LAN fica sem internet depois da remoção | O novo contêiner ainda não se conectou | Espere a página de status ou vincule o roteador a partir de um celular com dados móveis. Veja solução de problemas. |
Limites
- Ele procura os nomes acima e nada mais: uma configuração antiga personalizada à mão exige que uma pessoa leia
/export. - Ele não transfere a conta antiga. Vincule o roteador de novo com um código.
- Ele remove uma bridge
containers, o seu endereço e o seu masquerade somente quando não há mais nada nela.