3

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

2
  • 1
    Use /etc/ppp/ip-up.d instead, if the script is specifically for ppp.
    – muru
    May 22, 2015 at 12:38
  • sometimes it needs to have a prefix like '0000script' otherwise it does not works.
    – RikiRiocma
    Nov 15, 2017 at 16:47

1 Answer 1

3

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

2
  • 1
    I did the edit :)
    – Redanium
    Oct 5, 2015 at 10:24
  • 2
    I am pretty sure there is no need for sudo inside script
    – FarK
    Jul 30, 2019 at 14:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .