Answer the question
In order to leave comments, you need to log in
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
#!/bin/sh
/sbin/route add 192.168.0.0/24 -interface $1
Answer the question
In order to leave comments, you need to log in
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
#!/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 questionAsk a Question
731 491 924 answers to any question