How to permanently add route to custom routing table?

Executing via ssh on router:

ip route add 192.168.9.0/24 dev br-lan table via_pub_gw

seems fix my problem.

Longer story is:

My OpenWrt router hast one NATed IP# (default, 192.168.227.173 ) and two public IP# (pub.lic.ip.5/26 and pub.lic.ip.56/26) from ISP.
On public IP# listens nginx acting as reverse proxy.
Traffic coming out from nginx listening on public IP#s is using custom routing table 'via_pub_gw' so it is routed to different GW.

Problem is accessing public IP services works from internet, but not from LAN.

IMHO reason is routing table 'via_pub_gw' is missing my LAN route:
192.168.9.0/24 dev br-lan table via_pub_gw

Parts of /etc/config/network:

config interface 'wan'
		option device 'lan1'
		option proto 'static'
		option gateway '192.168.227.1'
		list ipaddr '192.168.227.173/24'

config interface 'wan_pub'
		option proto 'static'
		option device 'lan1'
		option gateway 'pub.lic.ip.30'
		option ip4table 'via_pub_gw'
		list ipaddr 'pub.lic.ip.56/26'
		list ipaddr 'pub.lic.ip.5/26'

You can set routes in the network config file, they are persistent over reboots.

config route 'yournamehere'
		option interface 'br-lan'
		option target '192.168.9.0'
		option netmask 'whatever netmask you use'
        option table 'via_pub_gw'

Thanks!

I only had to use
option interface 'lan'

with my interface lan definition:

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ip6assign '60'
        list ipaddr '192.168.9.3/24'
        list dns '192.168.9.3'
        option delegate '0'

Also it is nicely clickable from /cgi-bin/luci/admin/network/routes

1 Like

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