MikroTik
How to Configure VLAN Network Access on MikroTik: Complete Tutorial
O acesso à rede VLAN no Mikrotik é uma maneira eficiente de segmentar sua rede, melhorando a segurança e o desempenho. As VLANs permitem criar redes lógicas dentro de uma mesma infraestrutura física, isolando o tráfego e oferecendo mais controle sobre o gerenciamento de rede. Neste tutorial, você aprenderá como configurar o acesso à rede VLAN no Mikrotik de maneira simples e eficaz.
Prerequisites for Configuring VLAN Network Access on MikroTik
Antes de começar, verifique se você possui os seguintes itens:- Acesso ao dispositivo Mikrotik (via Winbox ou CLI).
- Basic knowledge of VLANs and networking.
1. Accessing MikroTik
Para configurar o acesso à rede VLAN, você precisará acessar o seu dispositivo:- Via Winbox: Baixe e execute o Winbox. Conecte-se ao seu Mikrotik usando o endereço IP ou MAC.
- Via CLI: Use um terminal SSH para se conectar ao Mikrotik com seu nome de usuário e senha.
2. Creating a VLAN on MikroTik
Para começar a configuração, crie uma VLAN no Mikrotik e associe-a à interface física que se conecta à sua rede:- No menu Interfaces, clique em VLAN e depois em Add.
- Defina o VLAN ID (número da VLAN) e o Name para a VLAN (por exemplo, "VLAN10").
- Selecione a interface física (geralmente ether1 ou ether2) onde a VLAN será aplicada.
- Clique em OK para salvar.
CLI command example:
RouterOS
/interface vlan add name=vlan10 vlan-id=10 interface=ether13. Assigning an IP Address to the VLAN
Após criar a VLAN, você precisará atribuir um endereço IP à interface VLAN para permitir a comunicação entre dispositivos dessa rede:- No menu IP, clique em Addresses.
- Clique em Add para adicionar um novo endereço IP.
- Select the previously created VLAN interface and enter the desired IP address and subnet mask.
- Clique em OK para salvar.
CLI command example:
RouterOS
/ip address add address=192.168.10.1/24 interface=vlan104. Configuring the Bridge for VLAN
Se você estiver utilizando várias interfaces ou VLANs em seu Mikrotik, pode ser necessário configurar uma bridge para interconectar as VLANs com outras interfaces de rede:- No menu Bridge, clique em Add para criar uma nova bridge.
- Adicione a interface VLAN e outras interfaces necessárias à bridge.
- Clique em OK para salvar.
CLI command example:
RouterOS
/interface bridge add name=bridge-vlan
/interface bridge port add bridge=bridge-vlan interface=vlan10
/interface bridge port add bridge=bridge-vlan interface=ether25. Configuring Inter-VLAN Routing (Optional)
Se você deseja que as VLANs se comuniquem entre si (roteamento entre VLANs), você precisará configurar o roteamento de camada 3. O Mikrotik usa a função de bridge VLAN filtering para permitir o roteamento entre as VLANs:- No menu Bridge, clique em VLANs.
- Add the VLANs that should communicate with each other and define the appropriate ports and interfaces.
- Habilite o VLAN filtering na bridge.
CLI command example:
RouterOS
/interface bridge vlan add bridge=bridge-vlan tagged=ether1,ether2 untagged=ether3 vlan-ids=10
/ip routing add dst-address=0.0.0.0/0 gateway=192.168.10.16. Testing the VLAN Configuration
Após configurar o acesso à VLAN, é importante testar se os dispositivos conectados às VLANs podem se comunicar corretamente:- Connect a device to the configured VLAN network and verify that it receives the IP address correctly.
- Tente fazer ping entre dispositivos das diferentes VLANs para verificar a conectividade.
Test command example:
RouterOS
/ping 192.168.10.2