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:
eth0 (WAN port) accesses to the internet.
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
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.
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
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 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.