Good morning,
Iam new in thes Forum, because its my first time CentOS.
My problem is, when a l2tp connections getting up as pppX interface the server has to run a Script.
I testing the follow things.
at the end of: /etc/sysconfig/network-scripts/ifup-post:
if [ -x /sbin/ifup-script ]; then
echo ${REALDEVICE} ${IPADDR} > /tmp/ifup.log
/sbin/ifup-script ${REALDEVICE} ${IPADDR}
fi
at the end of: /etc/sysconfig/network-scripts/ifup-ppp:
if [ -x /sbin/ifup-script ]; then
echo ${REALDEVICE} ${IPADDR} > /tmp/ifup.log
/sbin/ifup-script ${REALDEVICE} ${IPADDR}
fi
/sbin/ifup-script:
#!/usr/bin/perl
$device = $ARGV[0] or die;
$remip = $ARGV[1] or die;
$device =~ /^ppp(\d+)$/ or die;
($network,$ip) = $remip =~ /^192\.168\.(\d+)\.(\d+)$/ or die;
$ip = $ip - 1;
$network = "192.168.$network.$ip/26";
system( "/sbin/route add -net $network dev $device" );
My problem ist, wenn a pppX "interface" comes up, I found nothing in the logs.
When I reboot the whole system, I only found the information about eth1 and the correct IP-Address of eth1.
But noting about eth0 and the pppX connections.
So I think the script doenst run. Because why, were I have to put in the Lines, to start the script correct?
Thanks für your Support.
Best reguards.
[SOLVED] Run Script after upcomming ppp interface
Re: Run Script after upcomming ppp interface
It's been a while since I've done ppp but I don't think you want to touch any of the system scripts but, rather, you can add "ip-up.local" and "ip-down.local" scripts in /etc/ppp to do all your extra processing in them.
Re: Run Script after upcomming ppp interface
Thank you for your answer.
I test it and now the pppX interface is in the log. But the IP-Address not.
What ist the variable for the IP-Address ${IPADDR} doesnt work in the if-up or if-up.local script.
I test it and now the pppX interface is in the log. But the IP-Address not.
What ist the variable for the IP-Address ${IPADDR} doesnt work in the if-up or if-up.local script.
Re: Run Script after upcomming ppp interface
The man page for pppd has that information. Check out the environment variables that are set but there is also this section that shows the arguments given to ip-up/down:fredo788 wrote:Thank you for your answer.
I test it and now the pppX interface is in the log. But the IP-Address not.
What ist the variable for the IP-Address ${IPADDR} doesnt work in the if-up or if-up.local script.
/etc/ppp/ip-up
A program or script which is executed when the link is available
for sending and receiving IP packets (that is, IPCP has come
up). It is executed with the parameters
interface-name tty-device speed local-IP-address
remote-IP-address ipparam
Re: [SOLVED] Run Script after upcomming ppp interface
Problem Solved.
look at the working Scripts:
/etc/ppp/ip-up.local:
#!/bin/bash
PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH
LOGDEVICE=$6
REALDEVICE=$1
IPADDR=$5
if [ -x /sbin/ifup-my_script ]; then
/sbin/ifup-my_script ${REALDEVICE} ${IPADDR}
fi
exit 0
/sbin/ifup-my_script:
#!/usr/bin/perl
$device = $ARGV[0] or die;
$remip = $ARGV[1] or die;
$device =~ /^ppp(\d+)$/ or die;
($network,$ip) = $remip =~ /^192\.168\.(\d+)\.(\d+)$/ or die;
$ip = $ip - 1;
$network = "192.168.$network.$ip/26";
system( "/sbin/route add -net $network dev $device" );
Thanks for your Support!
look at the working Scripts:
/etc/ppp/ip-up.local:
#!/bin/bash
PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH
LOGDEVICE=$6
REALDEVICE=$1
IPADDR=$5
if [ -x /sbin/ifup-my_script ]; then
/sbin/ifup-my_script ${REALDEVICE} ${IPADDR}
fi
exit 0
/sbin/ifup-my_script:
#!/usr/bin/perl
$device = $ARGV[0] or die;
$remip = $ARGV[1] or die;
$device =~ /^ppp(\d+)$/ or die;
($network,$ip) = $remip =~ /^192\.168\.(\d+)\.(\d+)$/ or die;
$ip = $ip - 1;
$network = "192.168.$network.$ip/26";
system( "/sbin/route add -net $network dev $device" );
Thanks for your Support!