Дальше создаем соединение pppd (к Мегафону).
Для этого убиваем(или бэкапим всё из папки /etc/ppp)
rm -rf /etc/ppp/*
дальше создаем необходимые для соединения файлы и папки:
touch /etc/ppp/gprs-options
mkdir /etc/ppp/chatscripts
touch /etc/ppp/chatscripts/gprs-megafon-con
touch /etc/ppp/chatscripts/gprs-megafon-dis
mkdir /etc/ppp/peers
touch /etc/ppp/peers/gprs-megafon
вот сами файлы:
cat /etc/ppp/gprs-options
usepeerdns
defaultroute
modem
crtscts
persist
maxfail 10
#mtu 1500
#ipcp-accept-local
#ipcp-accept-remote
#noipdefault
lcp-echo-interval 10
lcp-echo-failure 2
lock
logfile /var/log/gprs.log
cat /etc/ppp/peers/gprs-megafon
kdebug 0
noauth
/dev/ttyUSB2
# Serial port line speed and options
#115200
# Generic GPRS options
file /etc/ppp/gprs-options
# Chat scripts
connect "/usr/sbin/chat -f /etc/ppp/chatscripts/gprs-megafon-con"
disconnect "/usr/sbin/chat -f /etc/ppp/chatscripts/gprs-megafon-dis"
cat /etc/ppp/chatscripts/gprs-megafon-con
ABORT 'BUSY'
ABORT 'NO ANSWER'
ABORT 'NO CARRIER'
ABORT 'NO DIALTONE'
SAY "GPRS modem init"
'' 'AT+ZOPRT=5'
'' 'AT+ZSTART'
'' 'AT+CPBS="SM"'
'' 'AT+CPMS="SM","SM",""'
SAY '\n + Enter APN'
OK 'AT+CGDCONT=1,"IP","internet"'
SAY "\n + attaching to GPRS"
OK 'ATDT*99***1#'
SAY "\n + requesting data connection"
CONNECT ''
SAY "\n + connected\n"
cat /etc/ppp/chatscripts/gprs-megafon-dis
ABORT BUSY
ABORT ERROR
ABORT 'NO DIALTONE'
'' '+++\c'
SAY " + sending break"
'' 'ATH'
SAY "\n + dropping data connection"
OK 'AT+CGATT=0'
SAY "\n + disconnecting from GPRS"
OK '\c'
SAY "\n + disconnected"
SAY "\n + sleeping modem"
'' 'AT+ZSTOPT'
'' 'AT+ZOPRT=6'
Дальше запускам pppd командой:
/usr/sbin/pppd call gprs-megafon
Смотрим лог-файл:
cat /var/log/gprs.log
GPRS modem init
+ Enter APN
+ attaching to GPRS
+ requesting data connection
+ connected
Serial connection established.
Using interface ppp0
Connect: ppp0 <--> /dev/ttyUSB2
Could not determine remote IP address: defaulting to 10.64.64.64
local IP address 10.231.150.50
remote IP address 10.64.64.64
primary DNS address 10.78.72.36
secondary DNS address 10.78.72.28
отлично! - проверяем интефесик
ifconfig
ppp0 Link encap:Point-to-Point Protocol
inet addr:10.231.150.50 P-t-P:10.64.64.64 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:146 (146.0 B) TX bytes:185 (185.0 B)
в папке /etc/ppp появился новый файл resolv.conf - в нем адреса ДНС-сервера, добавляем их в /etc/resolv.conf
cat /etc/ppp/resolv.conf >> /etc/resolv.conf
тестим:
ping ya.ru
64 bytes from ya.ru (77.88.21.8): icmp_seq=1 ttl=57 time=841 ms
64 bytes from ya.ru (77.88.21.8): icmp_seq=2 ttl=57 time=401 ms
64 bytes from ya.ru (77.88.21.8): icmp_seq=3 ttl=57 time=410 ms
64 bytes from ya.ru (77.88.21.8): icmp_seq=4 ttl=57 time=411 ms
^C
--- ya.ru ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3000ms
rtt min/avg/max/mdev = 401.817/516.533/841.831/187.850 ms
вот вроде и всё, если хотим убить соединение то:
killall pppd
Я еще настроил службу запуска:
cat /etc/rc.d/rc.gprs
#!/bin/sh
#
# /etc/rc.d/rc.gprs
# Start/stop/restart the GPRS connection
#
gprs_start() {
if [ -x /usr/sbin/pppd ]; then
echo "Start gprs: /usr/sbin/pppd call gprs-megafon"
/usr/sbin/pppd call gprs-megafon
fi
}
gprs_stop() {
killall pppd
}
gprs_restart() {
gprs_stop
sleep 3
gprs_start
}
case "$1" in
'start')
gprs_start
;;
'stop')
gprs_stop
;;
'restart')
gprs_restart
;;
*)
#default is "start"
gprs_start
esac
Вот теперь вроде всё!