Quitar la configuración anterior de ForestVPN de un MikroTik
Un script quita la configuración anterior con el contenedor qproxy y la interfaz WireGuard fvpn0, con su kill switch y sus reglas mangle, para que la app de ForestVPN se instale limpia.
En esta página (7)
Qué obtienes
La configuración anterior de ForestVPN desaparece: el contenedor qproxy, la interfaz WireGuard fvpn0, la lista de direcciones under_fvpn, la tabla de enrutamiento fvpn con su regla «ForestVPN Kill Switch» y sus reglas mangle. Si se quedan, ese kill switch y esas reglas mangle siguen dirigiendo tu LAN hacia un túnel que ya no existe, así que la instalación se niega a ejecutarse mientras quede algo de eso. Este script se pega aparte, antes de la instalación.
Antes de empezar
- Dispositivo: un MikroTik que todavía tiene la configuración anterior de ForestVPN. ¿No estás seguro? Pega el script igualmente: en un router sin ella, lo dice y no cambia nada.
- Firmware: RouterOS 7.21 o posterior, con el paquete
containery el modo de dispositivo para contenedores activado. - Tiempo: cinco minutos.
- Qué puede fallar: la LAN se queda sin túnel entre la eliminación y la conexión del contenedor nuevo. La cuenta de la configuración anterior no se traslada: vincula el router de nuevo con un código (el código de emparejamiento aparece en
/log).
Pasos
-
Pega esto en el terminal del router (WinBox o WebFig, New Terminal).
Quita la configuración anterior de 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/." } }Guarda tu configuración en
forestvpn-before-removal.rsc, quita exactamente los objetos nombrados arriba, deja un puentecontainersque otros contenedores aún usan (con su dirección y su masquerade172.17.0.0/24, que también crea la propia guía de contenedores de MikroTik) y comprueba que no queda nada. Termina con «the previous setup is removed». -
Pega la instalación de Obtén la app → Router, con los ajustes que elegiste encima.
Comprobar que funcionó
Ni qproxy, ni under_fvpn, ni fvpn0 deberían aparecer en la exportación, ni 172.17.0. salvo que otros contenedores sigan usando el puente containers.
Muestra toda la configuración
/export terseDeshacerlo
La exportación guardada es un registro, no una copia de seguridad: los secretos no están en ella. Para volver atrás, vuelve a añadir a mano los objetos que contiene, o impórtala en un router que se haya restablecido.
Importa la configuración guardada
/import file-name=forestvpn-before-removal.rscSi algo va mal
| Síntoma | Causa | Solución |
|---|---|---|
| La instalación dice «this router still has the previous ForestVPN setup» | La configuración anterior sigue ahí | No se cambió nada. Pega el script del paso 1 y luego la instalación otra vez. |
| «the previous setup could not be removed completely» | Queda algo personalizado a mano | Lee /export y quita lo que quede por su nombre; luego pega el script otra vez. |
| La LAN no tiene internet tras la eliminación | El contenedor nuevo todavía no se ha conectado | Espera a la página de estado o vincula el router desde un teléfono con datos móviles. Consulta solución de problemas. |
Límites
- Busca los nombres de arriba y nada más: una configuración antigua personalizada a mano necesita que una persona lea
/export. - No traslada la cuenta anterior. Vincula el router de nuevo con un código.
- Quita un puente
containers, su dirección y su masquerade solo cuando no hay nada más en él.