wok-current view ppp/stuff/pppnc-server @ rev 18556

Up slitaz-tools(953)
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sun Nov 08 01:42:35 2015 +0200 (2015-11-08)
parents e726e3214807
children 1ae2567134a8
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 \
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$$