OpenWrt Forum Archive

Topic: VLANs on Kamikaze

The content of this topic has been archived on 30 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I would like to create a virtual interface from an interface (e.g. eth0). So I have to write

vconfig add eth0 2

and eth0.2 is created.

Is there a way different from rc.d and init.d scripts, to do it at startup, using Kamikaze configuration files?
Thank you.

The best way to do this is to add entries to the /etc/config/network file. This is technically used by the init scripts so I don't know if it answers your question or not.

In any case you are probably going to end up using an init script of some sort if you want to have the configuration there on startup. The only other way I can think of might be a special cron directive which only runs on startup.

Thanks for your quick answer.
I'm successfully creating my VLANs at startup using init.d and rc.d script, but I would like to do it in a cleaner way, using /etc/config files.
So I'm wondering if it's possible to do it and in which way...

To define VLANs in /etc/config/network change (with a editor or UCI) the file like this:

#### VLAN configuration 
config switch eth0
        option vlan0    '0 1 2 5'
        option vlan1    '3 5'
        option vlan2    '4 5'

config interface vlan1
        option ifname 'eth0.1'
        option proto  'dhcp'

config interface vlan2
        option ifname 'eth0.2'
        option proto  'dhcp'

#### Loopback configuration
config interface loopback
        option ifname   "lo"
        option proto    static
        option ipaddr   127.0.0.1
        option netmask  255.0.0.0

#### LAN configuration
config interface lan
        option type     bridge
        option ifname   "eth0.0"
        option proto    static
        option ipaddr   '192.168.178.3'
        option netmask  255.255.255.0
        option gateway  '192.168.178.1'
        option dns      '192.168.178.1'


#### WAN configuration
#config interface        wan
#        option ifname   "eth0.1"
#        option proto    'none'

eth0.0 = vlan0, eth0.1 = vlan1, eth0.2 = vlan2 and so on. eth0 is the switch itself...

Once you changed the file you can bring up the new interfaces with 'ifup vlan1; ifup vlan2'.

This currently only works on routers with a Broadcom switch.

(Last edited by forum2006 on 31 Aug 2007, 09:00)

Thanks.
I'm using a Meraki Mini (very similar to Fon) and so I have only one ethernet port (not any switch to configure). I just want packets to be tagged on eth0.
It's not possible to configure VLANs in this way on my device, is it?

(1) Install package robocfg
(2) use command "robocfg" for manage port
(3) I do not know how to automatize this task at startup. Does anybody know how automatize?

The discussion might have continued from here.