K
K
ka-may2021-10-12 11:05:21
linux
ka-may, 2021-10-12 11:05:21

What variables can be used in the ip-up script?

Good afternoon!
I have several VPN connections on macOS and the task is to automatically add the appropriate route to the network behind the VPN.
I took as a basis the common implementation of the script. Created an ip-up file with launch rights in the /etc/ppp folder:

#!/bin/sh
VPNWORK="192.168.44.1"; #обьявляем переменную (например по названию VPN подключения)
if [ $IPREMOTE = $VPNWORK ] #проверяем, если совпадает добавляем маршрут
then
/sbin/route -n add -net 192.168.10.0/24 $IPREMOTE > /tmp/ppp.log 2>&1
fi

But the script did not work, I suspect that the problem is in the $IPREMOTE variable, since the script:
#!/bin/sh
/sbin/route add 192.168.0.0/24 -interface $1

It works, but it doesn't give variability since I can have different subnets behind the VPN.
The question is, where do the variables from the scripts above come from: $1, $IPREMOTE, it is clear that they are predefined, but where can I read their list with a description?

macOS Big Sur

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hint000, 2021-10-12
@ka-may

In my Linux, the regular /etc/ppp/ip-up starts with comments:

#!/bin/sh
#
# This script is run by the pppd after the link is established.
# It uses run-parts to run scripts in /etc/ppp/ip-up.d, so to add routes,
# set IP address, run the mailq etc. you should create script(s) there.
#
# Be aware that other packages may include /etc/ppp/ip-up.d scripts (named
# after that package), so choose local script names with that in mind.
#
# This script is called with the following arguments:
#    Arg  Name                          Example
#    $1   Interface name                ppp0
#    $2   The tty                       ttyS1
#    $3   The link speed                38400
#    $4   Local IP number               12.34.56.78
#    $5   Peer  IP number               12.34.56.99
#    $6   Optional ``ipparam'' value    foo

And by the way, I recommend not to replace the regular file, but leave it alone, and put your ip-up.local script next to /etc/ppp/

K
ka-may, 2021-10-12
@ka-may

#!/bin/sh
VPNWORK="172.16.2.99"; #declaring a variable (for example, by the name of the VPN subkey$
if [ $4 = $VPNWORK ] #check if it matches, add the route
then
/sbin/route -n add -net 192.168.1.0/24 $4 > /tmp/ppp.log 2>&1
fi
Everything worked with this script, how to determine the required variable is indicated in the comments to the question

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question