做個(gè)ADSL+LINUX軟路由器
本解決方案主要針對(duì)公司、學(xué)校、網(wǎng)吧等需用一條ADSL將整個(gè)局網(wǎng)連上INTERNET,適合于10 -50臺(tái)計(jì)算機(jī)的中小型網(wǎng)絡(luò)用戶。對(duì)于10臺(tái)以下計(jì)算機(jī)的用WINAGTE、SYGATE就蠻好用。
讓我們來看看具體環(huán)境先,某公司總部辦公室21間、計(jì)算機(jī)30臺(tái)。組成10-100MB對(duì)等局域網(wǎng),用一條ADSL寬帶線路跑,以前用WINGATE將局域網(wǎng)連上INTERNET,后來覺得不爽我又用WINDOWS2000雙網(wǎng)卡做了個(gè)NAT地址轉(zhuǎn)換,使用網(wǎng)關(guān)和透明協(xié)議拖。這下下感覺舒服些了。呵呵,用了不久又發(fā)現(xiàn)些不大不小的毛?。罕热鐑?nèi)部互發(fā)OICQ慢啊,訪問SINA.COM.CN等個(gè)別網(wǎng)站有問題啊等等。MS的東東看似簡單但是當(dāng)你想微調(diào)一下系統(tǒng)的時(shí)候,你就會(huì)突然發(fā)現(xiàn)原來人生多么無奈啊。痛定思痛!:(我毅然決定放棄WINDOWS2000,改用LINUX!!
要用LINUX得搞臺(tái)機(jī)器吧,東拼西湊好不容易搞了一臺(tái)。各位看官請看: INTEL FX主板+PENTIUM 75芯片+16MB內(nèi)存+540MB硬盤+512K顯卡+DE220 10MB網(wǎng)卡。軟件嘛隨便找個(gè)LINUX發(fā)行版,我手頭有REDHAT 6.2 核心是2.2.14,按SERVER的安裝方式,經(jīng)過長達(dá)48分鐘左右的安裝,可愛的#提示符出現(xiàn)在大家面前!各位看客也可以根據(jù)自己的具體情況安裝。
硬件、軟件都裝好了,下面開始具體配置。(加了#提示符號(hào)表示輸入命令)
1、用ifconfig看看網(wǎng)絡(luò)配置
[root@localhost /root]#ifconfig
lo Link encap
ocal 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
只有l(wèi)o沒找到網(wǎng)卡。不急,自己配。我是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可以根據(jù)你自己的網(wǎng)卡設(shè)置
如果不能插入就按INSERT,加完就按ESC。再按: ,再輸入w 存盤,再q 退出。如果不放心就 #more conf.modules 看看寫進(jìn)去沒有。
一般市面上ISA的便宜網(wǎng)卡都兼容NE2000。如果是新手在LINUX下安裝網(wǎng)卡的可能會(huì)遇到這樣那樣的問題,多在網(wǎng)上找找看看,一般都能解決。要提醒大家最好別用PNP即插即用模式,在LINUX出了問題不好解決,簡直是場噩夢。
2、下面配置網(wǎng)卡IP地址, 在/etc/sysconfig/network-scripts下有個(gè)文件
ifcfg-eth0 寫成如下:
DEVICE=eth0
IPADDR=192.168.0.254
這是網(wǎng)卡的IP地址,以后客戶機(jī)的網(wǎng)關(guān)就是這個(gè)地址。
NETMASK=255.255.255.0
NETWORK=192.168.0.0
BROADCAST=192.168.0.255
ONBOOT=yes
BOOTPROTO=none
重起就能找到網(wǎng)卡。
我們再[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
ocal 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找到網(wǎng)卡了,配置也正確,恭喜恭喜!進(jìn)行下一步。
3、下一步做ADSL的驅(qū)動(dòng)。去http://www.roaringpenguin.com/pppoe/rp-pppoe-2.6.tar.gz 下個(gè)驅(qū)動(dòng)程序先,大概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的帳號(hào)
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):
問你用哪片網(wǎng)卡撥號(hào),默認(rèn)是第一片eth0就可以了
4、最后一步:配置ipchains偽裝IP。
在 /etc/sysconfig的network文件里保證要有這句: FORWARD_IPV4=true
然后改/etc/rc.d/rc.local這個(gè)文件,加入以下內(nèi)容
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):
用缺省的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.[!--empirenews.page--]
>>> Enter the DNS information here:
這里填你ISP的DNS地址,成都用61.139.2.69,輔助DNS成都可用202.98.127.32
PASSWORD
>>> Please enter your PPPoE password:
ADSL撥號(hào)密碼這個(gè)東東。
搞定!爽爽,用#adsl-start 就可以開始撥號(hào)。如果連接成功系統(tǒng)會(huì)提示你:…….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
ocal 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
oint-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沒有!