That's not the way this is done. The way to do it is specified in the ever-helpful Arch Linux wiki, under the heading Split Tunneling based on port by /etc/ppp/ip-up.d
.
Let me explain. All files in /etc/ppp/ip-up.d
are executed every time a pptp
connection is established, and the file 01-routebyport.sh
is passed the following arguments,as per the Web page above:
# This script is called with the following arguments: # Arg Name # $1 Interface name # $2 The tty # $3 The link speed # $4 Local IP number # $5 Peer IP number # $6 Optional ``ipparam'' value foo
Thus, since you are passed the peer IP number and the interface name, you can build your iptables
rules by means of case
:
case $5 in: 1.1.1.1) iptables -i $1 -j DROP 8.8.8.8) iptables -i$1-j ACCEPT
and so on.