调制解调器是串行设备,外置的需要连到一个串口上,内置自己有一个串口。大家知道,UNIX系统对外设的操作都是通过特定的设备文件完成的,Linux下串口设备文件的命名和DOS的关系如下:
DOS COM1 = Linux /dev/cua0 (and /dev/ttyS0)
DOS COM2 = Linux /dev/cua1 (and /dev/ttyS1)
等等。
一般来说/dev/cua*是用来拨出的,/dev/ttyS*是用来拨入的,但现在好像已经不加以区分了,统统用的是/dev/ttyS*。如果你的机器上没有/dev/ttyS*,你需要用mknod来自己建立这些设备文件,但有个脚本程序MAKEDEV可以简化这个工作:
# cd /dev
# ./MAKEDEV ttyS0
拨号服务的电话号码
服务器使用动态 IP 地址分配还是静态的 IP?
ISP 的域名服务器( DNS ) IP 地址是什么 ?
登录服务器时都要回答什么问题?
如果服务器是 Windows NT ,它是否使用微软的 PAP/CHAP 系统 ?
这里可能会有一个问题 Windows 95 系列的拨号设置允许让 DNS 的地址在连线过程中传到客户端。因此你的 ISP 可能会告诉你不需要知道 DNS 服务器的 IP 地址。对于 Linux 来说,它不允许在连线之时动态地指定 DNS 的 IP 地址。所以你需要知道 DNS 地址并自己设置 DNS 。
等一段时间, ppp 连接建立之后,运行 ifconfig ,这是你就会看到 ppp0 的网络接口,并能看出你被分配的 ip 地址和对端服务器的 ip 地址。运行 route ,你会看到对端服务器的 ip 地址也被加入了路由表。好了!你的拨号成功了!此时可以 ping 一下 Internet 上的某个主机的 IP 地址,因该是没问题的。
现在还不能使用域名,因为还没配(废话)。
如果你的机器本身是连在局域网上的,你要确保在拨号之前没有缺省路由,就是在 route 命令中看不到 default 或 0.0.0.0 。原因很简单,拨号会产生一个缺省路由,如果原来就有一个,拨号产生的缺省路由就不起作用,你就不能连到 Internet 上,而还是在局域网里。可以用命令:
route del -net default
你就可以动态的观察各种日志信息,包括 pppd 的调试信息。当你看到:
Jun 23 16:10:31 hxf pppd[1234]: local IP address 210.78.131.151
Jun 23 16:10:31 hxf pppd[1234]: remote IP address 192.168.10.21
--------------------------------------------------------------------------------
#!/bin/sh
#
# Script to initiate a ppp connection. This is the first part of the
# pair of scripts. This is not a secure pair of scripts as the codes
# are visible with the ps command. However, it is simple.
#
# These are the parameters. Change as needed.
TELEPHONE=555-1212 # The telephone number for the connection
ACCOUNT=george # The account name for logon (as in George Burns)
PASSWORD=gracie # The password for this account (and Gracie Allen)
LOCAL_IP=0.0.0.0 # Local IP address if known. Dynamic = 0.0.0.0
REMOTE_IP=0.0.0.0 # Remote IP address if desired. Normally 0.0.0.0
NETMASK=255.255.255.0 # The proper netmask if needed
#
# Export them so that they will be available at ppp-on-dialer time. export TELEPHONE ACCOUNT PASSWORD
#
# This is the location of the script which dials the phone and logs
# in. Please use the absolute file name as the $PATH variable is not
# used on the connect option. (To do so on a root account would be
# a security hole so dont ask.)
#
DIALER_SCRIPT=/etc/ppp/ppp-on-dialer
#
# Initiate the connection
#
# I put most of the common options on this command. Please, dont
# forget the lock option or some programs such as mgetty will not
# work. The asyncmap and escape will permit the PPP link to work with
# a telnet or rlogin connection. You are welcome to make any changes
# as desired. Dont use the defaultroute option if you currently
# have a default route to an ethernet gateway.
#
exec /usr/sbin/pppd debug lock modem crtscts /dev/ttyS0 38400
asyncmap 20A0000 escape FF kdebug 0 $LOCAL_IPREMOTE_IP
noipdefault netmask $NETMASK defaultroute connect $DIALER_SCRIPT
--------------------------------------------------------------------------------
#!/bin/sh
#
# This is part 2 of the ppp-on script. It will perform the connection
# protocol for the desired connection.
#
exec chat -v
TIMEOUT 3
ABORT BUSY
ABORT NO ANSWER
ABORT RINGING RINGING
AT
OK-+++c-OK ATH0
TIMEOUT 30
OK ATDT$TELEPHONE
CONNECT
ogin:--ogin: $ACCOUNT
assword: $PASSWORD