[SOLVED] Configure Ethernet ports as LAN and WiFi as WAN

Hi,

I'm working on Olinuxino-RT5350.
It is a switch with 5 ports and wifi.
OpenWrt default configuration enables WAN on eth0.2 and LAN on eth0.1.
I would like to enable LAN on both ethernet ports. I tried removing the vlans and configuring only one interface "eth0" on both Ethernet ports. Is it possible ? Do I have to use vlans : 1 vlan containing both ethernet ports ?

config interface 'loopback'
        option ifname 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config interface 'lan'
        option ifname 'eth0'
        option proto 'dhcp'

config device 'lan_dev'
        option name 'eth0'
        option macaddr 'xx:xx:xx:xx:xx:xx'

config interface 'wwan'
        option proto 'dhcp'

I have searched the forum but didn't find a similar topic or I might have used the wrong key words...

Thank you.

You could do what you ask, but you should assign the physical port of the wan interface to vlan1 rather than erasing all the switch configuration.
Could you post the default config in /etc/config/network ?

1 Like

Thanks @trendy

So this is what I supposed. I need to keep at least 1 vlan.
But why can't I use eth0 directly ?
Why should I create a vlan since eth0 has all ports by default ?
Sorry if this sounds like a beginner question, I'm still learning networking/routing/firewall/etc while I'm getting more and more familiar with OpenWrt.

Here is my default 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 'fd79:b29e:2a29::/48'

config interface 'lan'
        option type 'bridge'
        option ifname 'eth0.1'
        option proto 'static'
        option netmask '255.255.255.0'
        option ip6assign '60'
        option ipaddr '192.168.250.1'

config device 'lan_dev'
        option name 'eth0.1'
        option macaddr '80:1f:12:7e:14:46'

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

config device 'wan_dev'
        option name 'eth0.2'
        option macaddr '80:1f:12:7d:e4:f4'

config interface 'wan6'
        option ifname 'eth0.2'
        option proto 'dhcpv6'

config switch
        option name 'rt305x'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'rt305x'
        option vlan '1'
        option ports '0 1 2 3 6t'

config switch_vlan
        option device 'rt305x'
        option vlan '2'
        option ports '4 6t'

config interface 'wwan'
        option proto 'dhcp'

Another question concerning the default config, why do they often/always bridge the lan interface in default configs? A bridge with only one interface?

Many thanks.

Because the eth0 is not a physical interface, but a virtual interface on the cpu of the router. In order to make cpu communicate with each physical port of the switch, you need to assign them in the same vlan. This is basically what the config switch_vlan sections do.

In order to have all wired ports in LAN interface do the following modifications

config switch_vlan
        option device 'rt305x'
        option vlan '1'
        option ports '0 1 2 3 4 6t'

config switch_vlan
        option device 'rt305x'
        option vlan '2'
        option ports '6t'

I moved port#4 from vlan 2 to vlan 1.

It is bridged with the wireless interface.

Great!

Thanks for the information.

Just to be sure that I understood all well :

  • router ports are physical
  • ethernet ports are physical
  • interfaces are virtual and bind ethernet ports to router ports ? :thinking:
    I would be very pleased if you have a link to some documentation / tuorial that could help me understand more about the subject.

Thanks

1 Like
  • Interfaces in OpenWrt must be enumerated in the UCI - this is one requirement
  • VLANs are another requirement - to address additional networks on a device with a managed switch

Because you need a LAN and WAN (hence 2 VLANs) - per your title.

All you have to do is look at Network > Switch. You should see 2 rows - VLAN 1 and VLAN 2.

Simply make both ports untagged on VLAN 1.

In order to place Wireless on WAN, simply browse to the WiFi setting, and change its network from LAN to WAN.

Screenshot%20from%202019-06-07%2013-16-24

1 Like

Thanks @lleachii

Why should I create a vlan since eth0 has all ports by default ?

Because you need a LAN and WAN (hence 2 VLANs) - per your title.

