Router – OpenWRT – Manage Virtual LAN

coovachilliopenwrtroutervlan

I have an Ubiquiti AirRouter with OpenWRT on it and I've been trying to separate the manage of the ports.

I've formated the router using CoovaChilli app, anyways the app just help to install OpenWRT on the router and gives an easy UI-WEB manager.

The router has internal programmable switch, and as far as I understand it is possible to separate the LAN PORTS.

I've tried to configure /etc/config/network following OpenWRT – Switch Documentation

  • In my Ubiquiti router it seems eth0 and eth1 are different from the tutorial. In the tutorial the switch is eth0 in my router it is eth1

  • I have the basic configuration and I'd like to modify it, right now 4 ethernet ports have access to internet and are managed by default configuration.

  • I'd like to have 2 ports (1 and 2) with default configuration (Internet access), and the other 2 ports (3 and 4) redirected to a Hotspot

I need to have 2 different "devices" to do this, e.g. I need br-lan0 to be the defaults ports and br-hot0 the redirected ports.

I tried 1 million ways and everytime I try a configuration, the router stopped to assign IP's and I don't know what's happening or how to fix it.

This is an example configuration I've tried:

config 'interface' 'lan'
    option 'ifname' 'eth1.0'
    option 'proto' 'static'
    option 'ipaddr' '192.168.1.1'
    option 'netmask' '255.255.255.0'
    option 'defaultroute' '0'
    option 'peerdns' '0'
    option 'nat'    '1'

config 'interface' 'hot'
    option 'ifname'  'eth1.1'
    option 'proto'   'dhcp'

Some technical information for Airrouter & OpenWRT can be found here

Best Answer

You have to accompany your plain network config with the corresponding switch configuration.

Also, do not use VLAN 0, as this is a special VLAN.

Try something along the lines of this:

config 'interface' 'lan'
    option 'ifname' 'eth1.1'
    option 'proto' 'static'
    option 'ipaddr' '192.168.1.1'
    option 'netmask' '255.255.255.0'
    option 'defaultroute' '0'
    option 'peerdns' '0'
    option 'nat'    '1'

config 'interface' 'hot'
    option 'ifname'  'eth1.2'
    option 'proto'   'dhcp'

config 'switch'
    option 'name'    'switch0'
    option 'enable'  '1'
    option 'enable_vlan' '1'
    option 'reset'   '1'

config 'switch_vlan'
    option 'vlan'    '1'
    option 'device'  'switch0'
    option 'ports'   '0t 1 2'

config 'switch_vlan'
    option 'vlan'    '2'
    option 'device'  'switch0'
    option 'ports'   '0t 3 4'

Also, are you absolutely sure that the switch is internally eth1?

Reading through the relevant architecture files in the OpenWRT distribution shows me that most ar71xx devices have their switch on eth0, including the airrouter.

Here's the relevant section from base-files/etc/uci-defaults/02_network:

ap121 |\
ap121-mini |\
ap96 |\
airrouter |\
dir-600-a1 |\
dir-615-c1 |\
dir-615-e4 |\
ja76pf |\
mynet-n600 |\
oolite |\
rb-750 |\
rb-751 |\
tew-632brp |\
tew-712br |\
tl-mr3220 |\
tl-mr3220-v2 |\
tl-mr3420 |\
tl-wdr3500 |\
tl-wr741nd |\
tl-wr741nd-v4 |\
tl-wr841n-v7 |\
tl-wr841n-v9 |\
whr-g301n |\
whr-hp-g300n |\
whr-hp-gn |\
wzr-hp-ag300h)
        ucidef_set_interfaces_lan_wan "eth0" "eth1"
        ucidef_add_switch "switch0" "1" "1"
        ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
        ;;

Note the ucidef_set_interfaces_lan_wan line that lists eth0 before eth1, which designates eth0 as LAN nic and eth1 as WAN nic.

EDIT:

(in which case you would replace eth1 by eth0 in the above config and replace eth0 by eth1, if you have that somewhere else in your config)