计网-路由器配置命令

路由器配置

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

注意:进入命令与提示符

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

三层交换机的配置 暂略

猜你喜欢

转载自blog.csdn.net/qq_37043191/article/details/79321114