Wednesday, January 13, 2016

Configure OpenWRT port switch -- VLAN and Trunk

1- To permanent save the switch configuration we have to edit the file /etc/config/network ,

Sample configuration port 1 trunk, port2 vlan 0, port 3 vlan 10 and port 4 vlan 1

config switch 'eth1'
      option enable '1'
      option enable_vlan '1'
config switch_vlan
      option device 'eth1'
      option vlan '2'
      option vid '2'
      option ports '0t 1t'
config switch_vlan
      option device 'eth1'
      option vlan '1'
      option vid '1'
      option ports '0t 1t 4'
config switch_vlan
      option device 'eth1'
      option vlan '0'
      option vid '0'
      option ports '0t 1t 2'
config switch_vlan
      option device 'eth1'
      option vlan '10'
      option vid '10'
      option ports '0t 1t 3'
config switch_vlan
      option device 'eth1'
      option vlan '20'
      option vid '20'
      option ports '0t 1t'
config switch_vlan
      option device 'eth1'
      option vlan '12'
      option vid '12'
      option ports '0t 1t'



2- after make change to the /etc/config/network , we need to restart network service
root@OpenWrt:/etc/config# /etc/init.d/network restart


2- use swconfig to show check the status of the switch
root@OpenWrt:/etc/config# swconfig list
Found: switch0 - eth1
root@OpenWrt:/etc/config# swconfig dev eth1 show
Global attributes:
    enable_vlan: 1
Port 0:
    pvid: 0
    link: port:0 link:up speed:1000baseT full-duplex txflow rxflow
Port 1:
    pvid: 0
    link: port:1 link:down
Port 2:
    pvid: 0
    link: port:2 link:down
Port 3:
    pvid: 10
    link: port:3 link:down
Port 4:
    pvid: 1
    link: port:4 link:down
VLAN 0:
    vid: 0
    ports: 0t 1t 2
VLAN 1:
    vid: 1
    ports: 0t 1t 4
VLAN 2:
    vid: 2
    ports: 0t 1t
VLAN 10:
    vid: 10
    ports: 0t 1t 3
VLAN 12:
    vid: 12
    ports: 0t 1t

No comments:

Post a Comment