Strange /etc/ppp/auth-up script work

mequasar

New Member
Joined
May 30, 2017
Messages
3
Reaction score
2
Credits
0
Hello everybody!
Sorry for not perfect English.
Need help, I try to execute this script in /etc/ppp/auth-up:
It this file, $1 is interface name like ppp0, ppp1 etc
$2 is peer name (defined in /ppp/chap-secrets)


#Script start
!#/bin/sh

if [ "$2" == "someusername" ]; then
echo $1 >> /var/test
route add -net 192.168.x.x/24 dev $1
fi

After it, in shell
cat /var/test return values like ppp0, ppp1, and condition work, but route don't add.
T.y for any ideas.
 


atanere

Well-Known Member
Joined
Apr 6, 2017
Messages
2,638
Reaction score
2,789
Credits
92
Hello everybody!
Sorry for not perfect English.
Need help, I try to execute this script in /etc/ppp/auth-up:
It this file, $1 is interface name like ppp0, ppp1 etc
$2 is peer name (defined in /ppp/chap-secrets)


#Script start
!#/bin/sh

if [ "$2" == "someusername" ]; then
echo $1 >> /var/test
route add -net 192.168.x.x/24 dev $1
fi

After it, in shell
cat /var/test return values like ppp0, ppp1, and condition work, but route don't add.
T.y for any ideas.

Hi @mequasar, and welcome to the forums! I'm not a networking guru, but glancing at the man pages for route I do not see any examples for the /24 netmask. Have you tried like this instead?

route add -net 192.168.x.x netmask 255.255.255.0 dev $1

Cheers
 
OP
M

mequasar

New Member
Joined
May 30, 2017
Messages
3
Reaction score
2
Credits
0
Hi! Nope, this work in debian
[email protected]:/etc/ppp# route add -net 192.168.120.0/24 dev ppp0
[email protected]:/etc/ppp# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.64.128.1 0.0.0.0 UG 0 0 0 eth0
10.64.128.0 * 255.255.255.0 U 0 0 0 eth0
172.16.32.10 * 255.255.255.255 UH 0 0 0 ppp0
172.16.32.11 * 255.255.255.255 UH 0 0 0 ppp1
172.16.32.12 * 255.255.255.255 UH 0 0 0 ppp2
192.168.120.0 * 255.255.255.0 U 0 0 0 ppp0
[email protected]:/etc/ppp#
 
OP
M

mequasar

New Member
Joined
May 30, 2017
Messages
3
Reaction score
2
Credits
0
I find a solution. Moderators can close thread:
Script /etc/ppp/auth-up work so fast, that ppp devices don't have time to start up.
This is corrected script:

#Script start
!#/bin/sh
if [ "$2" == "someusername" ]; then
echo $1 >> /var/test
sleep 10
route add -net 192.168.x.x/24 dev $1
fi

Thank u.
 

atanere

Well-Known Member
Joined
Apr 6, 2017
Messages
2,638
Reaction score
2,789
Credits
92
Nice job!
 
MALIBAL Linux Laptops

Linux Laptops Custom Built for You
MALIBAL is an innovative computer manufacturer that produces high-performance, custom laptops for Linux.

For more info, visit: https://www.malibal.com


Top