This README provides a step-by-step guide on how to create VLANs on OpenWRT-based routers (such as GL.iNet Mango) using the command-line interface via SSH. VLANs (Virtual LANs) enable network segmentation for enhanced security and management.
- OpenWRT-compatible router (e.g., GL.iNet Mango)
- SSH access to the router
- Basic knowledge of networking and SSH
ssh [email protected] # Replace with your router's IP address
cp /etc/config/network /etc/config/network.backup
ip link show
Typical interfaces: eth0
, eth1
, br-lan
, etc.
vi /etc/config/network
Add VLAN definitions:
config interface 'vlan10'
option proto 'static'
option ifname 'eth0.10'
option ipaddr '192.168.10.1'
option netmask '255.255.255.0'
config interface 'vlan20'
option proto 'static'
option ifname 'eth0.20'
option ipaddr '192.168.20.1'
option netmask '255.255.255.0'
If using swconfig
:
config switch
option name 'switch0'
option reset '1'
option enable_vlan '1'
config switch_vlan
option device 'switch0'
option vlan '10'
option ports '0t 1'
config switch_vlan
option device 'switch0'
option vlan '20'
option ports '0t 2'
If using DSA, use eth0.10
, eth0.20
, etc. directly.
config dhcp 'vlan10'
option interface 'vlan10'
option start '100'
option limit '150'
option leasetime '12h'
config dhcp 'vlan20'
option interface 'vlan20'
option start '100'
option limit '150'
option leasetime '12h'
config zone
option name 'vlan10'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'REJECT'
option network 'vlan10'
config zone
option name 'vlan20'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'REJECT'
option network 'vlan20'
/etc/init.d/network restart
- Connect devices to the corresponding switch ports
- Test IP address assignment and connectivity
- Use
ping
ortraceroute
to verify isolation or routing
βοΈ Always back up config files before making changes
βοΈ Use tagged VLANs for trunk ports and untagged for access ports
βοΈ Use logread
or dmesg
to troubleshoot issues
- π [OpenWRT VLANDocumentation
- π GL.iNet Developer Guide
π¦ This README is suitable for GitHub projects involving OpenWRT VLAN configurations.