CONFIGURAR ZEROTIER para ACCESO REMOTO HOME WORK TELETRABAJO

Avatar de Usuario
admin
Verified
Site Admin
Mensajes: 2089
Registered for: 9 years 10 months
9
Ubicación: Ciudad de Córdoba - Argentina
Gender:
Edad: 41
Contactar:

CONFIGURAR ZEROTIER para ACCESO REMOTO HOME WORK TELETRABAJO

#1

Mensaje por admin »

Imagen

Aca les dejo un tutorial de como configurarlo en un router con OPENWRT. Al final van a poder aprender el video
Link origina el ingles: https://bit.ly/2JopqEE

Instalacion

Si ya no esta instalado instale zerotier en tu router. Aqui te lo muestro

Instalacion via GUI/WEB LUCI : System -> Software luego click en Update lists para obtener los ultimos paquetes. Despues use el filtro y busque zerotier Solamente vera un solo paquete, luego haga click  en  INSTALL
Como seria via cli (Linea de Comandos)

Código: Seleccionar todo

root@openwrt:~# opkg update
root@OpenWrt:~# opkg install zerotier
Installing zerotier (1.2.12-2) to root...
Downloading ...
Installing libstdcpp (7.3.0-1) to root...
Downloading ...
Installing kmod-tun (4.14.95-1) to root...
Downloading ...
Installing libmnl (1.0.4-1) to root...
Downloading ...
Installing ip-tiny (4.16.0-8) to root...
Downloading ...
Installing libminiupnpc (2.0.20170509-1) to root...
Downloading ...
Installing libnatpmp (20150609-1) to root...
Downloading ...
Configuring kmod-tun.
Configuring libmnl.
Configuring libstdcpp.
Configuring ip-tiny.
Configuring libminiupnpc.
Configuring libnatpmp.
Configuring zerotier.
disabled in config
Crear red en ZEROTIER
Vaya a https://my.zerotier.com  y cree una red con las caracteristicas similares a esta:

Código: Seleccionar todo

ZeroTier Controller
-------------------
Network ID: 8ad5123ed69d6f69
IPv4 Auto-Assign (advanced)
[x] Auto-Assign from Range: 172.28.28.1-172.28.28.255
Managed Routes:
172.28.28.0/24 (LAN)
192.168.1.0/24 (172.28.28.1)
IPv6 Auto-Assign
[ ] ZeroTier RFC4193 (/128 for each device)
[ ] ZeroTier 6PLANE (/80 routable for each device)
[ ] Auto-Assign from Range
Configurar ZEROTIER en tu router OPENWRT con UCI (Es una especie de comandos especiales)

Loguearse via SSH - CLI y ejecutar el siguiente comand (es un comando show)

Código: Seleccionar todo

root@openwrt:~# uci show zerotier
zerotier.sample_config=zerotier
zerotier.sample_config.enabled='0'
zerotier.sample_config.join='8056c2e21c000001'
podemos obtener la misma info mediante el comando CAT leyendo el siguiente archivo

Código: Seleccionar todo

root@OpenWrt:~# cat /etc/config/zerotier

config zerotier sample_config
option enabled 0

# persistent configuration folder (for ZT controller mode)
#option config_path '/etc/zerotier'

#option port '9993'

# Generate secret on first start
option secret ''

# Join a public network called Earth
list join '8056c2e21c000001'
#list join '<other_network>'
Nosotros en este caso deberiamos ingresas estos comandos .(El ejemplo que vieron arriba es un ejemplo que viene por defecto).
Nuestra nueva red sera esta  openwrt_network

Código: Seleccionar todo

root@OpenWrt:~# uci set zerotier.openwrt_network=zerotier
root@OpenWrt:~# uci add_list zerotier.openwrt_network.join='8ad5123ed69d6f69'
root@OpenWrt:~# uci set zerotier.openwrt_network.enabled='1'
root@OpenWrt:~# uci commit zerotier
Si usted quiere remover algun network ID debera utilizar el siguiente comando

Código: Seleccionar todo

root@openwrt:~# uci del_list zerotier.openwrt_network.join='<network id to remove from join list>'
Ahora via el comando cat /etc/config/zerotier vamos a poder ver la configuracion relacioanda a zerotier. vamos a ver dos redes, una que no esta habilitada y otra que si. El "1" en el atributo "enabled" asi lo determina.

Código: Seleccionar todo

root@openwrt:~# cat /etc/config/zerotier

config zerotier 'sample_config'
option enabled '0'
list join '8056c2e21c000001'

config zerotier 'openwrt_network'
list join '8ad5123ed69d6f69'
option enabled '1'
Ahora realizamos un reboot

Despues del reboot tenemos que tirar el siguiente comando para ver que la interface que creamos con todos los comandos que hemos venido tirando este up arriba. Sintaxis de la misma seria algo asi ZTXXXXXXX

Código: Seleccionar todo

root@openwrt:~# ip a
... (several networks)
6: ztXXXXXXXX: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 2800 qdisc fq_codel state UNKNOWN group default qlen 1000
link/ether 6a:04:a7:8b:b8:6a brd ff:ff:ff:ff:ff:ff
inet6 fe80::6804:a7ff:fe8b:b86a/64 scope link
valid_lft forever preferred_lft forever
Nuestro Zerotier cliente instalado en el router deberia estar online y tirar algo parecido a lo que muestro abajo

Código: Seleccionar todo

