scripts in if-up.d not executed when ppp connection is created

I have a simple script "test" in /etc/network/if-up.d directory. The script contains below commands. It creates a empty text file, whenever an interfaces changes state from down to up.

#!/bin/bash
sudo touch /home/duser/test1.txt

But the script is not executing when ppp connection is established. The ppp connection belongs to an usb-modem. The pppd daemon will be initiated by wvdial. I tried disconnecting and connecting my wlan, then the script is executing. But it doesn't work for ppp. Note: The script have 755 permission


Solution 1:

For example put this script in /etc/ppp/ip-up.d/ to make default route to ppp0 interface every time when go up, make script called script with execute permissions 755

sudo nano /etc/ppp/ip-up.d/script

# Check for specific interface if desired
[ "$PPP_IFACE" != "ppp0" ] || exit 0
# Do something
sudo route add default dev ppp0
chmod 755 /etc/ppp/if-up.d/script

Try