MikroTik
How to Configure L2TP (Layer 2 Tunneling Protocol) on MikroTik: Step by Step
O L2TP (Layer 2 Tunneling Protocol) no Mikrotik é um protocolo de tunelamento usado para criar VPNs seguras e estáveis. No Mikrotik, o L2TP pode ser combinado com IPSec para garantir a criptografia e a autenticação da conexão, sendo uma escolha popular para conectar dispositivos remotos ou redes.
Step-by-Step Guide to Configure L2TP on MikroTik
1. Access the MikroTik
- Conecte-se ao dispositivo via WinBox, SSH, ou interface Web.
2. Enable the L2TP Server
- Habilite o servidor L2TP no Mikrotik:
RouterOS
/interface l2tp-server server set enabled=yes use-ipsec=no - Caso deseje usar IPSec com L2TP, habilite-o no servidor:
RouterOS
/interface l2tp-server server set enabled=yes use-ipsec=yes ipsec-secret="ChaveSegura"
3. Create Users for the VPN
- Adicione credenciais de login para os dispositivos que se conectarão à VPN:
RouterOS
/ppp secret add name=usuario password=senha service=l2tp profile=default
4. Configure the IP Pool for the VPN
- Defina o intervalo de IPs que será atribuído aos clientes conectados via L2TP:
RouterOS
/ip pool add name=L2TP-Pool ranges=192.168.100.10-192.168.100.20
5. Bind the Pool to the PPP Profile
- Ajuste o perfil PPP para usar o pool de IPs criado:
RouterOS
/ppp profile set default local-address=192.168.100.1 remote-address=L2TP-Pool
6. Configure the Firewall to Allow L2TP
- Libere as portas necessárias para o L2TP funcionar corretamente:
RouterOS
/ip firewall filter add chain=input protocol=udp dst-port=1701 action=accept comment="Permitir L2TP" /ip firewall filter add chain=input protocol=udp dst-port=500,4500 action=accept comment="Permitir IPSec para L2TP" /ip firewall filter add chain=input protocol=ipsec-esp action=accept comment="Permitir tráfego IPSec"
7. Test the VPN Connection
- Configure an L2TP client (Windows, macOS, or another device) with the credentials you created.
- No Mikrotik, monitore as conexões ativas:
RouterOS
/ppp active print
8. Add Routes for Internal Networks (if necessary)
- Caso precise acessar uma rede interna, adicione rotas específicas para redirecionar o tráfego:
RouterOS
/ip route add dst-address=192.168.1.0/24 gateway=192.168.100.1