I can't define routes properly

Hello,

I installed OpenWRT on a few on my devices (22.03.3). On one of those devices I have a difficulty setting routes.
Here's what defined in the interface :

However, here's the result of route -e :
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
default R3.lan 0.0.0.0 UG 0 0 0 switch.1
192.168.114.0 * 255.255.255.0 U 0 0 0 switch.1
192.168.240.0 192.168.240.2 255.255.255.0 UG 0 0 0 lan9
192.168.245.0 * 255.255.255.0 U 0 0 0 lan10

I don't see any route to 192.168.243.0/24.

If I run : traceroute 192.168.240.2
I get :
traceroute to 192.168.240.2 (192.168.240.2), 30 hops max, 46 byte packets
1 192.168.240.2 (192.168.240.2) 0.543 ms 0.465 ms 0.421 ms
The packets are going through the default route.

I assume there's something wrong with my configuration !

Could you help me please ?
Thank you.

Remove th first route (192.168.240.0/24 via 192.168.240.2)... it is not necessary.

Then restart the router and see if the other routes populate.

What interface has got the IP 192.168.240.2, ETH9?
Can you maybe show the network config for the interface that got the IP 192.168.240.2?

Thank you psherman. I did removed the first route : 192.168.240.0/24 via 192.168.240.2.
Here's what I get now :

I rebooted the device. Things changed in the routing table :
route -e
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
default R3.lan 0.0.0.0 UG 0 0 0 switch.1
192.168.114.0 * 255.255.255.0 U 0 0 0 switch.1
192.168.240.0 * 255.255.255.0 U 0 0 0 lan9
192.168.241.0 192.168.240.2 255.255.255.0 UG 0 0 0 lan9
192.168.242.0 192.168.240.2 255.255.255.0 UG 0 0 0 lan9
192.168.244.0 192.168.240.2 255.255.255.0 UG 0 0 0 lan9
192.168.245.0 * 255.255.255.0 U 0 0 0 lan10
192.168.249.0 192.168.240.2 255.255.255.0 UG 0 0 0 lan9

However, I still don't get the route to 192.168.243.0/24 which I need to access 192.168.243.2 (which is another OpenWRT router).
The router is still trying to access that subnet via the default gateway :
traceroute 192.168.243.2
traceroute to 192.168.243.2 (192.168.243.2), 30 hops max, 46 byte packets
1 R3.lan (192.168.114.1) 0.719 ms 0.805 ms 0.686 ms

I deleted the route to 192.168.243.0/24, perhaps did I set something wrong concerning it. I made it again, and rebooted the router. Now I get the route I needed :
route -e
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
default R3.lan 0.0.0.0 UG 0 0 0 switch.1
192.168.114.0 * 255.255.255.0 U 0 0 0 switch.1
192.168.240.0 * 255.255.255.0 U 0 0 0 lan9
192.168.241.0 192.168.240.2 255.255.255.0 UG 0 0 0 lan9
192.168.242.0 192.168.240.2 255.255.255.0 UG 0 0 0 lan9
192.168.243.0 192.168.240.2 255.255.255.0 UG 0 0 0 lan9
192.168.244.0 192.168.240.2 255.255.255.0 UG 0 0 0 lan9
192.168.245.0 * 255.255.255.0 U 0 0 0 lan10
192.168.249.0 192.168.240.2 255.255.255.0 UG 0 0 0 lan9

I still can't access 192.168.243.2, but the problem is somewhere else now.
Thank you for your help regarding that routing table.

@patient0 : Here's eth9 :

Remove the gateway addrss in the eth9 config (unless it is supposed to be different than the default route in general, aside from the static routes).

let's see your config in text form.

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/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 'fdeb:a119:51ce::/48'

config device 'switch'
        option name 'switch'
        option type 'bridge'
        option macaddr '10:7b:ef:ce:61:13'
        list ports 'lan1'
        list ports 'lan2'
        list ports 'lan3'
        list ports 'lan4'
        list ports 'lan5'
        list ports 'lan6'
        list ports 'lan7'
        list ports 'lan8'
        option ipv6 '0'
        option bridge_empty '1'

config bridge-vlan 'lan_vlan'
        option device 'switch'
        option vlan '1'
        list ports 'lan1'
        list ports 'lan2'
        list ports 'lan3'
        list ports 'lan4'
        list ports 'lan5'
        list ports 'lan6'
        list ports 'lan7'
        list ports 'lan8'

config device
        option name 'switch.1'
        option macaddr '10:7b:ef:ce:61:13'
        option ipv6 '0'

config interface 'lan'
        option device 'switch.1'
        option proto 'static'
        option ip6assign '60'
        option gateway '192.168.114.1'
        list dns '192.168.114.1'
        option netmask '255.255.255.0'
        option ipaddr '192.168.114.63'
        option delegate '0'

