CentOS 6.4 撥號上網全攻略,不行你打我~

注:這裏是物理機上網教程,不是虛擬機,虛擬機沒這麼麻煩~

本文是吐槽和教程的混合體,所以各位看官耐心看~


    CentOS上網真是個麻煩的事情,它不像Ubuntu一樣在安裝時就能配置好網絡,它會出現各種問題。

首先我的電腦直接插網線後,ifconfig顯示找不到eth0。後來仔細一看網線接口根本不亮!後來找了半天終於把驅動找到了,裝完驅動插入內核模塊後,網線接口亮了,ifconfig也能顯示eth0了,說明硬件搞定。【該步驟詳情參考這裏http://blog.csdn.net/mirage1993/article/details/41961933 】


    下面是重點,我折騰了半天還是上不去網,後來發現了一些教程說安裝一個叫rp-pppoe的撥號軟件,於是我安裝了,結果還是不行,NetworkManager和network服務重啓了無數次還是不行,setup裏面改了又改還是不行,我以爲要用DHCP服務,還特地安裝了DHCP,結果配置不了,比較複雜,畢竟我課程還沒到網絡原理~於是在撥號失敗,DHCP又不會配置時我崩潰了,放棄了一段時間。今晚再次想起來了,心想一定要搞死它! 百度個渣渣搜不到資料,那就來Google。搜了一篇文章,裏面說rp-pppoe不需要NetworkManager,可以卸載NetworkManager,我心想,我讀書少你可別騙我,NetworkManager卸載後連個網絡圖標都沒了,還連個毛毛網。

    看完後不敢輕信,但又想試試,於是結合另一篇教程,開始了終極實驗。我特地準備了四個DNS地址,我下決心不用DHCP了,因爲從百度百科上看DHCP用於配置局域網,我反正又不用路由器。


四個DNS分別爲:

百度公共DNS:180.76.76.76

阿里雲公共DNS:223.5.5.5、223.6.6.6

四川省成都市教育網DNS(博主在成都上學):202.115.64.34

然後開終端,配置rp-pppoe,運行命令

pppoe-setup

以下爲具體過程(#後面的中文是我寫的註釋):

[root@KD src]# pppoe-setup 
Welcome to the Roaring Penguin PPPoE client setup.  First, I will run
some checks on your system to make sure the PPPoE client is installed
properly...

Looks good!  Now, please enter some information:

USER NAME

>>> Enter your PPPoE user name (default bp20122999@cer): #帳號填你的帳號(教育網、網通、電信均可)

INTERFACE

>>> Enter the Ethernet interface connected to the DSL modem
For Solaris, this is likely to be something like /dev/hme0.
For Linux, it will be ethn, where 'n' is a number.
(default eth0):                                         #默認爲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 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 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: 223.5.5.5            #主DNS(上面四個DNS選一個,自己搞其他的也行)
Please enter the IP address of your ISP's secondary DNS server.
If you just press enter, I will assume there is only one DNS server.
>>> Enter the secondary DNS server address here: 223.6.6.6    #備用DNS

PASSWORD

>>> Please enter your PPPoE password:                    #你滴密碼
>>> Please re-enter your PPPoE password:                 #再輸一次

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,不開啓防火牆

** Summary of what you entered **

Ethernet Interface: eth0
User name:          bp20122999@cer
Activate-on-demand: No
Primary DNS:        223.5.5.5
Secondary DNS:      223.6.6.6
Firewalling:        NONE

>>> Accept these settings and adjust configuration files (y/n)? y    #輸入y回車確認
Adjusting /etc/ppp/pppoe.conf
Adjusting /etc/resolv.conf
  (But first backing it up to /etc/resolv.conf-bak)
Adjusting /etc/ppp/pap-secrets and /etc/ppp/chap-secrets
  (But first backing it up to /etc/ppp/pap-secrets-bak)
  (But first backing it up to /etc/ppp/chap-secrets-bak)



Congratulations, it should be all set up!

Type 'pppoe-start' to bring up your PPPoE link and 'pppoe-stop' to bring
it down.  Type 'pppoe-status' to see the link status.

    別急,我先吐吐苦水再寫教程,之後我又走了彎路,我撥號後,還是不行,奇怪的是可以ping通DNS服務器,但是ping不通百度等。

    這時我想起了那篇繁體中文教程的話,於是

先把NetworkManager廢了再說,

[root@KD src]# service NetworkManager stop
Stopping NetworkManager daemon:                            [  OK  ]

然後pppoe-start撥號!顯示

[root@KD src]# pppoe-start
.. Connected!

再然後還是不能ping通百度,沒關係,我們重啓network服務,在此之前先斷了撥號

[root@KD src]# pppoe-stop
Killing pppd (3449)
Killing pppoe-connect (3433)

現在重啓下network服務

[root@KD src]# service network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:                                [  OK  ]

現在,再次撥號!!!

[root@KD src]# pppoe-start
.. Connected!

現在ping百度!!!

[root@KD src]# ping www.baidu.com
PING www.a.shifen.com (119.75.217.56) 56(84) bytes of data.
64 bytes from 119.75.217.56: icmp_seq=1 ttl=47 time=58.7 ms
64 bytes from 119.75.217.56: icmp_seq=2 ttl=47 time=58.2 ms
64 bytes from 119.75.217.56: icmp_seq=3 ttl=47 time=58.9 ms
64 bytes from 119.75.217.56: icmp_seq=4 ttl=47 time=58.9 ms

ping通了!終於好了,當我看到網頁一開始是一個圈,等我pppoe-start後突然出現百度頁面時真特麼是高興壞了。

附錄:

pppoe-start:撥號聯網

pppoe-stop:斷網

pppoe-status:查看連接狀態

電腦重起後請再次stop掉NetworkManager,或者直接卸了它,然後再撥號。

這是終極教程,幾乎涵蓋了各個細節,如果還遇到故障可以給我評論~



發佈了51 篇原創文章 · 獲贊 14 · 訪問量 11萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章