OpenWrt Forum Archive

Topic: how to configure static routes

The content of this topic has been archived on 5 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I am using OpenWrt Kamikaze 7.09 on La Fonera 2201 device. I need to know how can i configure static routes on LAN interface.  Any link or configuration details will be help ful.

With Regards,
Reddy

in /etc/config/network

config route
    option interface lan
    option target 192.168.2.0
    option gateway 192.168.2.1

i'm not shure if theres an option netmask (i guess it is) but subnet is also defined via network address (in this example nm would be 255.255.255.0

ciao gerd

yes there is also an "option netmask" entry

Example for UCI CLI usage to add a static route to /etc/config/network:

# uci add network route
# uci set network.@route[-1].interface=lan
# uci set network.@route[-1].target=192.168.2.0
# uci set network.@route[-1].netmask=255.255.255.0
# uci set network.@route[-1].gateway=192.168.2.1
# uci commit network
# uci show network.@route[-1]
network.cfg078108=route
network.cfg078108.interface=lan
network.cfg078108.target=192.168.2.0
network.cfg078108.netmask=255.255.255.0
network.cfg078108.gateway=192.168.2.1

Example above only works with latest trunk.

(Last edited by Yanira on 16 Sep 2008, 18:23)

Hi,
I also want to add a static route but this doesn't work. I set this in /etc/config/network

config 'route'
    option 'interface' 'lan'
    option 'target' '10.0.1.0'
    option 'netmask' '255.255.255.0'
    option 'gateway' '10.0.1.1'

I rebooted but any ping 10.0.1.1 is routed through my wan iface ...

Ach it's working now, I put the wrong gateway ip, It should be

config 'route'
    option 'interface' 'lan'
    option 'target' '10.0.1.0'
    option 'netmask' '255.255.255.0'
    option 'gateway' '192.168.1.2'

(Last edited by Tex-Twil on 24 Sep 2009, 17:57)

Would these 2 examples be valid/working ?

config 'route'
    option 'interface' 'lan'
    option 'target' '10.0.0.0'
    option 'netmask' '255.255.255.0'
    option 'gateway' '192.168.1.0'

or replacing the ip by the iface name

config 'route'
    option 'interface' 'lan'
    option 'target' 'wlan0'
    option 'netmask' '255.255.255.0'
    option 'gateway' 'lan'

The discussion might have continued from here.