I would like to run a specific script if there are no connections made by a client to the internet (wan interface).
how to check from the CLI if there are current connections made by a client to the internet.
the script executed would restart my 4g router/modem which is upstream of my openwrt router,
but I would like it not to be executed in the hypothesis that there are outgoing connections to the wan of my openwrt router.
Would you restart it whenever there are no connections (theoretically you could be creating a boot loop), or only if internet is down at the same time?
I would like to do a crontab every 2 or 3 or 4 hours if it doesn't detect active connections then it executes a set of instructions otherwise it exits without executing anything.
I would like to know is there a system to know if there are active outgoing connections?
I would like to avoid running the script while I'm browsing or if a device in my network is downloading something.
my 4g modem/router a huawei sometimes reduces the received signal
if I perform a restart (or the passage from 4g -> 3g -> 4g) it manages to improve its reception of the LTE signal
as far as I know netstat only shows currently active connections on the router,
netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 116 192.168.1.1:ssh 192.168.1.16:55498 ESTABLISHED
always on the same topic since the "/proc/net/nf_conntrack" table is one
in the hypothesis of having multiple gateways it is not possible
deduce if the traffic is passing from one to the other gateway:
unfortunately the two connections remain active (they will never be inactive), but since the connections are based on 2 4g routers and the signal sometimes drops (and so does the network performance) I was wondering how to restart a 4g router if it is not used at that moment.
in any case always excellent answers from you if I don't receive other proposals for sure your first answer will be enough for me to start solving my little problem
this is a network performance issue that varies throughout the day, based on how many people are using the 4g antennas and bad weather
I notice that performance increases if I reboot or switch to 3g and then back to 4g I would like to automate everything, but only if there are no existing connections as I said.
The mwan3 interface options have also the quality check. If the connection is getting worse when the signal fades, then you'll be able to spot it there.
Other than that I can only think of some custom script to test signal and restart the modem if needed.
I would close the post the first solution you gave me is enough for me.
I wanted to get more opinions from other people active on this forum, but maybe since it could be just my problem, so I don't want to bore you further.