config interface 'eth10'
        option proto 'static'
        option netmask '255.255.255.0'
        option gateway '192.168.114.1'
        option device 'lan10'
        option ipaddr '192.168.245.1'
        option broadcast '192.168.245.255'

config device
        option type 'bridge'
        option name 'br.subnet245'
        list ports 'lan1'
        list ports 'lan10'

config device
        option type 'bridge'
        option name 'br.subnet240'
        list ports 'lan1'
        list ports 'lan9'
        option ipv6 '0'

config bridge-vlan
        option device 'br.subnet240'
        option vlan '114'
        list ports 'lan1:t'
        list ports 'lan9:t'

config interface 'ETH9'
        option proto 'static'
        option device 'lan9'
        option ipaddr '192.168.240.1'
        option netmask '255.255.255.0'
        option gateway '192.168.114.1'

config route
        option interface 'ETH9'
        option target '192.168.241.0/24'
        option gateway '192.168.240.2'

config route
        option interface 'ETH9'
        option target '192.168.242.0/24'
        option gateway '192.168.240.2'

config route
        option interface 'ETH9'
        option gateway '192.168.240.2'
        option target '192.168.244.0/24'

config route
        option interface 'ETH9'
        option target '192.168.249.0/24'
        option gateway '192.168.240.2'

config device
        option name 'br.subnet240.241'
        option type '8021q'

config rule
        option in 'lan'
        option out 'ETH9'
        option dest '192.168.243.0/24'

config route
        option interface 'ETH9'
        option gateway '192.168.240.2'
        option target '192.168.243.0/24'

After removing the IPv4 gateway set on eth9 :


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 'fdeb:a119:51ce::/48'

config device 'switch'
        option name 'switch'
        option type 'bridge'
        option macaddr '10:7b:ef:ce:61:13'
        list ports 'lan1'
        list ports 'lan2'
        list ports 'lan3'
        list ports 'lan4'
        list ports 'lan5'
        list ports 'lan6'
        list ports 'lan7'
        list ports 'lan8'
        option ipv6 '0'
        option bridge_empty '1'

config bridge-vlan 'lan_vlan'
        option device 'switch'
        option vlan '1'
        list ports 'lan1'
        list ports 'lan2'
        list ports 'lan3'
        list ports 'lan4'
        list ports 'lan5'
        list ports 'lan6'
        list ports 'lan7'
        list ports 'lan8'

config device
        option name 'switch.1'
        option macaddr '10:7b:ef:ce:61:13'
        option ipv6 '0'

config interface 'lan'
        option device 'switch.1'
        option proto 'static'
        option ip6assign '60'
        option gateway '192.168.114.1'
        list dns '192.168.114.1'
        option netmask '255.255.255.0'
        option ipaddr '192.168.114.63'
        option delegate '0'

config interface 'eth10'
        option proto 'static'
        option netmask '255.255.255.0'
        option gateway '192.168.114.1'
        option device 'lan10'
        option ipaddr '192.168.245.1'
        option broadcast '192.168.245.255'

config device
        option type 'bridge'
        option name 'br.subnet245'
        list ports 'lan1'
        list ports 'lan10'

config device
        option type 'bridge'
        option name 'br.subnet240'
        list ports 'lan1'
        list ports 'lan9'
        option ipv6 '0'

config bridge-vlan
        option device 'br.subnet240'
        option vlan '114'
        list ports 'lan1:t'
        list ports 'lan9:t'

config interface 'ETH9'
        option proto 'static'
        option device 'lan9'
        option ipaddr '192.168.240.1'
        option netmask '255.255.255.0'

config route
        option interface 'ETH9'
        option target '192.168.241.0/24'
        option gateway '192.168.240.2'

config route
        option interface 'ETH9'
        option target '192.168.242.0/24'
        option gateway '192.168.240.2'

config route
        option interface 'ETH9'
        option gateway '192.168.240.2'
        option target '192.168.244.0/24'

config route
        option interface 'ETH9'
        option target '192.168.249.0/24'
        option gateway '192.168.240.2'

config device
        option name 'br.subnet240.241'
        option type '8021q'

config rule
        option in 'lan'
        option out 'ETH9'
        option dest '192.168.243.0/24'

config route
        option interface 'ETH9'
        option gateway '192.168.240.2'
        option target '192.168.243.0/24'

(option gateway '192.168.114.1' was deleted from the config interface 'ETH9' section)

The route problem seems to be solved.

However, I can't access one of my routers.

