Mikrotik Router VLAN Configuration step by step
3 min read
11 months ago
Published on Sep 10, 2024
This response is partially generated with the help of AI. It may contain inaccuracies.
Table of Contents
Introduction
In this tutorial, we will learn how to configure VLANs on a Mikrotik router using a router-on-a-stick approach. This step-by-step guide is based on a practical demonstration with Mikrotik CCR1036-8G-2S and CRS328-24P-4S switches in a GNS3 lab environment. You will gain insights into creating, assigning, and routing VLANs effectively.
Step 1: Setting Up Your GNS3 Environment
- Download GNS3: Go to the GNS3 website and download the software.
- Install Required Resources:
- Download the necessary files including Mikrotik Firewall and Cisco images from the provided Google Drive links.
- Create a New Project in GNS3:
- Open GNS3 and create a new project to start your configuration.
Step 2: Add Devices to Your Project
- Add Mikrotik Router:
- Drag the Mikrotik CCR1036 router to the workspace.
- Add Switch:
- Drag the CRS328-24P-4S switch to the workspace.
- Connect Devices:
- Use the connection tool to link the Mikrotik router to the switch.
Step 3: Configure VLANs on Mikrotik Router
- Access the Mikrotik Router:
- Open the terminal or use Winbox to connect to the router.
- Define VLAN Interfaces:
- Use the following commands to create VLAN interfaces:
/interface vlan add name=vlan10 vlan-id=10 interface=ether1 /interface vlan add name=vlan20 vlan-id=20 interface=ether1
- Use the following commands to create VLAN interfaces:
- Assign IP Addresses to VLANs:
- Assign IP addresses to the VLAN interfaces:
/ip address add address=192.168.10.1/24 interface=vlan10 /ip address add address=192.168.20.1/24 interface=vlan20
- Assign IP addresses to the VLAN interfaces:
Step 4: Configure Switch for VLANs
- Access the Switch Configuration:
- Use the switch management interface to enter the switch configuration mode.
- Define VLANs on the Switch:
- Create VLANs on the switch:
vlan 10 name VLAN10 exit vlan 20 name VLAN20 exit
- Create VLANs on the switch:
- Assign Ports to VLANs:
- Assign the appropriate ports to each VLAN:
interface ethernet1 switchport access vlan 10 exit interface ethernet2 switchport access vlan 20 exit
- Assign the appropriate ports to each VLAN:
Step 5: Set Up Inter-VLAN Routing
- Enable IP Routing:
- Make sure IP routing is enabled on the Mikrotik router:
/ip settings set ip-routing=yes
- Make sure IP routing is enabled on the Mikrotik router:
- Configure DHCP for VLANs (Optional):
- If you want to add DHCP services, use the following commands:
/ip dhcp-server add name=dhcp1 interface=vlan10 address-pool=dhcp_pool1 /ip dhcp-server add name=dhcp2 interface=vlan20 address-pool=dhcp_pool2
- If you want to add DHCP services, use the following commands:
Step 6: Test Connectivity
- Use Ping Command:
- Test connectivity between devices in different VLANs to ensure routing is functioning.
- Use the ping command from a device in VLAN 10 to a device in VLAN 20.
Conclusion
You have successfully configured VLANs on a Mikrotik router using the router-on-a-stick method. This setup allows for efficient traffic management and improved network segmentation. As a next step, consider exploring additional features like firewall settings or implementing security measures for your VLANs. Happy networking!