Automatic add route

Hello.
pls help me
i have an dhcp ip from provider
how i can add automatically route after reboot that is using dhcp ip from provider? for example
dhcp ip is
ip 10.3.2.5
mask 255.255.255.0
gateway 10.3.2.1
and i need to auto add route for example
ip route add 172.16.5.0/24 via 10.3.2.1 dev eth0
help me pls

I don't think it is necessary as the gateway is providing the route 0/0
What does your routing table say?
ip -4 ro or route -n

1 Like
. /lib/functions/network.sh
network_flush_cache
network_find_wan NET_IF
network_get_gateway NET_GW "${NET_IF}"
uci -q delete network.gw
uci set network.gw="route"
uci set network.gw.interface="${NET_IF}"
uci set network.gw.target="172.16.5.0/24"
uci set network.gw.gateway="${NET_GW}"
uci commit network
/etc/init.d/network restart

It can be useful to override VPN-gateway to access ISP-network services.

1 Like

I guess that would be a logical explanation, cause the example above doesn't make sense. @artsiom82 if that is the case, be more specific as we cannot guess your setup.
Other than the uci method that vgaetera mentioned, you can do it in Luci: Network - Static routes.

2 Likes