Use 2nd OpenWrt router as switch?

I have 2 OpenWRT router, both with DSL, WAN and 4 LAN ports. First one is connected to Internet and has a usual PPPOE + 4LAN switch setup. Now i want to use my second router in another room.

I was going to connect LAN1 (or WAN port if that can be configured?) to WAN. Set WAN to DHCP client and somehow route traffic to the wired clients connected on LAN 1-4. I get an IP adress via DHCP but i cant reach, ping, ssh anything to it.

So is my wish feasable? Can some come up with a small gude for me?
Thank you!

DocMAX

Sure, this is no problem. You are going to be setting this up more-or-less like a dumb AP (even if you don't use the AP function).

The most important thing is that you turn off the DHCP server on the lan (set it to ignore), and set an IP address that does not conflict with your network or overlap the DHCP pool from your main router; or use DHCP client mode.

You can include your wan port (making it just another port on the switch) if you want.

Please copy the output of the following commands and post it here using the "Preformatted text </> " button:
grafik
Remember to redact passwords, MAC addresses and any public IP addresses you may have:

cat /etc/config/network
cat /etc/config/dhcp

You want the config from the main router or the 2nd? In case of the second all is still default.

Yes, config from the device that will become the switch. With that, I can recommend the specific changes to make your device into a switch with DHCP disabled and the wan port included.

root@bthh5a:~# cat /etc/config/dhcp

config dnsmasq
        option domainneeded '1'
        option boguspriv '1'
        option filterwin2k '0'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/lan/'
        option domain 'lan'
        option expandhosts '1'
        option nonegcache '0'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
        option nonwildcard '1'
        option localservice '1'
        option ednspacket_max '1232'

config dhcp 'lan'
        option interface 'lan'
        option start '100'
        option limit '150'
        option leasetime '12h'
        option dhcpv4 'server'
        option dhcpv6 'server'
        option ra 'server'
        option ra_slaac '1'
        list ra_flags 'managed-config'
        list ra_flags 'other-config'

config dhcp 'wan'
        option interface 'wan'
        option ignore '1'

config odhcpd 'odhcpd'
        option maindhcp '0'
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'
        option loglevel '4'
root@bthh5a:~# cat /etc/config/network

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

config globals 'globals'
        option ula_prefix 'fd5e:4438:44dd::/48'

config atm-bridge 'atm'
        option vpi '1'
        option vci '32'
        option encaps 'llc'
        option payload 'bridged'
        option nameprefix 'dsl'

config dsl 'dsl'
        option annex 'a'
        option tone 'av'
        option ds_snr_offset '0'

config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'lan1'
        list ports 'lan2'
        list ports 'lan3'
        list ports 'lan4'
        option ipv6 '0'

config device
        option name 'lan1'
        option macaddr '00:37:b7:2c:23:82'
        option ipv6 '0'

config device
        option name 'lan2'
        option macaddr '00:37:b7:2c:23:82'

config device
        option name 'lan3'
        option macaddr '00:37:b7:2c:23:82'
        option ipv6 '0'

config device
        option name 'lan4'
        option macaddr '00:37:b7:2c:23:82'
        option ipv6 '0'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'
        option ip6assign '60'

config interface 'wan'
        option proto 'dhcp'
        option device 'wan'

config interface 'wan6'
        option device '@wan'
        option proto 'dhcpv6'

config device
        option name 'eth0'

I really would like to connect the WAN <-> WAN ports together to have this as "bridge cable"
My ultimate goal then is to have also mesh WIFI running in this setup.

Set the lan interface DHCP server so that it looks like this

config dhcp 'lan'
        option interface 'lan'
        option start '100'
        option limit '150'
        option leasetime '12h'
        option ignore '1'

Now, in the network config, remove the wan and wan6 interfaces, and then add wan to the lan bridge so that it looks like this:

config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'lan1'
        list ports 'lan2'
        list ports 'lan3'
        list ports 'lan4'
        list ports 'wan'
        option ipv6 '0'

and finally, set the lan interface to an IP address in your main subnet that does not conflict with any other devices or the DHCP pool, or set it to proto 'dhcp' if you want it to be set via DHCP from your main router.

One or the other from below
Below would be a static configuration assuming that 192.168.1.0/24 is your main subnet and 192.168.1.2 is not used by any other device nor the DHCP pool.

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '192.168.1.2'
        option netmask '255.255.255.0'
        option ip6assign '60'

optionally, you can add the dns and gateway information to the lan (in static IP configuration) if you will need to install any packages (if not, this is not important).

--- or ----
if you go with the DHCP option, it would look like this:

config interface 'lan'
        option device 'br-lan'
        option proto 'dhcp'
3 Likes

Works flawlessly! Thank you very much!

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