Board logo

标题: linux下如何拨号上网 [打印本页]

作者: woshihaike    时间: 2005-6-14 21:28     标题: 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 \
  OK ATDT$TELEPHONE \
  CONNECT';'; \
  sername:--sername:$ACCOUNT \
  assword:$PASSWORD \
需要注意的是,在ppp-on脚本的最后一行用exec启动pppd的参数中,/dev/ttyS1代表Mo dem连结在COM2口上,115200表示Modem的速率,可以根据实际情况进行修改;此外,如果ISP提供的拨号提示不是username,而是login的话,需要将ppp-on-dialer中的sername改为ogin (即把username和login去掉第一个字母)。
  第四步:配置DNS
  为了能够使用WWW浏览器、ftp、Telnet,还必须配置DNS,可以使用netconf命令进行配置,也可以直接修改/etc/resolv.conf文件,例如笔者的该文件内容如下:
  search szonline.net
  nameserver202.96.154.15
  其中第一行表示域名搜索后缀,第二行为ISP提供的DNS服务器的IP地址。
  第五步:开始拨号上网
  上述准备工作完成之后,以root权限登录,开启Modem,运行ppp-on,该脚本将负责拨号、送出登录信息并完成协议验证,当看到Modem上的数据指示灯停止闪烁并保持连接状态的话,ppp就已经连接成功了。你可以用 netstat-r查看路由表或者pppstats检查ppp的状态,也可以通过Ping你的ISP,或者直接启动N etscape浏览器来检查,如果一切正常的话,那么你的Linux已经连接到Internet了。

作者: starlight    时间: 2005-6-14 23:19     标题: linux下如何拨号上网

RH 9.0以后没有那么麻烦
很简单的几步设置就搞定了。。
PS:风灵风之子
作者: 菜菜虫    时间: 2005-7-13 12:36     标题: linux下如何拨号上网

介绍 下9的 步骤如何  谢谢
作者: 风灵风之子    时间: 2005-7-14 00:47     标题: linux下如何拨号上网

在LINUXSIR和LINUXFANS上看了很多关于ADSL的文章,都没有解决我的REDHAT9上ADSL上网的问题,今天实在是没有办法,重新建立连接,曲折的经历,终于上网了(非常激动,可能表达的不是很好),特的写下我的过程,作为参考:
REDHAT默认的PPPOE有问题,需要RPM -E,然后,安装这个www.roaringpenguin.com/pppoe/rp-pppoe-3.5.tar.gz(北南兄推荐)解压和安装:#tar zxvf rp-pppoe-3.5.tar.gz进入解压目录执行#sh ./go
然后再来设置ADSL。这一处,我们要用命令。
#adsl-setup
Welcome to the Roaring Penguin ADSL client setup. First, I will runsome checks on your system to make sure the PPPoE client is installedproperly...
Looks good! Now, please enter some information:
USER NAME
>>> Enter your PPPoE user name (default XXX): 在这里输入ADSL的用户名
INTERFACE
>>> Enter the Ethernet interface connected to the ADSL modemFor Solaris, this is likely to be something like /dev/hme0.For Linux, it will be ethn, where ';n'; is a number.(default eth0):如果一张网卡就设置写上eth0
Do you want the link to come up on demand, or stay up continuously?If you want it to come up on demand, enter the idle time in secondsafter which the link should be dropped. If you want the link tostay up permanently, enter ';no'; (two letters, lower-case.)NOTE: Demand-activated links do not interact well with dynamic IPaddresses. You may have some problems with demand-activated links.>>> Enter the demand value (default no):不用写什么
DNSPlease enter the IP address of your ISP';s primary DNS server.If your ISP claims that ';the server will provide DNS addresses';,enter ';server'; (all lower-case) here.If you just press enter, I will assume you know what you aredoing and not modify your DNS setup.>>> Enter the DNS information here:在这里写上202.96.134.133下一个DNS是202.96.168.68 //这里根据个人不同可以修改
PASSWORD
>>> Please enter your PPPoE password:输入密码>>> Please re-enter your PPPoE password:再输入一次
FIREWALLING
Please choose the firewall rules to use. Note that these rules arevery basic. You are strongly encouraged to use a more sophisticatedfirewall setup; however, these will provide basic security. If youare running any servers on your machine, you must choose ';NONE'; andset up firewalling yourself. Otherwise, the firewall rules will denyaccess to all standard servers like Web, e-mail, ftp, etc. If youare using SSH, the rules will block outgoing SSH connections whichallocate a privileged source port.
The firewall choices are:0 - NONE: This script will not set any firewall rules. You are responsiblefor ensuring the security of your machine. You are STRONGLYrecommended to use some kind of firewall rules.1 - STANDALONE: Appropriate for a basic stand-alone web-surfing workstation2 - MASQUERADE: Appropriate for a machine acting as an Internet gatewayfor a LAN>>> Choose a type of firewall (0-2):这里添写为2
** Summary of what you entered **
Ethernet Interface: eth0User name: XXXActivate-on-demand: NoDNS: Do not adjustFirewalling: MASQUERADE
>>> Accept these settings and adjust configuration files (y/n)?
弄完后,就按一个y键。(以上为北南兄文章里面内容)不要急于连接,REBOOT -N然后进入网络设置,停止ETH1(我的是用他)然后ADSL-STARTPING 你的DNS,如果可以,那么,恭喜你!其中部分内容可能不同,仅作参考,主要在连接后,能够PING通DNS即可!





欢迎光临 黑色海岸线论坛 (http://bbs.thysea.com/) Powered by Discuz! 7.2