# HG changeset patch # User Pascal Bellard # Date 1431253380 -7200 # Node ID 56c606af68bcaf7539aa2ffcd76d07664db51688 # Parent 2f76ffd0c441ade427a0d2e113b20e4d0e140b9a dropbear/sshx, ppp/pppnc-client: add default route support diff -r 2f76ffd0c441 -r 56c606af68bc dropbear/stuff/sshx --- a/dropbear/stuff/sshx Sat May 09 21:58:06 2015 +0200 +++ b/dropbear/stuff/sshx Sun May 10 12:23:00 2015 +0200 @@ -30,14 +30,18 @@ read -s -t 30 DROPBEAR_PASSWORD && export DROPBEAR_PASSWORD $ssh $1 true || exit 1 } - for i in $4 ; do + extra="$(route -n | awk -vd=${1#*@} \ + '$1=="0.0.0.0"{ print d " gw " $2 " dev " $8 }')" + for i in ${4/default/128.0.0.0/1 0.0.0.0/1} ; do echo "route add -net $i dev \$1" done > /etc/ppp/ip-up.d/pppssh$$ + [ "$4" ] && echo "route add $extra" >> /etc/ppp/ip-up.d/pppssh$ chmod +x /etc/ppp/ip-up.d/pppssh$$ n=10.$(($$%256)).$(($$/256)) ppp="/usr/sbin/pppd local noauth nodetach" $ppp ${2:-$n.1:$n.2} passive pty "$ssh $1 $ppp ${3:-proxyarp} notty" \ ipparam pppssh$$ + [ "$4" ] && route del $extra rm -f /etc/ppp/ip-up.d/pppssh$$ } diff -r 2f76ffd0c441 -r 56c606af68bc ppp/stuff/ppp.cgi --- a/ppp/stuff/ppp.cgi Sat May 09 21:58:06 2015 +0200 +++ b/ppp/stuff/ppp.cgi Sun May 10 12:23:00 2015 +0200 @@ -269,7 +269,7 @@ $(_ 'Server routes') - + @@ -328,7 +328,7 @@ $(_ 'Peer routes') - + diff -r 2f76ffd0c441 -r 56c606af68bc ppp/stuff/pppnc-server --- a/ppp/stuff/pppnc-server Sat May 09 21:58:06 2015 +0200 +++ b/ppp/stuff/pppnc-server Sun May 10 12:23:00 2015 +0200 @@ -11,9 +11,12 @@ esac [ -z "$1" ] && echo "Usage: $0 serverip [port] [routes]" && exit 1 -for i in $3 ; do +extra="$(route -n | awk -vd=$1 '$1=="0.0.0.0"{ print d " gw " $2 " dev " $8 }')" +for i in ${3/default/128.0.0.0/1 0.0.0.0/1} ; do echo "route add -net $i dev \$1" done > $ipupd/pppnc$$ +[ "$3" ] && echo "route add $extra" >> $ipupd/pppnc$ chmod +x $ipupd/pppnc$$ $ppp noipdefault pty "nc $1 ${2:-$port}" ipparam pppnc$$ +[ "$3" ] && route del $extra rm -f $ipupd/pppnc$$