LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How to run a script after bringing up a particular network interface (ppp0) (https://www.linuxquestions.org/questions/linux-networking-3/how-to-run-a-script-after-bringing-up-a-particular-network-interface-ppp0-524297/)

polemon 01-31-2007 03:25 AM

How to run a script after bringing up a particular network interface (ppp0)
 
Hi.

Whenever I establish, or reestablish a network connection - ppp0 in particular - I need to upload my IP to a certain place on a server.

Now this upload script works fine, I have set it up so it uploads the IP on boot-time.

But sometimes, my connection gets severed, and I need to upload the new IP again.

Now, how do I make my script run everytime the ppp or any other connection goes up?

Please help.

--polemon

zmanea 01-31-2007 09:33 PM

You could accomplish this a couple of ways.

1. You could run a cron job that runs the script every 5 minutes.

2. You could call the script from /etc/ppp/ip-up

polemon 04-01-2007 08:32 PM

I made something totally different...

But it works fine, so I'll post it here:

I made my own ppp script, ones that handles most of the preliminary work, for uploading my IP to a certain server.

this file is: /etc/ppp/ip-up-post.local

as the name implyes, it is processed _after_ the connection was established, or was tried (and failed) to be established.

That script is only interesting for my DSL connection, so I added it right after the corresponding command in /etc/sysconfig/network-scripts/ifup-ppp:
Code:

(rest of code)...

# check that xDSL connection
if [ "$TYPE" = "xDSL" ] ; then
    if [ -x /sbin/adsl-start -o -x /usr/sbin/adsl-start ] ; then
        adsl-start /etc/sysconfig/network-scripts/$CONFIG
        # run local scripts, for great justice!
        /sbin/runuser - -c /etc/ppp/ip-up-post.local
        exit $?
    else
        logger -p daemon.info -t ifup-ppp \
            $"adsl-start does not exist or is not executable for ${DEVICE}"
        exit 1
    fi
fi

...(rest of code)

works fine!


All times are GMT -5. The time now is 04:17 PM.