I'm running OpenWrt 19.07.7 on a raspberry pi 3 , I'm trying to create a virtual nic (or is it called a vlan?) which is on eth0 but which is on a different subnet so that both subnets can access the internet but what I' have is not working. here is my config:
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fd24:8535:1964::/48'
config interface 'lan'
option type 'bridge'
option ifname 'eth0'
option proto 'static'
option ipaddr '172.16.1.245'
option netmask '255.255.0.0'
option ip6assign '60'
config interface 'wan'
option proto 'pppoe'
option ifname 'eth1'
option username '<my-username)'
option password '<password>'
option peerdns '0'
option dns '8.8.8.8 8.8.4.4'
config interface 'lan2'
option type 'bridge'
option proto 'static'
option netmask '255.255.255.0'
option ipaddr '192.168.0.1'
option ip6assign '60'
option ifname 'eth0.2'
I'm new to openwrt so not sure what I'm doing wrong. The pi3 itself can ping the internet but traffic into lan2 can't. thanks for any pointers.
ASFP
April 15, 2021, 3:36pm
2
I assume you need a vlan for "lan" and one for "lan2"?
'lan' - which is 172.16.1.245 - already connects to the internet fine as its on eth0 but lan2 -on 192.168.0.1 - does not. I don't know how to make lan2 connect to the internet. also, when i look at lan2 in the web gui the RX is always 0.
ASFP
April 15, 2021, 3:57pm
4
Can you configure it via the LuCi WebInterface or would you like to do it via the cli? (It's a lot easier via LuCi in my opinion)
I've tried both but cannot get it to work
ASFP
April 15, 2021, 3:59pm
6
I can give you a explanation of how to do it via LuCi, if you want so
yes that would be good thankyou
ASFP
April 15, 2021, 4:01pm
8
Ok, do you need the vlan untagged or tagged? Just so you can still connect to the router after activating the vlan
so sorry I don't know what that means. I of course still need to access the pi3, which 'is' the router.
trendy
April 15, 2021, 4:14pm
10
The OpenWrt configuration is correct. Have you configured the managed switch on port eth0 accordingly?
I'm not using a managed switch, just a standard network hub
trendy
April 15, 2021, 4:34pm
12
That won't work. You need a managed switch there.
ASFP
April 15, 2021, 4:36pm
13
Doesn't the raspberry have 1 ethernet port anyway?
virtual NICs would be the option then.
ASFP
April 15, 2021, 4:56pm
14
The OpenWRT Wiki has the following two configuration types for virtual NICs.
Option 1
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fd24:8535:1964::/48'
config device
option type '8021q'
option ifname 'eth0'
option vid '1'
option name 'vlan1'
config device
option type '8021q'
option ifname 'eth0'
option vid '2'
option name 'vlan2'
config interface 'lan'
option type 'bridge'
option ifname 'vlan1'
option proto 'static'
option ipaddr '172.16.1.245'
option netmask '255.255.0.0'
option ip6assign '60'
config interface 'lan2'
option type 'bridge'
option ifname 'vlan2'
option proto 'static'
option ipaddr '192.168.0.1'
option netmask '255.255.255.0'
option ip6assign '60'
config interface 'wan'
option ifname 'eth1'
option proto 'dhcp'
config interface 'wan'
option proto 'pppoe'
option ifname 'eth1'
option username '<my-username)'
option password '<password>'
option peerdns '0'
option dns '8.8.8.8 8.8.4.4'
Option 2
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fd24:8535:1964::/48'
config interface 'lan'
option type 'bridge'
option ifname 'eth0.1'
option proto 'static'
option ipaddr '172.16.1.245'
option netmask '255.255.0.0'
option ip6assign '60'
config interface 'lan2'
option type 'bridge'
option ifname 'eth0.2'
option proto 'static'
option ipaddr '192.168.0.1'
option netmask '255.255.255.0'
option ip6assign '60'
config interface 'wan'
option ifname 'eth1'
option proto 'dhcp'
config interface 'wan'
option proto 'pppoe'
option ifname 'eth1'
option username '<my-username)'
option password '<password>'
option peerdns '0'
option dns '8.8.8.8 8.8.4.4'
I don't really know if these work for you. I don't use virtual NICs on my setup.