Честно говоря долго не выдумывал :)
Вот информация:
Немного для себя пишу дальнейшее, на всякий случай.
Настройки подключения (рек. провайдером):
Cеть – IP адрес, DNS сервер выдается автоматически
Тип VPN – L2TP
Адрес VPN сервера – tp.internet.beeline.ru
Login <Ваш логин>
Password: <Ваш пароль>
1. Установка пакетов
aptitude install lsb-release pptp-linux xl2tpd
2. Скрипт автонастройки
Скачал отсюда - форум (ссылка №2)На всякий случай залил к себе в гугло-документы. Вот линк.
Скрипт запускаем, при установленных пакетах. Если при этом подключен линк от провайдера - будет еще лучше.
Он задаст вопросы, отвечаем и в ребут.
Файлы настроек, после работы скрипта:
cat /etc/xl2tpd/xl2tpd.conf
[global]
access control = yes
auth file = /etc/ppp/chap-secrets
[lac Corbina]
;lns = tp.internet.beeline.ru
lns = 78.107.1.156
redial = yes
redial timeout = 5
require chap = yes
require authentication = no
name = <Ваш логин>
ppp debug = yes
pppoptfile = /etc/ppp/options.l2tp-corbina-script
require pap = no
autodial = yes
cat /etc/ppp/options.l2tp-corbina-script
unit 0
name <Ваш логин>
remotename L2TP
ipparam Corbina
connect /bin/true
mru 1460
mtu 1460
nodeflate
nobsdcomp
persist
maxfail 0
nopcomp
noaccomp
defaultroute
usepeerdns
noauth
cat /etc/ppp/chap-secrets
<Ваш логин> L2TP
<Ваш пароль> *
cat /etc/ppp/ip-down.d/99l2tp-corbina-script
#!/bin/sh
# This file was generated by L2TP/Corbina Autoconfiguration Script v1.40.
# $1 - PPP interface name, $2 - tty, $3 - PPP link speed, $4 - local IP address, $5 $
LANG=C
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
ALL_PARAMS=$(printf "%s " "$@")
A=0
for I in $ALL_PARAMS
do
A=$(expr $A + 1)
eval PARAM_${A}=$I
done
if [ x"$PARAM_6" = x"Corbina" ]
then
ENABLE_NAT=1
PHYS_IFACE=$(route -n|grep -m 1 '^10\..*0\.0\.0\.0'|awk '{ print $8 }')
DEFAULT_GW=$(route -n|grep -m 1 '^0\.0\.0\.0.*G'|awk '{ print $2 }')
GW_CHECK=$(printf "%s" "$DEFAULT_GW"|grep '^10\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.$
# Fall back to hardcoded values if something is wrong.
[ -z "$PHYS_IFACE" ] && PHYS_IFACE=eth0
[ -z "$GW_CHECK" ] && DEFAULT_GW=10.44.160.1
route del default dev $PARAM_1
route add default gw $DEFAULT_GW dev $PHYS_IFACE
if [ "$ENABLE_NAT" -eq "1" ]
then
iptables -t nat -D POSTROUTING -o $PHYS_IFACE -j MASQUERADE
iptables -t nat -D POSTROUTING -o $PARAM_1 -j MASQUERADE
iptables -D FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp$
fi
kill -15 $(ps ax|grep '/etc/ppp/ip-up.d/99l2tp-corbina-script'|awk '{ print $
fi
exit 0
cat /etc/ppp/ip-up.d/99l2tp-corbina-script
#!/bin/sh
# This file was generated by L2TP/Corbina Autoconfiguration Script v1.40.
# $1 - PPP interface name, $2 - tty, $3 - PPP link speed, $4 - local IP address, $5 - remote IP address, $6 - ipparam
LANG=C
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
ALL_PARAMS=$(printf "%s " "$@")
A=0
for I in $ALL_PARAMS
do
A=$(expr $A + 1)
eval PARAM_${A}=$I
done
### BEGIN WATCHDOG ROUTINE
f_WatchDog () {
while :
do
if [ x"$(cat /var/run/ip-up-local.pid)" = x"$$" ] && [ -n x"$(ps ax|grep "pppd.*options.l2tp-corbina-script"|grep -v 'grep')" ]
then
ping -c 1 -W 1 $PARAM_5 >/dev/null 2>&1
if [ "$?" -ne "0" ]
then
route del -host $PARAM_5 dev $PARAM_1 2>/dev/null
route add -host $PARAM_5 gw $DEFAULT_GW dev $PHYS_IFACE 2>/dev/null
fi
touch -a /etc/resolv.conf
LN_NUM1=$(< /etc/resolv.conf grep -n "^nameserver ${DNS1}$")
LN_NUM2=$(< /etc/resolv.conf grep -n "^nameserver ${DNS2}$")
if [ x"${LN_NUM1%%:*}" != x"1" ] || [ x"${LN_NUM2%%:*}" != x"2" ]
then
sed -i -e '/'$DNS1'/d' -e '/'$DNS2'/d' /etc/resolv.conf
if [ "$(stat -c %s /etc/resolv.conf)" -eq "0" ]
then
printf "%b\n" "nameserver $DNS1" > /etc/resolv.conf
printf "%b\n" "nameserver $DNS2" >> /etc/resolv.conf
else
sed -i -e '1 i\nameserver '"$DNS1"'\nnameserver '"$DNS2"'' /etc/resolv.conf
fi
fi
ping -c 1 -W 1 icann.org >/dev/null 2>&1
if [ "$?" -ne "0" ]
then
while [ -n "$(route -n|grep '^0\.0\.0\.0')" ]
do
route del default
done
route add default dev $PARAM_1
fi
else
return 0
fi
sleep 60
done
}
### END WATCHDOG ROUTINE
if [ x"$PARAM_6" = x"Corbina" ]
then
printf "%b" "$$" > /var/run/ip-up-local.pid
ENABLE_NAT=1
ENABLE_GDNS=0
PHYS_IFACE=$(route -n|grep -m 1 '^10\..*0\.0\.0\.0'|awk '{ print $8 }')
DEFAULT_GW=$(route -n|grep -m 1 '^0\.0\.0\.0.*G'|awk '{ print $2 }')
GW_CHECK=$(printf "%s" "$DEFAULT_GW"|grep '^10\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$')
# Fall back to hardcoded values if something is wrong.
[ -z "$PHYS_IFACE" ] && PHYS_IFACE=eth0
[ -z "$GW_CHECK" ] && DEFAULT_GW=10.44.160.1
### BEGIN PATCH (Static routes parser)
[ -f "/var/lib/l2tp-corbina-script/static-routes" ] && rm -f /var/lib/l2tp-corbina-script/static-routes
v_LeaseFileExt="lease"
find /var/lib/dhc* -type f | grep "\.${v_LeaseFileExt}$" || v_LeaseFileExt="leases"
v_LastLeaseFile=$(find /var/lib/dhc* -type f -printf '%T@ %p\n' | grep "${PHYS_IFACE}.${v_LeaseFileExt}$" | sort -k 1 -n | tail -1 | cut -d' ' -f2)
if [ -n "$v_LastLeaseFile" ]; then
v_ClasslessRoutes=$(grep -m 1 'ms-classless-static-routes' $v_LastLeaseFile | head -1 | cut -d' ' -f5- | sed -e 's/[,;]/ /g')
printf "%s\n" "new_ms_classless_static_routes=\"${v_ClasslessRoutes%?}\"" >> /var/lib/l2tp-corbina-script/static-routes
v_LegacyRoutes=$(grep -m 1 'option static-routes' $v_LastLeaseFile | head -1 | cut -d' ' -f5- | sed -e 's/[,;]/ /g')
printf "%s" "new_static_routes=\"${v_LegacyRoutes%?}\"" >> /var/lib/l2tp-corbina-script/static-routes
bash /etc/dhcp/dhclient-exit-hooks.d/l2tp-corbina-script
fi
### END PATCH (Static routes parser)
route add -host $PARAM_5 gw $DEFAULT_GW dev $PHYS_IFACE
route del default gw $DEFAULT_GW dev $PHYS_IFACE
route add default dev $PARAM_1
if [ "$ENABLE_NAT" -eq "1" ]
then
iptables -t nat -D POSTROUTING -o $PHYS_IFACE -j MASQUERADE 2>/dev/null
iptables -t nat -D POSTROUTING -o $PARAM_1 -j MASQUERADE 2>/dev/null
iptables -D FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu 2>/dev/null
iptables -t nat -A POSTROUTING -o $PHYS_IFACE -j MASQUERADE
iptables -t nat -I POSTROUTING -o $PARAM_1 -j MASQUERADE
iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
fi
if [ "$ENABLE_GDNS" -eq "1" ]
then
DNS1="8.8.8.8"
DNS2="8.8.4.4"
fi
f_WatchDog &
fi
exit 0
Комментариев нет:
Отправить комментарий