計網-路由器配置命令

路由器配置

(一)路由器的基本配置和命令

注意:進入命令與提示符

1. 用戶模式

只讀

Router> ping/telnet/show version

2. 特權模式

用戶模式下,輸入enable與超級用戶密碼,進入特權模式

Router > enable   
password:    
Router # 

特權模式可以進入全局配置模式,以便對其進行配置。

3. 設置模式

通過Console端口進入剛出廠的無配置路由器,所進入的模式。

4. 全局配置模式(Global Configuration)

 Router # configure terminal   
 Router (config) # ...

5. 其他

在全局模式下進入接口配置模式

Router (config) # int f0 /12
Router (config-if) #

在全局配置模式下進入虛擬終端配置模式:

Router (config) # line vty 0 15
Router (config-line) #

在全局配置模式下,進入RIP路由協議模式:

Router (config) # router rip
Router (config-router) #

6. 配置主機名

Router (config) # hostname Router-phy
Router-phy (config) #

7. 配置超級用戶口令

Router (config) # enable secret phy123
Router (config) # enable password 7 phy123
Router (config) #

(二) 路由器接口配置

description 描述信息

Router (config) # int g6/0
Router (config-if) # description To-Blabla

bandwidth 設置帶寬 單位是kbps

Router (config) # interface POS3/0
Router (config-if) # bandwidth 25000000

配置接口的IP地址
命令格式: ip address \\

Router (config) # interface f2/3
Router (config-if) # ip address 0.0.0.0 255.255.255.252

開啓與關閉

Router (config) # interface f2/3
Router (config-if) # shutdown
Router (config-if) # no shutdown

(三)局域網接口配置

1. 配置標準以太網接口

interface Ethernet0  # 進入config-if
description To blabla
ip address 202.112.7.4 255.255.255.0
bandwidth 10000
no shutdown
exit # 退到config
exit # 退到Router #

2. 配置快速以太網接口

FastEthernet, f for short

interface f2/1
...
duplex full
no ip directer-broadcast
no ip proxy-arp
no shutdown
exit
exit

3. 配置千兆以太網

GigabitEthernet, g for short

interface g0/1
...

(四) 廣域網接口配置

1. 配置異步串行口

先配置異步串行接口Async, a for short.

interface a1
ip unnumbered ethernet0
encapsulation ppp
async default ip address 202.112.7.129
async dynamic routing
async mode interactive
no shutdown
exit
exit

2. 配置高速同步串行接口

Serial, s for short.需要配置的參數:接口帶寬,接口協議,接口IP地址。

interface s1/1
description
bandwidth 2048 # 2M
ip address
encapsulation hdlc
no ip directed-broadcast
no shutdown

3. 配置POS接口

POS使用的鏈路層協議主要有PPP和HDLC

interface POS3/0
description To blabla
bandwidth 2500000
ip address 212.12.0...
crc 32 #crc校驗位爲16和32
pos framing sdh #
no ip directed-broadcast
pos flag s1 s0 2
no shutdown

(五)Loopback接口配置

是一種應用廣泛的虛接口。爲方便管理,在每臺路由器上設置環回接口,接口不受網絡故障的影響。

網絡管理員爲loopback分配一個IP地址作爲管理地址,掩碼255.255.255.255。

可以使用這個地址遠程登陸到路由器上,進行管理配置。

int loopback 0
ip address IP 255.255.255.255
no ip route-cache
no ip mroute-cache
exit
exit

(六)靜態路由配置

已知路由表的情況下:

# 全局配置模式下(config)
ip route <目的網絡地址><子網掩碼><下一跳路由器的IP地址>
# 設置默認路由器
ip route 0.0.0.0  0.0.0.0 <下一跳>

(七)動態路由協議的配置

1. RIP

RIP只依據路由器跳數(hop)決定最佳路徑,不管帶寬、延時等。最大hop==15。

不能攜帶子網掩碼信息,不支持可變長掩碼VLSM。自動根據ip的網絡號確定掩碼。

每30s更新一次路由,一般用於小型局域網。

基本配置:啓動,定義參與RIP路由的網絡地址。

# 在全局config模式下
router rip
network 159.105.0.0 # 進入config-router
network 212.112.7.0
exit
exit

高級配置

# 配置被動接口
router rip
passive-interface ethernet 0
# 配置路由過濾
access-list 12 deny any
router rip
distribute-list 12 in ethernet0
end
# 配置管理距離AD
# AD缺省120,AD越小路由可信度越高
router rip
distance 50
# 定義鄰居路由,單播發送
router rip
neighbor ip

2. OSPF

OSPF可以區域劃分,路由更新信息只在本區域內傳播,不同區域不交換路由信息。

支持大型互聯網的路由選擇

區域用數字表示,區域ID,32位unsigned。區域ID爲0表示主幹區域。

基本配置
子網配置

# 定義參與OSPF的單個IP地址
# network ip <子網> <wildcard-mask> area <區域號>
# wildcard-mask子網掩碼的反碼
router ospf 63
network 131.107.25.1 0.0.0.0 area 0
# 網絡地址
network 133.181.0.0 0.0.255.255 area 0
# area range 定義一定範圍子網的聚合
area 0 range 212.37.123.0 255.255.255.0

其他的如passive-interface/distribute-list/distance/redistribute

三層交換機的配置 暫略

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章