WAN
| (wan port)
[Router R3 running OpenWRT]--------[PC]
| 192.168.114.1 (lan port)
|
| 192.168.114.63 (lan port)
[Managed Switch running OpenWRT]
| 192.168.240.1 (lan port)
|
| 192.168.240.2 (wan port)
[Router R5 running OpenWRT]
| 192.168.243.1 (lan port)
|
| 192.168.243.2 (wan port)
[Router R6 running OpenWRT]

I can ping and access on port 80 the R6 router at 192.168.243.2 from :

  • R5
  • the managed switch (the one where I had the routing problem, now solved thanks to you !)

But I can't access it from R3, on which I have :
route -e
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
default 192.168.228.1 0.0.0.0 UG 0 0 0 eth0.2
192.168.114.0 * 255.255.255.0 U 0 0 0 br-lan
192.168.114.0 * 255.255.255.0 U 0 0 0 eth1.114
192.168.228.0 * 255.255.255.0 U 0 0 0 eth0.2
192.168.240.0 192.168.114.63 255.255.255.0 UG 0 0 0 br-lan
192.168.241.0 192.168.114.63 255.255.255.0 UG 0 0 0 br-lan
192.168.242.0 192.168.114.63 255.255.255.0 UG 0 0 0 br-lan
192.168.243.0 192.168.114.63 255.255.255.0 UG 0 0 0 br-lan
192.168.244.0 192.168.114.63 255.255.255.0 UG 0 0 0 br-lan
192.168.245.0 192.168.114.63 255.255.255.0 UG 0 0 0 br-lan
192.168.249.0 192.168.114.63 255.255.255.0 UG 0 0 0 br-lan

root@R3:~# 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 'fdc7:bb57:f631::/48'

config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'eth1.1'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option netmask '255.255.255.0'
        option ipaddr '192.168.114.1'
        option gateway '192.168.228.145'
        option delegate '0'

config interface 'wan'
        option device 'eth0.2'
        option proto 'static'
        option ipaddr '192.168.228.145'
        option netmask '255.255.255.0'
        option gateway '192.168.228.1'

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

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option vid '1'
        option ports '6t 4 3 2'

config switch_vlan
        option device 'switch0'
        option vlan '2'
        option ports '0t 5'
        option vid '2'

config route
        option interface 'lan'
        option target '192.168.245.0/24'
        option gateway '192.168.114.63'

config switch_vlan
        option device 'switch0'
        option vlan '9'
        option ports '6t 1t'
        option vid '114'

config interface 'PORT4_VLAN114'
        option device 'eth1.114'
        option proto 'static'
        option ipaddr '192.168.114.164'
        option netmask '255.255.255.0'
        option gateway '192.168.114.1'

config route
        option interface 'lan'
        option target '192.168.240.0/24'
        option gateway '192.168.114.63'

config route
        option target '192.168.241.0/24'
        option gateway '192.168.114.63'
        option interface 'lan'

config route
        option interface 'lan'
        option target '192.168.242.0/24'
        option gateway '192.168.114.63'

config route
        option interface 'lan'
        option target '192.168.243.0/24'
        option gateway '192.168.114.63'

config route
        option interface 'lan'
        option target '192.168.244.0/24'
        option gateway '192.168.114.63'

config route
        option interface 'lan'
        option gateway '192.168.114.63'
        option target '192.168.249.0/24'

Would it be possible to draw a diagram (a photo of a piece of a drawing on paper, rather than using ASCII art) so it is a bit more clear:

  1. the overall toplogy, including switches and router arrangements
  2. which routers can successfully route to R5 (if any) vs which cannot.

I'm having a similar issue. I share my solution for you to learn from


Hope that helps

Here's the diagram :
schema

Access to R6 KO from R3 :

root@R3:~# traceroute 192.168.243.2
traceroute to 192.168.243.2 (192.168.243.2), 30 hops max, 46 byte packets
 1  192.168.114.63 (192.168.114.63)  1.001 ms  0.829 ms  0.807 ms
 2  192.168.240.2 (192.168.240.2)  1.156 ms  1.051 ms  1.009 ms
 3  *  *  *

Ping + http KO.

From the managed switch, access to R6 is OK :

traceroute 192.168.243.2
traceroute to 192.168.243.2 (192.168.243.2), 30 hops max, 46 byte packets
 1  192.168.240.2 (192.168.240.2)  0.516 ms  0.420 ms  0.099 ms
 2  192.168.243.2 (192.168.243.2)  0.664 ms  0.531 ms  0.524 ms

Ping + http access to R6 OK.

From R5, access to R6 is OK :

traceroute 192.168.243.2
traceroute to 192.168.243.2 (192.168.243.2), 30 hops max, 46 byte packets
 1  192.168.243.2 (192.168.243.2)  0.308 ms  0.163 ms  0.139 ms

I assume the problem is on the managed switch (running OpenWRT).

On the managed switch :