Linux中国 Linux中国门户站!
设为主页 设为主页
收藏本站 收藏本站
 
当前位置 :首页 ->Linux技术 ->入门与提高 ->正文

Linux下怎么样拨号上网

来源:linuxdby.com 作者:Webmaster 时间:2007-04-12 点击: [收藏] [投稿]
Linux在去年可谓春风得意,现在风头依然很劲,人们逐渐发现在Windows之外还有更好的选择,Lin ux被寄予了厚望,希望有一天它把能够取代Windows,它的创始人Linus Torvalds也成为因特网时代 的英雄。作为天天面对Windows的电脑爱好者来说,对Windows是既爱又恨,因而怎能错过Linux呢?更何 况它是免费的午餐。
  Linux是因特网时代的神话,在Linux系统中各种Internet的软件、工具应有尽有也就不足为奇了 。但是对大多数用户来说,通过Modem拨号上网是联结Internet的唯一途径,在此笔者以Redhat5.1为 例,详细介绍一种拨号上网的方法,希望Linux的新手能够尽快通过Linux去畅游Internet,体会Linu x强大的网络功能,获取更多Linux的知识。

  先假设你的计算机已经安装好了Redhat5.1或者以上版本的Linux,并且Modem已经连接在计算机 上。

  第一步:准备Modem

  需要确定Modem在计算机的哪个串口上。最简单的办法是启动Windows95,在控制面板中察看Mode m的属性;在Linux下有一种简单的办法是:先确认Modem已经连接在计算机上,打开Modem电源,MR、HS 灯应该是亮的,然后在提示符下输入以下命令:

  echo AT>/dev/ttyS0

  如果Modem的TR灯亮了,表明Modem连结在COM1口,否则,再试/dev/ttyS1、/dev/ ttyS2、/dev/ttyS3。

  第二步:准备核心

  版本2.0.34的Linux核心已经内置了PPP功能,在此需要确认一下Linux的版本,如果是Redh at5.1就可以跳过这一步,因为Redhat5.1的内核版本即是2.0.34。否则就可能需要重新编译Linux 内核以便支持PPP。

  第三步:准备拨号脚本

  在RedHat5.1中,已经在/usr/doc/ppp-2.3.3/scripts目录下为我们提供了拨 号脚本程序的样本,需要我们做的是把其拷贝到正确的目录并把其改为可执行文件,具体操作如下:

  cp/usr/doc/ ppp-2.3.3/scripts/ppp-on/usr/sbin

  cp/usr/doc/ ppp-2.3.3/scripts/ppp-off/usr/sbin

  cp/usr/doc/ ppp-2.3.3/scripts/ppp-on-dialer/etc/ppp

  cd/usr/sbin

  chmod+x ppp-on

  chmod+x ppp-off

  cd/etc/ppp

  chmod+x ppp-on-dialer

  然后根据你的ISP做相应的少许改动。以下是笔者所用的两个脚本ppp-on和ppp-on-dialer的 内容:

  ppp-on的内容:

  #!/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 scr ipts as the codes

  # are visible with the'ps' command. However, it is simple.

  #

  # These are the parameters. Change as needed.

  TELEPHONE=96340# ISP提供的上网电话号码

  ACCOUNT=yuangq#账号名称

  PASSWORD=654321#登录密码,注意修改本文件权限以便保密:)

  LOCAL_IP=0.0.0.0#本地IP地址,0.0.0.0表示由ISP动态分配

  REMOTE_IP=0.0.0.0#远端IP地址,一般为0.0.0.0

  NETMASK=255.255.255.0#子网掩码地址

  #

  # 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 th e 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' a ccount would be

  # a security hole so don't ask.)

  #

  DIALER_SCRIPT=/etc/ppp/ppp-on-dialer

  #

  # Initiate the connection

  #

  # I put most of the common options on this command. Please, don't

  # 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. Don't use the'defaultroute' option if you currently

  # have a default route to an ethernet gateway.

  #

  exec/usr/sbin/pppd debug lock modem crtscts/dev/tty S1115200 \

  asyncmap20A0000 escape FF kdebug0$LOCAL_IP:$REMOTE_ IP \

  noipdefault netmask$NETMASK defaultroute connect$DI ALER_SCRIPT&

  ppp-on-dialer的内容:

  #!/bin/sh

  #

  # This is part2 of the ppp-on script. It will perfo rm the connection

  # protocol for the desired connection.

  #

  exec chat-v \

  TIMEOUT3 \

  ABORT'\nBUSY\r' \

  ABORT'\nNO ANSWER\r' \

  ABORT'\nRINGING\r\n\r\nRINGING\r' \

  '' \rAT \

  'OK-+++\c-OK' ATH0 \

  TIMEOUT30 \

 如果您对本文有任何疑问或者建议,请到讨论区发表您的意见: >> 论坛入口 <<



上一篇: Linux的常用网络命令   下一篇: Linux下拨号网络配置

文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论
更多相关文章
Power by linux-cn.com 粤ICP备05006655号