OpenWRT/VLAN

From Segfault
Jump to: navigation, search
$ grep -A4 switch_vlan /etc/config/network 
config switch_vlan
       option device 'rtl8366s'
       option vlan '1'
       option ports '0 1 2 3 5t'
$ swconfig dev switch0 help
switch0: rtl8366s(RTL8366S), ports: 6 (cpu @ 5), vlans: 4096
    --switch
       Attribute 1 (int): enable_learning (Enable learning, enable aging)
       Attribute 2 (int): enable_vlan (Enable VLAN mode)
       Attribute 3 (int): enable_vlan4k (Enable VLAN 4K mode)
       Attribute 4 (none): reset_mibs (Reset all MIB counters)
       Attribute 5 (int): blinkrate (Get/Set LED blinking rate (0 = 43ms, 1 = 84ms, 2 = 120ms, 3 = 170ms, 4 = 340ms, 5 = 670ms))
       Attribute 6 (int): max_length (Get/Set the maximum length of valid packets (0 = 1522, 1 = 1536, 2 = 1552, 3 = 16000 (9216?)))
       Attribute 7 (none): apply (Activate changes in the hardware)
       Attribute 8 (none): reset (Reset the switch)
    --vlan
       Attribute 1 (string): info (Get vlan information)
       Attribute 2 (int): fid (Get/Set vlan FID)
       Attribute 3 (ports): ports (VLAN port mapping)
    --port
       Attribute 1 (none): reset_mib (Reset single port MIB counters)
       Attribute 2 (string): mib (Get MIB counters for port)
       Attribute 3 (int): led (Get/Set port group (0 - 3) led mode (0 - 15))
       Attribute 4 (int): pvid (Primary VLAN ID)
       Attribute 5 (string): link (Get port link information)
$ swconfig dev switch0 show | egrep '^Port|link:'
Port 0:
       link: port:0 link:up speed:100baseT full-duplex txflow rxflow 
Port 1:
       link: port:1 link:up speed:100baseT full-duplex 
Port 2:
       link: port:2 link:down
Port 3:
       link: port:3 link:down
Port 4:
       link: port:4 link:down
Port 5:
       link: port:5 link:up speed:1000baseT full-duplex txflow rxflow auto

Configure two VLANs:

config interface 'lan'
       option ifname 'vlan1'
       option type 'bridge'
       option proto 'static'
       option ipaddr '192.168.0.1'
       option netmask '255.255.255.0'
       
config interface 'guests'
       option ifname 'vlan2'
       option type 'bridge'
       option proto 'static'
       option ipaddr '10.0.0.1'
       option netmask '255.255.255.0'
config switch_vlan 'vlan1'
       option device 'switch0'
       option vlan '1'
       option ports '1 2 0t'
       
config switch_vlan 'vlan2'
       option device 'switch0'
       option vlan '2'
       option ports '3 4 0t'

Configure firewall and DHCP:

$ cat /etc/config/firewall 
[...]
config zone
     option name             guestzone
     option network          guests
     option input            ACCEPT
     option output           ACCEPT
     option forward          REJECT
$ cat /etc/config/dhcp
[...]
config dhcp guest
     option interface        guests
     option start            200     
     option limit            250
     option leasetime        12h

Links