root@openwrt:~# zerotier-cli info
200 info 41c7017c10 ONLINE 1.1.14
Ahora tambien el comando show deberia mostrar una variable o atributo que antes no veiamos. Esta es llamada secret
 

Código: Seleccionar todo

root@OpenWrt:~# uci show zerotier
zerotier.sample_config=zerotier
zerotier.sample_config.enabled='0'
zerotier.sample_config.join='8056c2e21c000001'
zerotier.openwrt_network=zerotier
zerotier.openwrt_network.join='8ad5123ed69d6f69'
zerotier.openwrt_network.enabled='1'
zerotier.openwrt_network.secret='6b3a5d8678:0:...'
El varlo zerotier.openwrt_network.secret esta en este path /var/lib/zerotier-one/identity.secret osea que si tiras un comando cat podrias ver el contenido

Ahora si se dirigue al manager de https://my.zerotier.com/ podra ver que existe una relacion entre su router y ZEROTIER. El atributo auth? no se olvide de marcarlo. Seria como un tipo de autorizacion a la relacion "router <-------> ZEROTIER"

El siguiente comando es para que usted vea la IP que le asigno a sus dispositivo, en este caso al router. Esta IP la asigno ZEROTIER

Código: Seleccionar todo

root@openwrt:~# ip a
... (several networks)
6: ztXXXXXXXX: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 2800 qdisc fq_codel state UNKNOWN group default qlen 1000
link/ether 6a:04:a7:8b:b8:6a brd ff:ff:ff:ff:ff:ff
inet 172.28.28.1/24 brd 172.28.28.255 scope global ztXXXXXXXX
valid_lft forever preferred_lft forever
inet6 fe80::6804:a7ff:fe8b:b86a/64 scope link
valid_lft forever preferred_lft forever
Configuracion del firewall para las conecciones entrantes hacia el router (Mejora la performance)

Via luci seria algo como lo que se explica

En OpenWrt 18.06 LuCI ir Network -> Firewall -> Traffic Rules y en  Open ports on router configurar:

Código: Seleccionar todo

Name: Allow-ZeroTier-Inbound
Protocol: UPD
External port: 9993
Le damos SAVE y vera una entrada muy parecida a la que se ve abajo

Código: Seleccionar todo

Match:
Incoming IPv4 and IPv6, protocol UDP
From any zone
To this device, port 9993

Action:
Accept input
Ahora le da SAVE  and APPLY

USANDO LINEA DE COMANDO

Código: Seleccionar todo

root@OpenWrt:~# uci add firewall rule
root@OpenWrt:~# uci set firewall.@rule[-1].name='Allow-ZeroTier-Inbound'
root@OpenWrt:~# uci set firewall.@rule[-1].src='*'
root@OpenWrt:~# uci set firewall.@rule[-1].target='ACCEPT'
root@OpenWrt:~# uci set firewall.@rule[-1].proto='udp'
root@OpenWrt:~# uci set firewall.@rule[-1].dest_port='9993'
root@OpenWrt:~# uci commit firewall
root@OpenWrt:~# /etc/init.d/firewall restart
Usted en este file /etc/config/firewall puede ver la configuracion. Algo asi puede encontrar:

Código: Seleccionar todo

config rule
option enabled '1'
option target 'ACCEPT'
option proto 'udp'
option dest_port '9993'
option name 'Allow-ZeroTier-Inbound'
option src '*'
La opcion "enabled=1" puede ser opcional

Configurando enrutamiento dentro del router
Algo parecido a esto seria nuestra actual configuracion relacionada al  enrutamiento

Código: Seleccionar todo

WAN-Interface of the OpenWRT router : a public IP on the internet
IP-Range of the LAN switch on the OpenWRT router : 192.168.1.0/24
IP-Address of the zt interface on the OpenWRT router : 172.28.28.1
ZeroTier network route on the OpenWRT router : 172.28.28.0/24 via zt
Go to Network -> Interfaces, click en Add new interface e ingrese las siguientes configuraciones

Código: Seleccionar todo

Name of the new interface : ZeroTier
Protocol of the new interface : Unmanaged
Create a bridge over multiple interfaces : [ ]
Cover the following interface : Ethernet Adapter: "ztXXXXXXXX"
click en submit y luego en save and apply
Para ver la IP de la interface relacionada a Zerotier esta solamente se puede ver via cli ip a
Por ultimo debemos crear una zona. Ahi en el video explico bien para que sirve este paso

Luego ir a Network -> Firewall, click en Add to create a new zone con la siguiente informacion

Código: Seleccionar todo

Name: vpn
Input: accept
Output: accept
Forward: accept
Masquerading: [x]
MSS clamping: [ ]
Covered networks: [x] ZeroTier:
[ ] lan:
[ ] wan:
[ ] wan6:
Inter-Zone Forwarding
Allow forward to destination zones: [x] lan:
[x] wan: wan6:
Allow forward from source zones : [x] lan:
[ ] wan: wan6:
Save and apply y luego ir a reboot

TEST
El test lo van a ver en el video que pongo a continuacion

Escenario de prueba

Imagen

Video


 
 
 

Enlace:
BBCode:
HTML:
Ocultar enlaces al mensaje
Mostrar enlaces al mensaje
Responder

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Registrarse

Sign in

  • Temas similares
    Respuestas
    Vistas
    Último mensaje

Volver a “Redes/Networking”

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 8 invitados