How to run a script after ppp interface is comes up under Linux

Q. I am using Fedora Core Linux. How do I run a script called /etc/rapp/logtime.sh immediately after my ppp interface is up?

ADVERTISEMENTS

A. Point-to-Point Protocol (PPP), is data link protocol commonly used for dial-up internet access. It is used to establish a direct connection between two nodes. It can connect computers using serial cable, phone line, trunk line, cellular telephone, specialized radio links, or fiber optic links. Most Internet service providers use PPP for customers’ dial-up access to the Internet.

Fedora Core – /etc/ppp/ip-up.local file

Under Fedora Core / RHEL /CentOS Linux you need to create or edit file – /etc/ppp/ip-up.local (Debian / Ubuntu Linux user see below for more information).

There is also a file called /etc/ppp/ip-up and it should not be modified — make local all changes to /etc/ppp/ip-up.local file only.

Step # 1: Open /etc/ppp/ip-up.local file
# vi /etc/ppp/ip-up.local

Step # 2: You can call your shell script – /etc/rapp/logtime.sh or any other program from this file by adding following line:
/etc/rapp/logtime.sh

Save and close the file.

Step # 3: Set executable permission
Next set the file executable for the owner:
# chmod 700 /etc/ppp/ip-up.local
Then set the file executable for script – /etc/rapp/logtime.sh
# chmod +x /etc/rapp/logtime.sh

From now on, the file /etc/ppp/ip-up.local will be executed immediately after the ppp0 interface has been brought up by your dialer.

Debian / Ubuntu Linux

Under Debian / Ubuntu Linux put your script in /etc/ppp/ip-up.d/ directory itself. /etc/ppp/ip-up script is run by the pppd after the link is established. It uses run-parts to run scripts in /etc/ppp/ip-up.d you should create script(s) there.
# cp /etc/rapp/logtime.sh /etc/ppp/ip-up.d/
# chmod +x /etc/ppp/ip-up.d/logtime.sh

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
5 comments… add one
  • Jevin Ramjattan Apr 4, 2007 @ 15:09

    will this work for an ethernet connection as well or only for ppp? how do i get a script to run each time eth0 comes up [i’m using a fedora core 6 system]

  • 🐧 nixCraft Apr 4, 2007 @ 17:11

    Jevin,

    Use /etc/eth0/ip-up.local file

    HTH

  • Jevin Ramjattan Apr 4, 2007 @ 21:05

    there is no such file [ip-up.local] or directory [/etc/eth0] ins fedora core 6.

  • Evgeny Oct 12, 2009 @ 12:38

    How I should do the same in OpenSuSE 11.0?
    Scripts is not running from /etc/ppp/ip-up.d, when the interface ppp0 is up.

  • Andy Mason Jan 14, 2010 @ 16:41

    If running from /etc/ppp/ip-up.d (or ip-down.d), you can’t have a . in the script name (a restriction of the default settings for run-parts). You can test which scripts will be run with
    “run-parts –test /etc/ppp/ip-up.d”

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.