Change metric without restart network?

I change the metric for an interface with:
uci set ...
uci commit ....
But the new settings doesn´t work until I restart network.

Is there an other way than "/etc/init.d/network restart" to apply the new settings?

/etc/init.d/network reload
ifup wan
1 Like

Both restart and reload trigger a reset of my LTE modem and I loose internet connection for a while.
Isn´t there a way to do it without reseting the LTE modem?

Is there really a problem?
You are supposed to configure it just once.
The setting should persist after committing.

1 Like

I have both fixed internet and a LTE modem in my router. My idea was to change the metric to control the outgoing traffic if one connections goes down.
Maybe it´s possible to use ip route add/del?

It may wok, but perhaps you should use a well-known solution:

1 Like

If you want to do it manually, you can do:
ip route replace default via <gateway> dev <dev> src <srcip>

Otherwise, you can use mwan3 to automatically detect link status and manage the routes.


I have two LTE modems, so I just simply defined two WAN connections, and used policy routing to send some traffic left, and some traffic right. definitely look into setting up MWAN3. I was running this on Openwrt, Mikrotik, and finally settled on pfsense because of some other stuff I wanted to do that required "more" operating system.

But definitely possible to flip between the two on failover without changing any routing metrics.


I made a bash script and run it as a cronjob. :slight_smile:


# Default metric: wan=5 wwan=10

pingWAN=$(ping -c 4 -W 1 -I eth0 | grep packets | awk '{print $7 }' | sed s/%//g)
pingWWAN=$(ping -c 4 -W 1 -I wwan0 | grep packets | awk '{print $7 }' | sed s/%//g)

wwanRoute=$(ip route | grep wwan0 | grep default)
wwanMetric=$(echo $wwanRoute | awk '{print $NF}')
delWWANroute='ip route del '$(echo $wwanRoute | awk '{print $1, $2, $3, $4, $5}')
addWWANroute='ip route add '$(echo $wwanRoute | awk '{$NF=""; print $0}')

if [ $pingWAN -eq 100 ]
	if [ $wwanMetric -eq 10 -a $pingWWAN -lt 100 ]
		echo $delWWANroute
		echo $addWWANroute' 1'
		logger -t defaultRoute wwan0 default route
	if [ $wwanMetric -eq 1 ]
		echo $delWWANroute
		echo $addWWANroute' 10'
		logger -t defaultRoute eth0 default route