wok-next view ppp/stuff/pppnc-server @ rev 19367
Up tazlito (428), links (2.13)
author | Xander Ziiryanoff <psychomaniak@xakep.ru> |
---|---|
date | Thu Aug 04 19:53:20 2016 +0200 (2016-08-04) |
parents | 8e23f5ef2444 |
children |
line source
1 #!/bin/sh
3 ppp="/usr/sbin/pppd local noauth nodetach"
4 port=1111
5 ipupd=/etc/ppp/ip-up.d
7 case "$0" in
8 *server) # Usage: pppnc-server [port] [localip:remoteip]
9 n=10.$(($$%256)).$(($$/256))
10 exec $ppp ${2:-$n.1:$n.2} passive proxyarp pty "nc -ulp ${1:-$port}"
11 esac
13 [ -z "$1" ] && echo "Usage: $0 serverip [port] [routes]" && exit 1
14 extra="$(route -n | awk -vd=$(nslookup ${1#*@} | sed '/::/d' | sed \
15 '$!d;s/.*: \([^ ]*\).*/\1/') '$1=="0.0.0.0"{ print d " gw " $2 " dev " $8 }')"
16 for i in ${3/default/128.0.0.0/1 0.0.0.0/1} ; do
17 echo "route add -net $i dev \$1"
18 done > $ipupd/pppnc$$
19 [ "$3" ] && echo "route add $extra" >> $ipupd/pppnc$$
20 chmod +x $ipupd/pppnc$$
21 $ppp noipdefault pty "nc -u $1 ${2:-$port}" ipparam pppnc$$
22 [ "$3" ] && route del $extra
23 rm -f $ipupd/pppnc$$