Switch port seem to list only ethernet ports... or is there a port for WiFi ?
If only ethernet ports, then I would use ONLY WiFi over WAN so still no need for VLANs since all ethernet ports will be for LAN, right?

I don't use any Web UI for configuration.
All done through command line but managed to configure it all in one vlan.

WiFi goes over an internal bus to the CPU, which then uses/routes/bridges it, so no “switch port” like there is for the SoC's MACs (Ethernet logical part, “ethN”) and the phys (Ethernet physical part, “LAN jack N”).

Thanks @jeff for the precision.

So, if I want a VLAN for WAN over WiFi, I need to configure a vlan with no ports and bind WiFi to it ?
This is not working...

root@OpenWrt:/# cat /etc/config/network

config interface 'loopback'
        option ifname 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config interface 'lan'
        option type 'bridge'
        option ifname 'eth0.1'
        option proto 'static'
        option netmask '255.255.255.0'
        option ipaddr '192.168.252.1'
config device 'lan_dev'
        option name 'eth0.1'
        option macaddr '80:1f:12:7e:14:46'

config interface 'wwan'
        option ifname 'eth0.2'
        option proto 'dhcp'
config device 'wan_dev'
        option name 'eth0.2'
        option macaddr '80:1f:12:7d:e4:f4'

config switch
        option name 'rt305x'
        option reset '1'
        option enable_vlan '1'
config switch_vlan
        option device 'rt305x'
        option vlan '1'
        option ports '0 1 2 3 4 6t'
config switch_vlan
        option device 'rt305x'
        option vlan '2'
        option ports '6t'  <<<  same behavior if I remove this line

root@OpenWrt:/# cat /etc/config/wireless

config wifi-device 'radio0'
        option type 'mac80211'
        option channel '11'
        option hwmode '11g'
        option path 'platform/10180000.wmac'
        option htmode 'HT20'
        option disabled '0'

config wifi-iface 'default_radio0'
        option device 'radio0'
        option macaddr '80:1f:12:7e:0a:09'
        option mode 'sta'
        option network 'wwan'
        option ssid 'test'
        option encryption 'psk2'
        option key 'test'

root@OpenWrt:/# ifconfig

br-lan    Link encap:Ethernet  HWaddr 80:1F:12:7E:14:46  
          inet addr:192.168.252.1  Bcast:192.168.252.255  Mask:255.255.255.0
          inet6 addr: fe80::821f:12ff:fe7e:1446/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:310 errors:0 dropped:0 overruns:0 frame:0
          TX packets:168 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:45292 (44.2 KiB)  TX bytes:37742 (36.8 KiB)

eth0      Link encap:Ethernet  HWaddr 0A:5D:D8:30:28:DF  
          inet6 addr: fe80::85d:d8ff:fe30:28df/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:414843 errors:0 dropped:0 overruns:0 frame:0
          TX packets:17281 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:69344140 (66.1 MiB)  TX bytes:1441754 (1.3 MiB)
          Interrupt:5 

eth0.1    Link encap:Ethernet  HWaddr 80:1F:12:7E:14:46  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:310 errors:0 dropped:0 overruns:0 frame:0
          TX packets:172 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:45292 (44.2 KiB)  TX bytes:38026 (37.1 KiB)

eth0.2    Link encap:Ethernet  HWaddr 80:1F:12:7D:E4:F4  
          inet6 addr: fe80::821f:12ff:fe7d:e4f4/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:106 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:33559 (32.7 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:3893 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3893 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:222610 (217.3 KiB)  TX bytes:222610 (217.3 KiB)

wlan0     Link encap:Ethernet  HWaddr 80:1F:12:7E:0A:09  
          inet6 addr: fe80::821f:12ff:fe7e:a09/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:329 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:50842 (49.6 KiB)  TX bytes:1044 (1.0 KiB)

VLANs only exist for Ethernet, not for 802.11. You can bridge an 802.11 interface with a VLAN-tagged, Ethernet sub-interface, like eth1.1234

See the guest-net wiki and threads

3 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.