How to configure openWrt with 4 Ports network card? 1 WAN and 3 LAN?

I am a beginner in openwrt. i am using openWrt OpenWrt version 22.03.5 r20134-5f15225c1e / LuCI openwrt-22.03 branch git-23,093.57104-ce20b4a.
I installed on my desktop computer, the desktop computer has 1 network card with 4 ports. I checked and found that openWrt named each port eth0, eth1, eth2, eth3.
I want to configure openWrt to do the following:

  1. eth0 (WAN port) accesses to the internet.
  2. eth1, eth2, eth2 as LAN port. it allows other computers connected to it to access the internet.
    please give me a configuration example of /etc/config/network

With dedicated network interfaces (e.g. on x86_64), you add them to a bridge/ br-lan.

1 Like

I think you want to make br-lan containing eth1 eth2 eth3. You want two interfaces, LAN and WAN. LAN uses br-lan and WAN uses eth0

1 Like

In Luci
Network -> Interfaces -> Devices
select br-lan -> configure
Bridge ports : select the eth ports you want for the bridge
save

Interfaces tab
select wan -> edit
Device : select the eth port
save
save and apply

After that you may have to change the eth port you are using to connect to the router, depending off the actual one.

1 Like

OpenWRT will enumerate the Nic ports and will assign eth0-3 to them if you have 4 NICs. I think it is the Mac adress sorting order which effectively decides about the eth numbering. Which might make it appear as a weird order, if it is from multiple different network cards instead of a single network card with multiple ports.

by default:

  • eth0 is assigned to LAN
  • eth1 is assigned to WAN (in case the device has a second or more NIC ports)
  • all other ports (if more exist) are not assigned to interfaces by default.

You need to manually assign eth2-x to the br-lan device, if you want additional LAN ports

I for myself keep eth0 and eth1 as assigned by default (and live with the “unusual“ HW port assignment on the back of the device), as this helps a lot, whenever you reinstall OpenWRT. Otherwise you have to temporarily recable the eth0 and eth1 ports until a config restore has been applied on a fresh installation.

3 Likes

This is my configre in /etc/config/netwok
image

eth0 can optain ip address and openwrt can access to the internet, but when i connect a computer to eth2 or eth2 or eth3, the computer cannot optain any ip address.
Please help to correct the configure file.

did you edit the file or reconfig network via GUI?
(If you edit the file, you also need to commit your changes)

other option: you could reset the OpenWRT config and edit via GUI, what badulesia had explained here. It leads exactly to what you want, to activate the missing ports as LAN

1 Like

Yes worthy to remember, it bugged me more than once.
I use an alternative setup: eth0 for the main computer, eth1-2 also in the bridge and eth3 for WAN. Hence even if the router is reset to default I still have control with eth0. I can manually reconfigure it or restore a previous backup. By the time I do this, WAN (eth1) is connected to local devices, with no security risk.

I change to use web ui instead of editing the config file. I can make them work properly.

Thank you very much.

I may be more intuitive to do when you are beginning with OpenWrt. But the true power is unleashing once you are entering config file. So mind to read the docs, you'll discover new settings and possibilities.

1 Like

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