如何在Linux下用ADSL拨号上网
1??首先,你必須安裝相應的ADSL撥號軟件。平常用的redhat發行版本中,帶有pppoe這個rpm包。
我們通過下面的命令實現:
[root@Server root]# rpm -qa|grep pppoe
rp-pppoe-3.4-7
這個命令的輸出來確定系統中是否已經安裝了pppoe這個包。rpm -qa是列出系統中已經安裝的包。通過管道|將這個命令的輸出,作為第二個命令的輸入。grep pppoe是列出包含有pppoe的行。如果返回為空,則說明沒有安裝。如果安裝了,會返回安裝了pppoe的版本號。如果你還沒有安裝的話,通過下面的命令安裝。
[root@Server root]# rpm -ivh redhat/ppp-2.4.1-7.i386.rpm
這樣,你就安裝好了撥號需要的軟件。
2??配置網卡
撥號需要將撥號的網卡設置為動態獲取ip。而動態獲取ip在機器啟動的時候,將會花費很長時間去獲取ip。所以,我們最好將網卡設置不啟動時不激活。(不建議這么做,如果是遠程登陸的話,就很麻煩)一般情況下我們都使用命令netconfig可以方面的配置網絡相關信息。當然,也可以通過修改網卡的配置文件實現:
[root@Server root]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
3??配置撥號軟件
與ADSL相關的一共有四個命令adsl-connect?,adsl-setup,adsl-start,adsl-status,adsl-stop
通過下面這個命令,啟動ADSL設置:
[root@Server root]# 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):
接著,要求我們選擇使用的網絡接口。我們這時候,填入我們剛剛設置的那個網卡。對于大多數只有一個網卡的朋友而言,默認eth0就可以了。
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):
接下來,詢問的是,adsl連接以后,是否持續保持連接。或者是自動的斷開,在指定的時間(以秒數計算)內。多數情況下,我們希望手動的打開關閉連接。所以這里選擇默認的no。
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了。我發現很多時候,pppoe都不能夠正確獲取dns信息。我建議你輸入dns地址。這些信息在isp的網站上一般都有公布。
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.
帳號密碼是必須,輸入兩次。密碼顯示風格和其他的地方一樣,不顯示在屏幕上。這個,我不知道改怎么填寫。太高深的問題了。希望你將你的答案和我分享。:P。
PASSWORD
Please enter your Password:
Please re-enter your Password:
下面的設置,是表示是否允許普通用戶啟用/關閉 ADSL連接。默認是允許。
Please enter 'yes' (two letters, lower-case.) if you want to allow
normal user to start or stop DSL connection (default yes):
我們看下防火墻選項。這里提供的防火墻可以給你提供基本的安全保護。我不推薦你使用——你最好選擇“NONE”選項。無論是什么樣的用戶使用,我都建議你使用額外的工具來配置防火墻規則(iptables目前看來是一個非常不錯的工具)。
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):
是否在開機時,打開這個連接?
Do you want to start this connection at boot time?
所有的配置信息填寫完成之后,系統將給出一個報告,完整的顯示出你輸入的配置信息。如果,你確信你輸入的配置信息是正確的,輸入yes寫入配置文件。輸入no放棄配置。
Summary of what you entered
Ethernet Interface: eth0
User name: root
Activate-on-demand: No
DNS: Do not adjust
Firewalling: NONE
User Control: yes
Accept these settings and adjust configuration files (y/n)?
Please enter no or yes (default no):
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.
測試撥號
現在,我們需要測試下我們的撥號是否配置正確了。
輸入ADSL-start撥號。一般情況下,我會ping 我的ISP的主WWW服務器。比如
ping 61.139.2.69(該地址是電信的DNS服務器)
如果能ping通則說明沒有什么問題
如果不怕麻煩,打開瀏覽器測試下,也可以。如果一切ok。那么我們就可以結束我們的配置了。
當然,你關閉連接的話,使用命令adsl-stop就可以了。
?
故障排除
照上邊的操作步驟配置下來,一般是沒有什么問題的。但是因為Linux沒有Windows那么直觀,出現問題的話,排除故障是非常惱火的。
故障1:無法瀏覽網頁,但是可以ping通DNS服務器地址,多半是在配置的時候DNS服務器地址填錯了。建議檢查一下DNS服務器是否正確。
故障2:用ifconfig查看鏈接,確實出現了三個鏈接,一個eth0,一個lo,一個ppp0,但是就是無法ping通外網,這種情況多出現在手動修改ifcfg-eth0文件,或者用netconfig命令的情況下。
我查看了一下我Windows下和Linux下的路由信息發現少了如下路由,
Network???????Destination????????Netmask??????????Gateway???????Interface?
?0.0.0.0??????????0.0.0.0?????192.168.0.77????192.168.0.77???????1
?注釋:?192.168.0.77?是我windows撥號取得的PPPOE客戶端地址,這條路由的意思是所有的數據包都從77這個端口出去,但是Linux下就沒有這條路由。
后來查了很多資料終于找到了問題所在,因為我的eth0網址信息是我手動修改的,所以就有GATEWAY這一項,?而且我發現路由都是從192.168.0.1這個端口出去的,而我PPP0E客戶端撥號獲得的地址是192.168.0.76,所以這肯定是不對的,怎么解決呢?
將/etc/sysconfig/network文件中的GATEWAY一項用#號注釋掉,
將/etc/sysconfig/network-scipts/ifcfg-eth0文件中的GATEWAY也注釋掉,
重啟撥號,OK了,終于OK了,倒杯茶,點根煙慶祝一下吧!!!
總結
以上是生活随笔為你收集整理的如何在Linux下用ADSL拨号上网的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux并口驱动编程开发
- 下一篇: 计算机设备管理器该文件没有与之,该文件没