点击阅读:宽带、窄带,ADSL、PPPoE、虚拟拨号等名词解释
当初我在虚拟机中第一次安装好 Red Hat,在百度上 Google 了很多次,逛了无数论坛、博客,看了无数帖子和文章,试了各种方法,怎么也找不到让“宽带”连上网的方法。
后来用 Ubuntu 也是这样。Ubuntu 自带的客户端根本连不上网,想找个办法,见到的回答却常常牛头不对马嘴,真是让人气馁。
虽然 Linux 各种发行版的命令大体一样,但有一些地方还是不同的。下面整理一下常见发行版里配置 PPPoE/ADSL 虚拟拨号时会用到的命令。由于发行版版本差异较大,包名、路径和网卡名称请以本机环境为准;操作前可先用 ip link 查看网卡名称,用发行版的软件包管理器确认是否已安装 rp-pppoe 或对应的 PPPoE 客户端。
Table of Contents
Red Hat Linux
Red Hat Linux 下常用的是 ADSL 调制解调器相关命令,用来配置宽带调制解调器工作。
首先检查是否安装了 PPPoE 软件,并确认版本满足需要。旧资料里常见的版本要求是高于 3.5-1。如果版本过低,可以先升级软件版本,例如 rp-pppoe-3.5-3.i386.rpm:
rpm -Uvh rp-pppoe-3.5-3.i386.rpm
友情提示:我认为升级并不是必要的。如果你确定要升级,先在其他电脑上下载合适的 PPPoE 软件包,放在 /home/你的用户名/ 下面,再执行上面的命令即可。注意命令大小写,文件名也要替换成实际下载的文件名。
安装后系统通常会提供下面四个命令:
adsl-setup:配置 DNS、用户账号、密码和其他选项。adsl-start:使用 ADSL 连接互联网。adsl-stop:断开 ADSL 和互联网连接。adsl-status:检测 ADSL 连接状态。
建立 ADSL 连接:
[root@sample ~]# adsl-setup
Welcome to the ADSL client setup. First, I will run some checks on
your system to make sure the PPPoE client is installed properly...
LOGIN NAME
Enter your Login Name (default root):
这里填入 ADSL 连接的用户名。
INTERFACE
Enter the Ethernet interface connected to the ADSL modem
For Solaris, this is likely to be something like /dev/hme0.
For Linux, it will be ethX, where 'X' is a number.
(default eth0):
这里指定网络接入设备。只有一块网卡时,一般使用默认的 eth0。较新的系统可能不再叫 eth0,需要根据 ip link 的输出填写实际网卡名。
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 seconds
after which the link should be dropped. If you want the link to
stay up permanently, enter 'no' (two letters, lower-case.)
NOTE: Demand-activated links do not interact well with dynamic IP
addresses. You may have some problems with demand-activated links.
Enter the demand value (default no):
直接按回车,接受默认设置。
DNS
Please enter the IP address of your ISP's primary DNS server.
If your ISP claims that 'the server will provide dynamic DNS addresses',
enter 'server' (all lower-case) here.
If you just press enter, I will assume you know what you are
doing and not modify your DNS setup.
Enter the DNS information here:
如果知道 DNS 服务器地址,就在这里填入;不知道时可以按回车跳过。旧资料中曾提供《全国 DNS 服务器 IP 地址》下载地址:http://olseeling.qjwm.com/down_1249888.html。
PASSWORD
Please enter your Password:
Please re-enter your Password:
输入并确认 ADSL 连接密码。
USERCTRL
Please enter 'yes' (two letters, lower-case.) if you want to allow
normal user to start or stop DSL connection (default yes): no
填入 no,不允许普通用户控制 PPPoE 连接。
FIREWALLING
Please choose the firewall rules to use. Note that these rules are
very basic. You are strongly encouraged to use a more sophisticated
firewall setup; however, these will provide basic security. If you
are running any servers on your machine, you must choose 'NONE' and
set up firewalling yourself. Otherwise, the firewall rules will deny
access to all standard servers like Web, e-mail, ftp, etc. If you
are using SSH, the rules will block outgoing SSH connections which
allocate a privileged source port.
The firewall choices are:
0 - NONE: This script will not set any firewall rules. You are responsible
for ensuring the security of your machine. You are STRONGLY
recommended to use some kind of firewall rules.
1 - STANDALONE: Appropriate for a basic stand-alone web-surfing workstation
2 - MASQUERADE: Appropriate for a machine acting as an Internet gateway
for a LAN
Choose a type of firewall (0-2): 0
输入 0,表示不在这里使用防火墙。
Start this connection at boot time
Do you want to start this connection at boot time?
Please enter no or yes (default no): yes
填入 yes,在系统启动时自动连接 ADSL。
** Summary of what you entered **
Ethernet Interface: eth0
User name: caun870293@ca.dti.ne.jp
Activate-on-demand: No
DNS: Do not adjust
Firewalling: NONE
User Control: no
Accept these settings and adjust configuration files (y/n)? y
Adjusting /etc/sysconfig/network-scripts/ifcfg-ppp0
Adjusting /etc/ppp/chap-secrets and /etc/ppp/pap-secrets
(But first backing it up to /etc/ppp/chap-secrets.bak)
(But first backing it up to /etc/ppp/pap-secrets.bak)
Congratulations, it should be all set up!
Type '/sbin/ifup ppp0' to bring up your xDSL link and '/sbin/ifdown ppp0'
to bring it down.
Type '/sbin/adsl-status /etc/sysconfig/network-scripts/ifcfg-ppp0'
to see the link status.
配置信息确认无误后,键入 y 同意设置。
启动 ADSL 连接:
adsl-start
稍等片刻,如果启动成功,通常会直接回到命令提示符,没有额外提示也可能表示连接成功。可以再用下面的命令检查:
adsl-status
ip addr show ppp0
route -n
Ubuntu
- 打开应用程序菜单,依次选择“附件”->“终端”。
- 在终端窗口中输入:
sudo pppoeconf
- 系统会提示输入当前 Ubuntu 管理员用户的密码。输入完成后回车。
- 询问网络设备时,一般选择“是”,让程序进行检测,然后继续选择“是”。
- 之后会提示输入 ADSL 用户名和密码。输入账号时,把原来的
user删除后再填写自己的账号;除密码之外,其他问题通常全部回答“是”(Yes)即可。 - 最后会提示是否开机自动拨号。选择“是”(Y)时,默认开机会在没有提示的情况下自动拨号,可以直接上网。选择“否”(N)时,需要拨号时手工进入终端输入:
sudo pon dsl-provider
常用命令如下:
pon:启用 ADSL 连接。poff:结束 ADSL 连接。plog:查看 ADSL 的提示信息,调试时使用。ifconfig ppp0:查看是否有ppp0接口。较新的系统也可以用ip addr show ppp0。route -n:查看默认网关是否正确。nslookup:查看 DNS 是否能够正确解析。
这些命令可以帮助解决 ADSL 上网遇到的问题,也可以用来调试 ADSL 连接。
CentOS
同 Red Hat Linux。
BackTrack Linux
同 Red Hat Linux。
Slax
同 Red Hat Linux。
