4G LTE does not retry to connect after a loss of connection

I have a system with 4G LTE modem.
I am currently using ncm protocol to connect to 4G network.
It works fine.
But sometime for some reason the system present a message log like that :slight_smile:

Thu Apr  4 17:45:53 2019 daemon.notice netifd: Interface 'wan_4' has link connectivity loss
Thu Apr  4 17:45:53 2019 daemon.notice netifd: Interface 'wan_6' has link connectivity loss
Thu Apr  4 17:45:53 2019 daemon.notice netifd: wan_4 (5767): udhcpc: received SIGTERM

After this kind of messages, the ip address of the 4G interface disappeared and I have no access to internet. Which is quite normal.

But I am wondering about the fact that netifd is not retring to connect to the 4G network.

I need to do a "ifup ethLTE" to reteive a 4G network connection and obviously an IP address.

Probably it is an issue in my configuration.
I used that one :slight_smile:

 config interface 'wan'
	option ifname 'ethLTE'
	option proto 'ncm'
	option device '/dev/ttyModem4g2'
	option mode 'lte'
	option delay '3'
	option apn 'orange'
	option pincode 'xxxx'

How can I do to have permanent retry of connection to the 4G interface when I have a loss of connection?

Thanks
Benoit

I thought there was a watchdog or something like that but I could not find it.
Have a look at this thread, I think with some slight customization to your needs it should do the job.

1 Like

Thank you for your answer.
I checked out the post.

I prefer to have something relevant to do a "ifup wan" once a loss connection raise condition happened.
But I don't really know if it is possible.

This kind of script could provoke some issue at startup for example when the 4G is trying to connect to the network.

In fact I did not understand where this kind of script is placed. I missed something.

Note, that pinging google may not be the best idea.
Better check your ISP gateway:

source /lib/functions/network.sh
network_find_wan NET_IF
network_get_gateway NET_GW "${NET_IF}"
ping "${PING_OPTIONS}" "${NET_GW}"
...

Another point is that ifup currently includes ifdown, so explicit ifdown is redundant:

https://openwrt.org/docs/guide-user/base-system/hotplug

1 Like

I already use the hotplug functionality to create link but I did not know that it was possible to catch "action".
I am going to make a try.
Thanks for your help

1 Like

hello,
I have encountered similar problem, could you please execute ifstatus wan to see the interface status?
You can try following script

#!/bin/sh
. /lib/functions.sh
. /lib/netifd/netifd-proto.sh
ubus call network.interface.wan down
killall gcom
sleep 1
proto_set_available wan 1
ubus call network.interface.wan up

I am using ModemManager, but I have this crude hotplug script that works in most cases. Essentially it parses the modem manager output and takes some action based on the status (ifup/down). You are welcome to adapt it to your purposes if it helps.

1 Like

well I am going to take a look and adapt it.
I will advice you if it works.
Thanks for the tip.

Maybe the package mwan3 could be used to monitor and restart the interface.

I saw in the mwantrack script that if a failed connection is detected (failed to ping for example), ifdown is called for the corresponding interface which generates an hotplug event.

So scripts in /etc/hotplug.d/iface are called.

I experimented that the interface is not restarted automatically.

But the hotplug script 16-mwan3-user calls the user script /etc/mwan3.user.
So i modifed this user script to make an ifup on the interface after a disconnect or a ifdown.

cat /etc/mwan3.user
#!/bin/sh
#
# This file is interpreted as shell script.
# Put your custom mwan3 action here, they will
# be executed with each netifd hotplug interface event
# on interfaces for which mwan3 is enabled.
#
# There are three main environment variables that are passed to this script.
#
# $ACTION
#      <ifup>         Is called by netifd and mwan3track
#      <ifdown>       Is called by netifd and mwan3track
#      <connected>    Is only called by mwan3track if tracking was successful
#      <disconnected> Is only called by mwan3track if tracking has failed
# $INTERFACE	Name of the interface which went up or down (e.g. "wan" or "wwan")
# $DEVICE	Physical device name which interface went up or down (e.g. "eth0" or "wwan0")
if [ "$ACTION" == "ifdown" -o "$ACTION" == "disconnected" ]; then
	ifup "$INTERFACE"
fi

It seems to work for me.