0

I have set a ppp interface but as it is a bit unstable, I want to keep checking its status in a cron script and if down, take certain action.

I found this stackoverflow question (although in C++) helpful and it works for normal interfaces but for type ppp, it always shows that the interface is up. "ip addr ls" shows the interface status as UNKNOWN irrespective of whether the modem is switched on or not. I do not know if that is the issue though the ppp interface works fine despite the UNKNOWN status.

What do I need to add to the program to get real up/down status of the ppp interface?

Sunny
  • 9,245
  • 10
  • 49
  • 79
  • Assuming you are programming for Linux, you should use the netlink interface for that. That is: open a netlink socket and query the interface status. That is the most reliable and correct method of doing this nowadays. There's support libraries you can use. – Cheatah Sep 17 '22 at 18:47
  • To add to that: you should monitor for interface changes. Check if you receive any events on the command `ip monitor link` or `ip monitor all`, and if so, you should probably try to implement that programmatically. – Cheatah Sep 17 '22 at 18:50
  • @Cheatah That is exactly what I am doing (or so I think) in the code from the link cited by me. It works find for non-ppp interfaces but for ppp interfaces, it always shows it is up even if I disconnect the fibre line to the modem. The fact that the status is shown as UNKNOWN when doing a "ip addr ls" may be the source of the problem. – Sunny Sep 18 '22 at 04:10

0 Answers0