歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux資訊 >> Linux文化 >> 做個ADSL+LINUX軟路由器

做個ADSL+LINUX軟路由器

日期:2017/2/27 12:15:18   编辑:Linux文化

  本解決方案主要針對公司、學校、網吧等需用一條ADSL將整個局網連上INTERNET,適合於10 -50台計算機的中小型網絡用戶。對於10台以下計算機的用WINAGTE、SYGATE就蠻好用。

  讓我們來看看具體環境先,某公司總部辦公室21間、計算機30台。組成10-100MB對等局域網,用一條ADSL寬帶線路跑,以前用WINGATE將局域網連上INTERNET,後來覺得不爽我又用WINDOWS2000雙網卡做了個NAT地址轉換,使用網關和透明協議拖。這下下感覺舒服些了。呵呵,用了不久又發現些不大不小的毛病:比如內部互發OICQ慢啊,訪問SINA.COM.CN等個別網站有問題啊等等。MS的東東看似簡單但是當你想微調一下系統的時候,你就會突然發現原來人生多麼無奈啊。痛定思痛!:(我毅然決定放棄WINDOWS2000,改用LINUX!!

要用LINUX得搞台機器吧,東拼西湊好不容易搞了一台。各位看官請看: INTEL FX主板+PENTIUM 75芯片+16MB內存+540MB硬盤+512K顯卡+DE220 10MB網卡。軟件嘛隨便找個LINUX發行版,我手頭有REDHAT 6.2 核心是2.2.14,按SERVER的安裝方式,經過長達48分鐘左右的安裝,可愛的#提示符出現在大家面前!各位看客也可以根據自己的具體情況安裝。

  硬件、軟件都裝好了,下面開始具體配置。(加了#提示符號表示輸入命令)

1、用ifconfig看看網絡配置

[root@localhost /root]#ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:3924 Metric:1
RX packets:23 errors:0 dropped:0 overruns:0 frame:0
TX packets:23 errors:0 dropped:0 overruns:0 carrier:0

  只有lo沒找到網卡。不急,自己配。我是DLINK的DE220 IRQ=3 IO=300,兼容NE2000。在/etc/conf.modules 加兩句。

具體如下:

[root@localhost /root]#cd /etc
[root@localhost /root]#vi conf.modules
alias eth0 ne
options eth0 io=0x300 irq=3

IO和IRQ可以根據你自己的網卡設置

如果不能插入就按INSERT,加完就按ESC。再按: ,再輸入w 存盤,再q 退出。如果不放心就 #more conf.modules 看看寫進去沒有。

一般市面上ISA的便宜網卡都兼容NE2000。如果是新手在LINUX下安裝網卡的可能會遇到這樣那樣的問題,多在網上找找看看,一般都能解決。要提醒大家最好別用PNP即插即用模式,在LINUX出了問題不好解決,簡直是場噩夢。

2、下面配置網卡IP地址, 在/etc/sysconfig/network-scripts下有個文件

ifcfg-eth0 寫成如下:

DEVICE=eth0
IPADDR=192.168.0.254

這是網卡的IP地址,以後客戶機的網關就是這個地址。

NETMASK=255.255.255.0
NETWORK=192.168.0.0
BROADCAST=192.168.0.255
ONBOOT=yes
BOOTPROTO=none

重起就能找到網卡。

我們再[root@localhost /root]#ifconfig
eth0 Link encap:Ethernet HWaddr 00:40:05:64:11:28
   inet addr:192.168.0.254 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:347573 errors:0 dropped:0 overruns:0 frame:0
TX packets:40194 errors:0 dropped:0 overruns:0 carrier:0
collisions:35 txqueuelen:100
Interrupt:3 Base address:0x300

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:3924 Metric:1
RX packets:23 errors:0 dropped:0 overruns:0 frame:0
TX packets:23 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0

哈哈,eth0找到網卡了,配置也正確,恭喜恭喜!進行下一步。


3、下一步做ADSL的驅動。去http://www.roaringpenguin.com/pppoe/rp-pppoe-2.6.tar.gz 下個驅動程序先,大概85K大小。 考到/root去。

然後 #tar xvfz rp-pppoe-2.6.tar.gz
#cd rp-pppoe-2.6
#./go

開始安裝,裝好就#make一下下,開始配置ADSL。

Welcome to the Roaring Penguin ADSL 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):
這裡輸入在電信局申請的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 ethn, where 'n' is a number.(default eth0):
問你用哪片網卡撥號,默認是第一片eth0就可以了

4、最後一步:配置ipchains偽裝IP。

在 /etc/sysconfig的network文件裡保證要有這句: FORWARD_IPV4=true

然後改/etc/rc.d/rc.local這個文件,加入以下內容

>> Enter the demand value (default no):
用缺省的no就可以了。

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:
這裡填你ISP的DNS地址,成都用61.139.2.69,輔助DNS成都可用202.98.127.32

PASSWORD
>>> Please enter your PPPoE password:
ADSL撥號密碼這個東東。

搞定!爽爽,用#adsl-start 就可以開始撥號。如果連接成功系統會提示你:…….connect

用ifconfig看看。[root@localhost /root]# ifconfig

eth0 Link encap:Ethernet HWaddr 00:40:05:64:11:28
inet addr:192.168.0.254 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:347573 errors:0 dropped:0 overruns:0 frame:0
TX packets:40194 errors:0 dropped:0 overruns:0 carrier:0
collisions:35 txqueuelen:100
Interrupt:3 Base address:0x300

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:3924 Metric:1
RX packets:23 errors:0 dropped:0 overruns:0 frame:0
TX packets:23 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0

ppp0 Link encap:Point-to-Point Protocol
inet addr:61.157.91.227 P-t-P:61.157.91.1 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1
RX packets:20498 errors:0 dropped:0 overruns:0 frame:0
TX packets:19187 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:10

看見ppp0沒有!


摘自:http://www.oso.com.cn


Copyright © Linux教程網 All Rights Reserved