Beeline internet Ubuntu Linux: различия между версиями
Внешний вид
Glorin (обсуждение | вклад) Нет описания правки |
Glorin (обсуждение | вклад) Нет описания правки |
||
| Строка 6: | Строка 6: | ||
#get default gw ip | #get default gw ip | ||
BEELINEGWIP=`route -n | grep 'UG[ \t]' | awk '{print $2}' | tail -n 1` | BEELINEGWIP=`route -n | grep 'UG[ \t]' | awk '{print $2}' | tail -n 1` | ||
#get and set routes for BEELINE DNS servers | #get and set routes for BEELINE DNS servers | ||
DNS1=`grep nameserver /etc/resolv.conf | awk '{print $2}' | head -n 1` | DNS1=`grep nameserver /etc/resolv.conf | awk '{print $2}' | head -n 1` | ||
DNS2=`grep nameserver /etc/resolv.conf | awk '{print $2}' | tail -n 1` | DNS2=`grep nameserver /etc/resolv.conf | awk '{print $2}' | tail -n 1` | ||
if [ "$DNS1" != "$DNS2" ]; then | if [ "$DNS1" != "$DNS2" ]; then | ||
ip route add $DNS1 via $BEELINEGWIP | ip route add $DNS1 via $BEELINEGWIP | ||
| Строка 17: | Строка 17: | ||
ip route add $DNS1 via $BEELINEGWIP | ip route add $DNS1 via $BEELINEGWIP | ||
fi | fi | ||
#get ips for tp.internet.beeline.ru, if going to loop comment elif | #get ips for tp.internet.beeline.ru, if going to loop comment elif | ||
while true; do | while true; do | ||
| Строка 32: | Строка 32: | ||
sleep 1 | sleep 1 | ||
done | done | ||
#set routes for l2tp tunnel | #set routes for l2tp tunnel | ||
if [ "$IP1" != "" ]; then | if [ "$IP1" != "" ]; then | ||
| Строка 40: | Строка 40: | ||
ip route add ${IP2}.0/24 via $BEELINEGWIP | ip route add ${IP2}.0/24 via $BEELINEGWIP | ||
fi | fi | ||
#remove default routes | #remove default routes | ||
ip route del default | ip route del default | ||
ip route del $5 dev $1 | ip route del $5 dev $1 | ||
Версия от 17:07, 4 августа 2012
/etc/ppp/ip-up.d/corbina
#!/bin/sh
#get default gw ip
BEELINEGWIP=`route -n | grep 'UG[ \t]' | awk '{print $2}' | tail -n 1`
#get and set routes for BEELINE DNS servers
DNS1=`grep nameserver /etc/resolv.conf | awk '{print $2}' | head -n 1`
DNS2=`grep nameserver /etc/resolv.conf | awk '{print $2}' | tail -n 1`
if [ "$DNS1" != "$DNS2" ]; then
ip route add $DNS1 via $BEELINEGWIP
ip route add $DNS2 via $BEELINEGWIP
else
ip route add $DNS1 via $BEELINEGWIP
fi
#get ips for tp.internet.beeline.ru, if going to loop comment elif
while true; do
IPS=`host tp.internet.beeline.ru | awk '{print $4}' | cut -d. -f1,2,3 | sort -u`
for IP in $IPS
do
if [ "$IP1" == "" ]; then
IP1=$IP
elif [ "$IP1" != "$IP" ] ; then
IP2=$IP
break 2
fi
done
sleep 1
done
#set routes for l2tp tunnel
if [ "$IP1" != "" ]; then
ip route add ${IP1}.0/24 via $BEELINEGWIP
fi
if [ "$IP2" != "" ]; then
ip route add ${IP2}.0/24 via $BEELINEGWIP
fi
#remove default routes
ip route del default
ip route del $5 dev $1