2 pppoe && routes @ system startup
Добавлено: 19 май 2010, 16:26
Что делает: проверяет на наличие поднятых 2х интерфейсов eth* и потом поднимает 2 рррое и настраивает маршрутизацию.
Код: Выделить всё
#!/bin/bash
# interfaces
gen1us2k_if='eth2'
friday_if='eth1'
gen1us2k_ip='77.235.12.36'
kg_if='ppp0'
un_if='ppp1'
# text redactors
ifc='/sbin/ifconfig'
sed='/bin/sed'
g='/bin/grep'
echo "Test for required interfaces"
# test interfaces
$ifc $gen1us2k_if
ret=$?
if [ "$ret" -ne "0" ]; then
/etc/init.d/net.eth0 start
if [ "$ret" -ne "0" ]; then
echo "Cannot configure interface, please do it by your hands"
exit [1]
fi
else
echo "Interface eth0 configured"
fi
$ifc $friday_if
if [ "$ret" -ne "0" ]; then
/etc/init.d/net.eth1 start
if [ "$ret" -ne "0" ]; then
echo "Cannot configure interface, please do it by your hands"
exit [1]
fi
else
echo "Interface eth1 configured"
fi
echo "Test completed sucessfully"
# configuring interfaces
pppd call gen1us2k
sleep 15s
if [ "`$ifc $kg_if | $g addr: | $sed 's/.*addr:\([^ ]*\) .*/\1/'`" -e "$gen1us2k_ip" ]; then
route add -net 77.235.0.0/19 dev $kg_if
route add -net 92.245.96.0/19 dev $kg_if
route add -net 109.201.160.0/19 dev $kg_if
route add -net 91.213.233.0/24 dev $kg_if
route add -host 217.29.21.21 dev $kg_if
fi
echo "ppp0 configured sucessfull, Start configuring next ppp interface"
pppd call friday
sleep 15s
if [ "`$ifc $un_if | $g addr: | $sed 's/.*addr:\([^ ]*\) .*/\1/'`" -ne "$gen1us2k_ip" ]; then
route del default dev $un_if
route add default dev $un_if
fi
echo "ppp1 configured sucessfull."
echo "Lets drink a beer ;-)"