看到一個不錯的例子,拿來給大家看
結合實例講解廣域網路由基本技術
作者:水泊梁山 東方龍
我們假定讀者對IP協議有一定程度的了解(不了解IP協議永遠無法維護一個IP網絡),比如至少懂得IP地址的結構、類別和子網、子網掩碼的概念,并且具有一定的計算機基礎知識。在配置路由器時,只要將計算機的串口通過路由器自帶的專用電纜接到Console口,使用諸如超級終端或者Netterm之類的軟件即可。
網絡中的只有一塊網卡(一個IP地址)任何一臺主機只能直接訪問本子網內的機器。而路由器相當于一臺由多個網卡的主機,每一塊網卡可以直接與一個子網通信。根據上圖我們知道,兩個網絡相連主要是通過在其間建立一個廣域網互聯子網來進行。這個子網中只有兩臺機器,即兩邊的路由器,當然它的子網掩碼就是255.255.255.252。只要路由器A、B的Seiral口在同一個子網,由于它們的Ethernet口分別屬于A、B兩網,我們就在A、B網之間建立了一條通道。網絡A中的主機只要將網關設為路由器A,其信息即可通過路由器A、B轉發(fā)到B網。
我們在例子中使用的是應用最廣泛的Cisco 2501路由器,這種路由器物理結構簡單,網絡接口只有兩個Serial口和一個Ethernet口,卻支持完整的路由功能。采用的協議為TCP/IP,因為現在使用其他諸如IPX、Netbeui之類的協議已經是非常的不合時宜。
實例1:通過Cisco 2501連接A局域網與B局域網
假設實驗條件如下:
A網:202.96.199.0——202.96.199.255
B網:202.97.76.0——202.97.76.31
DNS Server:202.96.199.2(主),202.96.199.3(備)
所屬域:xxx.com
廣域網互聯:需要一個包含4個IP地址(2個可用IP)的子網,
定為:202.98.0.0——202.98.0.3,其中202.98.0.1給A網,202.98.0.2給B網
互聯專線速率:128kbps
具體網絡參數分配表如下:
項目 A網 B網
網絡號 202.96.199.0 202.97.76.0
子網掩碼 255.255.255.0 255.255.255.224
所屬域 xxx.com yyy.com
以太網地址 202.96.199.1 202.97.76.1
互聯地址 202.98.0.1 202.98.0.2
專線速率 128kbps 同左
域名服務器 主:202.96.199.2
備:202.96.199.3 同左
首先進入路由器:將你的計算機串行口連接到路由器的Console口,使用Netterm或者超級終端之類的軟件登錄。
Router>en:
passwd:******(輸入超級口令)
全局配置:(A、B網相同)
Router#conf terminal(切換到配置狀態(tài))
Router(config)#enable secret my-root-password(定義超級口令)
Router(config)#ip host Router-A(定義路由器名,B網為Router-B)
Router(config)#ip domain-name xxx.com(定義所屬域名稱,B網為yyy.com)
Router(config)#nameserver 202.96.199.2(定義主域名服務器)
Router(config)#nameserver 202.96.199.3(定義備域名服務器)
Router(config)#ip classless
Router(config)#line vty 0 4
(定義5個telnet虛終端,即可以同時有5個人登錄本路由器)
Router(config-line)#password my-telnet-password(定義telnet口令)
Router(config-line)#exit
Router(config)#exit
地址和路由配置:
/****** A網路由器 ******/
Router-A#conf t(切換到配置狀態(tài))
Router-A(config)#int e0(配置Ethernet 0口)
Router-A(config-if)#description the LAN port link to my local network(端口說明)
Router-A(config-if)#ip add 202.96.199.1 255.255.255.0
(定義以太網IP地址,子網掩碼表示為C類網絡)
Router-A(config-if)#no shutdown(激活端口)
Router-A(config-if)#exit
Router-A(config)#int s0(配置Serial 0口)
Router-A(config-if)#description the WAN port link to Router-B(端口說明)
Router-A(config-if)#ip add 202.98.0.1 255.255.255.252(定義互聯廣域網IP地址)
Router-A(config-if)#bandwidth 128(定義端口速率,單位:kbps)
Router-A(config-if)#no shutdown(激活端口)
Router-A(config-if)#exit
Router-A(config)#ip route 202.97.76.0 255.255.255.224 202.98.0.2
(定義靜態(tài)路由,通過網關到達對端局域網絡,IP為對端廣域網IP地址)
Router-A(config)#exit
Router-A#wr m(保存配置)
/****** B網路由器 ******/
Router-B#conf t
Router-B(config)#int e0
Router-B(config-if)#description the LAN port link to my local network(端口說明)
Router-B(config-if)#ip add 202.97.76.1 255.255.255.224
(定義以太網IP地址,子網掩碼表示為擁有32個地址的子網)
Router-B(config-if)#no shutdown
Router-B(config-if)#exit
Router-B(config)#int s0
Router-B(config-if)#description the WAN port link to Router-A(端口說明)
Router-B(config-if)#ip add 202.98.0.2 255.255.255.252
Router-B(config-if)#bandwidth 128
Router-B(config-if)#no shutdown
Router-B(config-if)#exit
Router-B(config)#ip route 202.96.199.0 255.255.255.0 202.98.0.1
(定義靜態(tài)路由,通過網關到達對端局域網絡,IP為對端廣域網IP地址)
Router-B(config)#exit
Router-B#wr m(保存配置)
配置完成。
這里是A網、B網路由器配置清單。
Router A:
Router-A#sh run
Building Configuration...
Current configuration
version 11.2
service udp-small-servers
service tcp-small-servers
hostname Router-A
enable secret test-a
ip subnet-zero
interface Ethernet0
description the LAN port link to my local network
ip address 202.96.199.1 255.255.255.0
interface Serial0
description the WAN port link to Router-B
ip address 202.98.0.1 255.255.255.252
bandwidth 128
interface Serial1
no ip address
shutdown
ip domain-name xxx.com
ip name-server 202.96.199.2
ip name-server 202.96.199.3
ip classless
ip route 202.97.76.0 255.255.255.224 202.98.0.2
line con 0
line aux 0
line vty 0 4
password telnet-a
login
end
Router-A#
Rouer B:
Router-B#sh run
Building Configuration...
Current configuration
version 11.2
service udp-small-servers
service tcp-small-servers
hostname Router-B
enable secret test-b
ip subnet-zero
interface Ethernet0
description the LAN port link to my local network
ip address 202.97.76.1 255.255.255.224
interface Serial0
description the WAN port link to Router-A
ip address 202.98.0.2 255.255.255.252
bandwidth 128
interface Serial1
no ip address
shutdown
ip domain-name yyy.com
ip name-server 202.96.199.2
ip name-server 202.96.199.3
ip classless
ip route 202.96.199.0 255.255.255.0 202.98.0.1
line con 0
line aux 0
line vty 0 4
password telnet-b
login
end
Router-B#
實例2:通過Cisco 2501將你的局域網接入Internet
假設實驗條件如下:
本網IP地址為:202.96.199.0——202.96.199.255
DNS Server:202.96.202.96(主),202.96.96.202(備)
ISP分配的廣域網互聯IP地址為202.98.0.2
具體網絡參數分配表如下:
項目
用戶網絡
ISP網絡
網絡號
202.96.199.0
子網掩碼
255.255.255.0
所屬域
xxx.com
以太網地址
202.96.199.1
互聯地址
202.98.0.2
202.98.0.1
專線速率
128kbps
同左
域名服務器
主:202.96.202.96
備:202.96.96.202
我們已經有了上例的經驗,則很容易根據相同的原理配置這個路由器。
首先進入路由器:
Router>en:
passwd:
全局配置:
Router#conf t
Router(config)#ip host Router
Router(config)#nameserver 202.96.202.96
Router(config)#nameserver 202.96.96.202
Router(config)#exit
其他項目同“例一”。
地址配置:
Router#conf t
Router(config)#int e0
Router(config-if)#description the LAN port link to my local network(端口說明)
Router(config-if)#ip add 202.96.199.1 255.255.255.0
Router(config-if)#no shutdown(激活端口)
Router(config-if)#exit
Router(config)#int s0
Router(config-if)#description the WAN port link to Internet(端口說明)
Router(config-if)#ip add 202.98.0.2 255.255.255.252
Router(config-if)#no shutdown(激活端口)
Router(config-if)#exit
路由配置:
Router(config)#ip route 0.0.0.0 0.0.0.0 202.98.0.1
(定義默認靜態(tài)路由,所有的遠程訪問通過網關,IP為對端廣域網IP地址)
Router(config)#exit
Router#wr m
配置完成。
這里是本網路由器配置清單。
Router#sh run
Building Configuration...
Current configuration
version 11.2
service udp-small-servers
service tcp-small-servers
hostname Router
enable secret test
ip subnet-zero
interface Ethernet0
description the LAN port link to my local network
ip address 202.96.199.1 255.255.255.0
interface Serial0
description the WAN port link to Internet
ip address 202.98.0.2 255.255.255.252
bandwidth 128
interface Serial1
no ip address
shutdown
ip domain-name xxx.com
ip name-server 202.96.202.96
ip name-server 202.96.96.202
ip classless
ip route 0.0.0.0 0.0.0.0 202.98.0.1
line con 0
line aux 0
line vty 0 4
password telnet
login
end
Router#
實例3:使用Cisco路由器對大型網絡(例如ISP網絡)進行擴容
--------------------------------------------------------------------------------
當然,設計管理大型網絡的路由非常復雜,一般都是由經過高級培訓的專業(yè)人士進行。而且,大型網絡一般都采用像Cisco 7507這樣的高檔路由器。在這里順便簡單講述,主要是讓大家開闊一下視野,了解一下其他的路由協議。
這時,與例2唯一的不同就是路由配置,不能采用靜態(tài)路由協議而應該相應地采用非常優(yōu)秀的OSPF動態(tài)路由協議并結合RIP協議。
假設具體網絡參數如下:
項目
本地網絡
網絡號
202.96.199.0
子網掩碼
255.255.255.0
OSPF編號
100
OSPF域
202.96.192.0——202.96.207.255,16個C
那么應該這樣配置:
Router(config)#router ospf 100(配置OSPF路由)
Router(config-router)#summary-address 202.96.199.0 255.255.255.0
Router(config-router)#redistribute connnected metric-type 1 subnets
Router(config-router)#redistribute static(通過OSPF協議廣播靜態(tài)路由)
Router(config-router)#network 202.96.192.0 0.0.15.255 area 0.0.0.0
Router(config-router)#area 0.0.0.0 authentiication message-digest
Router(config-router)#exit
Router(config)#router rip(配置RIP路由)
Router(config-router)#redistribute ospf 100 metric 1(通過RIP協議廣播OSPF路由)
Router(config-router)#passive-interface Serial 0(不在Serial 0上使用)
Router(config-router)#network 202.101.199.0(定義本網絡)
Router(config-router)#exit
Router(config)exit
同時,采用OSPF協議時應該在廣域網端口上加入授權機制:
Router(config)#int s0
Router(config-if)#ip ospf message-digest-key keyword
Router(config-if)#exit
Router(config)#exit
Router#wr m
更大型的網絡會采用BGP邊緣路由協議,假設具體網絡參數如下:
項目 本地網絡 遠程網絡
AS(自治域) 20000 4000
本地BGP網絡 202.96.192.0——202.96.207.255,16個C
202.97.0.0——202.97.15.255,16個C
202.98.128.0——202.98.159.255,32個C
互聯地址 202.100.4.2 202.100.4.1
則本地路由器配置方法為:
Router(config)#router bgp 20000(定義本BGP管理的AS--自治域編號)
Router(config-router)#no synchronization
Router(config-router)#network 202.96.192.0 mask 255.255.240.0
(定義本AS--自治域包含的網絡)
Router(config-router)#network 202.97.0.0 mask 255.255.240.0
Router(config-router)#network 202.98.128.0 mask 255.255.224.0
Router(config-router)#neighbor 202.100.4.1 remote-as 4000
(定義到遠端AS--自治域的網關IP)
Router(config-router)#exit
Router(config)#exit
Router#wr m
配置完成。
實用技術
--------------------------------------------------------------------------------
一、使用口令加密機制:
Router(config)#service password-encryption(路由器密碼將以暗碼顯示)
二、配置http server,以便從瀏覽器訪問路由器:
Router(config)#ip http server
三、訪問控制:
Router(config)#access-list 101 permit ip 10.150.0.0 0.0.255.255 any
(允許10.150.0.0——10.150.255.255訪問)
Router(config)#access-list 101 deny ip 10.151.0.0 0.0.255.255 any
(禁止10.151.0.0——10.150.255.255訪問)
四、負載分擔:
要實現負載分擔必須使用動態(tài)路由協議,以OSPF為例,只要將兩條路由的代價(cost)設為相等,即可自動實現。
默認的OSPF代價為廣域網線路64,局域網線路30,設置路徑代價的命令為:
Router(config-if)#ip ospf cost xx。
五、常用命令:
Router#help/?(獲得幫助)
Router#sh run(顯示路由器當前配置)
Router#sh int Xn(接口名稱,例如Ethernet 0、Serial 1等,顯示接口狀態(tài))
Router#sh ip route(顯示當前路由)
Router#wr m(儲存配置,以便下次重啟時使用)
Router#reload(重啟路由器)
Router#ping ip-address(測試與其他主機的連接)
Router#telnet host(登錄其它主機)
本站僅提供存儲服務,所有內容均由用戶發(fā)布,如發(fā)現有害或侵權內容,請
點擊舉報。