上一篇说了wvdial,很简单吧。实际上wvdial隐藏了很多东西,用pppd来看看真实的拨号过程吧:

其实modem拨号认证的方式有两种,一种是显示明文的login:(username:)方式,另一种是显示乱码的pap(chap)方式。

①首先:

vi /etc/ppp/options  
lock  
crtscts  
defaultroute  
noauth  

②清理一下老的连接:

killall pppd  
rm /var/lock/LCK..ttyS0  

③找出认证的方式:

/usr/sbin/pppd /dev/ttyS0 115200 debug connect
 "/usr/sbin/chat -v   ''   'AT&F0'   OK
ATD0,28929191   CONNECT   'dc' "  

less /var/log/messages

如果看见什么login username之流的那就是明文认证,如果类似下面的,看见了,那就是pap(chap)方式。

pppd 2.4.2 started by root, uid 0  
Removed stale lock on ttyS0 (pid 3561)  
send (AT^M)  
expect (OK)  
AT^M^M  
OK  
-- got it
send (ATD0,28929191^M)  
expect (CONNECT)  
^M
ATD0,28929191^M^M  
CONNECT  
-- got it
send (d)  
Serial connection established.  
using channel 2  
Using interface ppp0  
Connect: ppp0 <--> /dev/ttyS0  
sent [LCP ConfReq id=0x1 <mru 552> <asyncmap 0x0> <magic 0x3947d7a8> <pcomp> <accomp>]  
rcvd [LCP ConfReq id=0x1 <mru 1500> <asyncmap 0x0> <auth chap MD5> <magic 0xebe7666>]  
sent [LCP ConfAck id=0x1 <mru 1500> <asyncmap 0x0> <auth chap MD5> <magic 0xebe7666>]  
sent [LCP ConfReq id=0x1 <mru 552> <asyncmap 0x0> <magic 0x3947d7a8> <pcomp> <accomp>]  
sent [LCP ConfReq id=0x1 <mru 552> <asyncmap 0x0> <magic 0x3947d7a8> <pcomp> <accomp>]  
rcvd [LCP ConfReq id=0x2 <mru 1500> <asyncmap 0x0> <auth chap MD5> <magic 0x125e3a73>]  
sent [LCP ConfAck id=0x2 <mru 1500> <asyncmap 0x0> <auth chap MD5> <magic 0x125e3a73>]  

如果是明文认证:

/usr/sbin/pppd /dev/ttyS0 115200 debug connect
"/usr/sbin/chat -v   ''  ATDT0,28929191  CONNECT
''  ogin:  ttt  assword:  qqq"  

如果是pap(chap)认证:

/usr/sbin/pppd /dev/ttyS0 115200 debug
user ttt connect "/usr/sbin/chat -v '' ATDT0,28929191 CONNECT 'dc' "  

看出区别了吧,pap(chap)跟明文的区别就在于多了一个 user ttt 的参数。 这就是pppd拨号的详细过程了,断掉拨号连接就用killall pppd即可。 大家可以把这么长的一行命令写到sh里,就好看了。

comments powered by Disqus