歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux服務器

linux下用wvdial實現gprs撥號上網

1. 安裝wvdial

  sudo apt-get install wvdial

  2. 在/etc/wvdial.conf中寫入wvdial的配置信息: femacs /etc/wvdial.conf

  Init1 = ATZ

  Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0

  Init3 = AT+CGDCONT=1,"IP","CMNET"  ##important! 否則無法使用DNS

  Modem Type = Analog Modem

  Baud = 115200  ##根據你的gprs modem來設定

  New PPPD = yes

  Modem = /dev/ttyS0 ##你所連接的串口

  ISDN = 0

  Phone = *99***1#  ##中國移動的撥號號碼

  Password = ***    ##其實沒什麼用

  Username = itlanger

  這一步,可以首先運行wvdial,這時會出現找不到modem,然後修改/etc/wvdial.conf, 增加

  Baud = 115200  ##根據你的gprs modem來設定

  Modem = /dev/ttyS0 ##你所連接的串口

  然後再次運行wvdial, 再手動加入一下內容到/etc/wvdial.conf:

  Init3 = AT+CGDCONT=1,"IP","CMNET"

  Phone = *99***1#  ##中國移動的撥號號碼

  Password = ***    ##其實沒什麼用

  Username = itlanger

  這裡Init3 = AT+CGDCONT=1,"IP","CMNET" 一定要加,否則wvdial撥號時會出現:

  warning, can't find address for `www.suse.de`

  --> warning, address lookup does not work

  --> Nameserver (DNS) failure, the connection may not work.

  導致只能ping通IP,不能ping通域名

  3. 配置ppp參數: femacs /etc/ppp/options

  noipdefault

  ipcp-accept-local

  ipcp-accept-remote

  defaultroute

  noauth

  crtscts

  debug

  4.撥號上網: sudo wvdial

  --> WvDial: Internet dialer version 1.60

  --> Initializing modem.

  --> Sending: ATZ

  ATZ

  OK

  --> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0

  ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0

  OK

  --> Sending: AT+CGDCONT=1,"IP","CMNET"

  AT+CGDCONT=1,"IP","CMNET"

  OK

  --> Modem initialized.

  --> Sending: ATDT*99***1#

  --> Waiting for carrier.

  ATDT*99***1#

  CONNECT

  ~[7f]}#@!}!}#} }9}"}&} }*} } }'}"}(}"}%}&K_{}$}#}%B#}%<e~

  --> Carrier detected.  Waiting for prompt.

  ~[7f]}#@!}!}#} }9}"}&} }*} } }'}"}(}"}%}&K_{}$}#}%B#}%<e~

  --> PPP negotiation detected.

  --> Starting pppd at Tue Dec 15 11:19:14 2009

  --> Pid of pppd: 6666

  --> Using interface ppp0

  --> Authentication (CHAP) started

  --> Authentication (CHAP) successful

  --> local  IP address 10.24.229.233

  --> remote IP address 192.168.254.254

  --> primary   DNS address 211.137.160.5

  --> secondary DNS address 211.136.17.107

  --> Script /etc/ppp/ip-up run successful

  --> Default route Ok.

  --> Nameserver (DNS) Ok.

  --> Connected... Press Ctrl-C to disconnect

  4. 斷開以太網連接:

  sudo ifconfig eth0 down

  sudo route add default g

w 10.24.229.233 ##這裡是ppp0的IP

  5. 測試網絡:

  ping 60.28.166.84

  ping www.chinaunix.net

  如果ping不通域名,可以cat /etc/resolv.conf

  然後寫入撥號獲得的DNS

Copyright © Linux教程網 All Rights Reserved