Статьи‎ > ‎

Мобильный Internet

В данной заметке я опишу порядок настроки GPRS в некоторых дистрибутивах Linux без использования графических средств.


Debian


Создаем файл /etc/ppp/peers/tele2
/dev/ttyACM0
57600
noauth
defaultroute
usepeerdns
persist
noipdefault
lock
connect '/usr/sbin/chat -v -f /etc/chatscripts/tele2-connect'
novjccomp
nopcomp
noaccomp
noipdefault
nodeflate
novj
defaultroute - установить маршрутом "по умолчанию"
noipdefault - не использовать IP адрес, назначенный для данного hostname
persist - восстанавливать соединение при разрыве
updetach - `возвратить управление` процессу, вызвавшему pppd, при успешно установленном соединение
usepeerdns - получить DNS адреса от сервера (потребуется при настройке pdnsd)

Создаем файл /etc/chatscripts/tele2-connect
TIMEOUT 45
ABORT 'NO ANSWER'
ABORT 'BUSY'
ABORT 'NO CARRIER'
SAY 'Starting GPRS connection\n'
ABORT ERROR
"" 'ATZ'
"" 'ATE1'
OK AT+CGDCONT=1,"IP","internet.tele2.ru"
OK ATD*99***1#
CONNECT c

Подключение производится командами
# pppd call tele2
или
# pon tele2
Проверяется наличие подключения выводом команды ifconfig
ppp0      Link encap:Point-to-Point Protocol 
          inet addr:90.140.34.106  P-t-P:192.200.1.21  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:3 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:54 (54.0 B)  TX bytes:61 (61.0 B)
Отключение производится командой
# poff tele2

Gentoo

Создаем символическую ссылку для скрипта инициализации нашего соединения
# ln -s /etc/init.d/net.lo /etc/init.d/net.ppp0
Конфигурируем соединение в файле /etc/conf.d/net
config_ppp0=("ppp")
link_ppp0="/dev/ttyACM0"
username_ppp0='tele2'
password_ppp0='tele2'
pppd_ppp0=(
 # "maxfail 0" # WARNING: It's not recommended you use this
 #   # if you don't specify maxfail then we assume 0
  "updetach"  # If not set, "/etc/init.d/net.ppp0 start" will return
 #   # immediately,  without waiting the link to come up
 #   # for the first time.
 #   # Do not use it for dial-on-demand links!
  "debug"  # Enables syslog debugging
  "noauth" # Do not require the peer to authenticate itself
  "defaultroute" # Make this PPP interface the default route
  "usepeerdns" # Use the DNS settings provided by PPP
 #
 # On demand options
 # "demand"  # Enable dial on demand
 # "idle 30"  # Link goes down after 30 seconds of inactivity
 # "10.112.112.112:10.112.112.113" # Phony IP addresses
  "ipcp-accept-remote" # Accept the peers idea of remote address
  "ipcp-accept-local" # Accept the peers idea of local address
  "holdoff 3"  # Wait 3 seconds after link dies before re-starting
#
# Dead peer detection
# "lcp-echo-interval 15" # Send a LCP echo every 15 seconds
# "lcp-echo-failure 3" # Make peer dead after 3 consective
#    # echo-requests
#
# Compression options - use these to completely disable compression
 novj
    noaccomp noccp nobsdcomp nodeflate nopcomp novjccomp
#
# Dial-up settings
  "lock"    # Lock serial port
#"115200"   # Set the serial port baud rate
  "modem crtscts"   # Enable hardware flow control
 # "192.168.0.1:192.168.0.2" # Local and remote IP addresses
)
phone_number_ppp0=( "*99***1#" ) # Maximum 2 phone numbers are supported
 # They will also need a chat script - here's a good one
chat_ppp0=(
 # 'ABORT' 'BUSY'
  'ABORT' 'ERROR'
 # 'ABORT' 'NO ANSWER'
 # 'ABORT' 'NO CARRIER'
 # 'ABORT' 'NO DIALTONE'
 # 'ABORT' 'Invalid Login'
 # 'ABORT' 'Login incorrect'
  'TIMEOUT' '5'
  '' 'AT+CMEE=1'
#  '' 'AT+IPR=115200'
  'OK' 'ATZ'
  'OK' 'AT+CGDCONT=1,"IP","internet.tele2.ru"' # Put your modem initialization string here
  'OK' 'ATDT\T'
  'TIMEOUT' '60'
  'CONNECT' ''
  'TIMEOUT' '5'
  '~--' ''
)

Запускаем соединение
# /etc/init.d/net.ppp0 start
Останавливаем
# /etc/init.d/net.ppp0 stop