把一台Cisco路由器配置为帧中继交换机
使用路由器R0模拟帧中继交换机。
命令
FRS(config)#frame-relay switching //把路由器模拟成帧中继交换机
FRS(config-if)#encapsulation frame-relay //配置接口封装帧中继
FRS(config-if)#frame-relay lmi-type cisco //配置LMI类型
FRS(config-if)#frame-relay intf-type dce //配置接口为帧中继的DCE
FRS(config-if)#frame-relay route 102 int s0/1 201 //定义本接口和s0/1接口之间的PVC交换表
说明
①“encapsulation frame-relay {ietf}”命令用来配置接口帧中继封,默认时为Cisco封装,如果要连接到另
一台Cisco路由器,则可以使用该命令;如果连接到非Cisco路由器需要带“ietf”参数,使用ietf封装。
②“frame-relay lmi-type {ansi|cisco|q933a}”命令用来配置LMI的类型,不配置时默认是Cisco类型。
1>ANSI T1.617 ANNEX D:欧洲电信委员会标准;
2>Cisco:思科标准;
3>I TU-TQ.933 ANNEX A:国际标准。
③“frame-relay intf-type {dce|dte|}”命令用来配置接口是帧中继的DCE还是DTE,默认为DTE类型。
注意:帧中继接口DCE/DTE和物理接口端是DCE/DTE无关,也就是说即使接口是DTE,也可以配置成帧中继DCE。
R0(config)#hostname FRS
FRS(config)#frame-relay switching
FRS(config)#int s0/0
FRS(config-if)#clock rate 64000
FRS(config-if)#encapsulation frame-relay
FRS(config-if)#frame-relay lmi-type cisco
FRS(config-if)#frame-relay intf-type dce
FRS(config-if)#frame-relay route 102 int s0/1 201
FRS(config-if)#frame-relay route 103 int s0/2 301
FRS(config-if)#no sh
FRS(config)#int s0/1
FRS(config-if)#clock rate 64000
FRS(config-if)#encapsulation frame-relay
FRS(config-if)#frame-relay lmi-type cisco
FRS(config-if)#frame-relay intf-type dce
FRS(config-if)#frame-relay route 201 int s0/0 102
FRS(config-if)#frame-relay route 203 int s0/2 302
FRS(config-if)#no sh
FRS(config)#int s0/2
FRS(config-if)#clock rate 64000
FRS(config-if)#encapsulation frame-relay
FRS(config-if)#frame-relay lmi-type cisco
FRS(config-if)#frame-relay intf-type dce
FRS(config-if)#frame-relay route 301 int s0/0 103
FRS(config-if)#frame-relay route 302 int s0/1 203
FRS(config-if)#no sh
实验调试
FRS#show frame-relay route //查看接口进入和送出的DLCI,以及状态是否是active
以上输出表明了路由器R2上配置了3条PVC,状态都是活动的。以第一条为例,其含义是:路由器如果从s0/0接口收到DLCI=102的帧,要从s0/1接**换出去,并且DLCI被替换为201。
FRS#show frame-relay pvc int s0/0 //显示本接口的虚电路(PVC)统计信息
PVC状态有如下3种:
①ACTIVE:表明PVC的状态是激活的,表示成功的端对端(DTE到DTE)电路。
②INACTIVE:表明成功连接到交换机,但在PVC的另一端未检测到DTE。
③DELETED:表明该DTE配置的DLCI被交换机视为对该接口无效,或PVC不存在。
FRS#show frame-relay lmi int s0/0 //查看LMI的统计信息
帧中继基本配置
命令
R1(config-if)#no frame-relay inverse-arp //关闭IARP,默认是开启的
R1(config-if)#frame-relay map ip 172.16.123.2 102 broadcast //配置帧中继静态映射
R1(config-if)#ip split-horizon //开启水平分割
说明:IARP的自动映射默认是开启的,在配置静态映射时需要关闭IARP;当一个接口配置了静态映射时,该接口
的IARP会自动关闭。如果IARP被关闭了,也可以通过以下命令打开:
R1(config-if)#frame-relay inverse-arp ip DLCI //DLCI:本地接口的DLCI地址。
R0(config)#hostname FRS
FRS(config)#frame-relay switching
FRS(config)#int s0/0
FRS(config-if)#clock rate 64000
FRS(config-if)#encapsulation frame-relay
FRS(config-if)#frame-relay lmi-type cisco
FRS(config-if)#frame-relay intf-type dce
FRS(config-if)#frame-relay route 102 int s0/1 201
FRS(config-if)#frame-relay route 103 int s0/2 301
FRS(config-if)#no sh
FRS(config)#int s0/1
FRS(config-if)#clock rate 64000
FRS(config-if)#encapsulation frame-relay
FRS(config-if)#frame-relay lmi-type cisco
FRS(config-if)#frame-relay intf-type dce
FRS(config-if)#frame-relay route 201 int s0/0 102
FRS(config-if)#frame-relay route 203 int s0/2 302
FRS(config-if)#no sh
FRS(config)#int s0/2
FRS(config-if)#clock rate 64000
FRS(config-if)#encapsulation frame-relay
FRS(config-if)#frame-relay lmi-type cisco
FRS(config-if)#frame-relay intf-type dce
FRS(config-if)#frame-relay route 301 int s0/0 103
FRS(config-if)#frame-relay route 302 int s0/1 203
FRS(config-if)#no sh
R1(config)#int lo0
R1(config-if)#ip add 172.16.1.1 255.255.255.0
R1(config)#int s0/0
R1(config-if)#ip add 172.16.123.1 255.255.255.0
R1(config-if)#encapsulation frame-relay
R1(config-if)#frame-relay lmi-type cisco
R1(config-if)#no sh
R1(config)#router rip
R1(config-router)#version 2
R1(config-router)#no auto-summary
R1(config-router)#network 172.16.0.0
R2(config)#int lo0
R2(config-if)#ip add 172.16.2.2 255.255.255.0
R2(config)#int s0/0
R2(config-if)#ip add 172.16.123.2 255.255.255.0
R2(config-if)#encapsulation frame-relay
R2(config-if)#frame-relay lmi-type cisco
R2(config-if)#no sh
R2(config)#router rip
R2(config-router)#version 2
R2(config-router)#no auto-summary
R2(config-router)#network 172.16.0.0
R3(config)#int lo0
R3(config-if)#ip add 172.16.3.3 255.255.255.0
R3(config)#int s0/0
R3(config-if)#ip add 172.16.123.3 255.255.255.0
R3(config-if)#encapsulation frame-relay
R3(config-if)#frame-relay lmi-type cisco
R3(config-if)#no sh
R3(config)#router rip
R3(config-router)#version 2
R3(config-router)#no auto-summary
R3(config-router)#network 172.16.0.0
说明:
①如果采用的Cisco路由器IOS是11.2或以后的版本,路由器可以自动协商LMI类型,如果路由器没有自动检测LMI
类型的功能,需要配置和帧中继交换机同样的LMI类型,本实验路由器IOS版本是12.4,所以路由器R1/R2/R3的
“frame-relay lmi-type cisco”命令可以不配置。
②在配置IP地址时,要求用帧中继连接的路由器接口必须都在同一个网段中。
③可以通过如下配置命令开启水平分割:
R1/R2/R3(config)#int s0/0
R1/R2/R3(config-if)#ip split-horizon
注意:由于接口封装了帧中继后,水平分割会被自动关闭,必要时需要重新打开。
实验调试
R1/R2/R3#show frame-relay map //查看帧中继的映射
以上输出显示了帧中继逆向ARP(IARP)的作用结果,表明路由器R1、R2和R3每个封装帧中继的接口都包含2条处于活动(active)状态的DLCI;每条记录都显示了远端的IP地址和本地的DLCI的映射关系;“broadcast”参数允许在PVC上传输广播或组播流量;“dynamic”表明是动态映射。
R1#show frame-relay pvc
说明:以上实验我们注意到,每台路由器都不能ping通自己的串行接口IP地址,但是可以ping通远端封装帧中继
的串行接口IP地址,因为自己的帧中继映射表中没有(也不能配置)到自己接口IP地址和DLCI的映射条目;另外
如果想要使用OSPF等路由协议时,也应该使用静态映射;此外还有一些早期的路由器不支持IARP,这种路由器
也只能使用静态映射。因此可见采用IARP做动态映射是解决不了这些问题的,只有通过静态映射解决。
帧中继的静态映射
在本实验中,帧中继交换机(路由器R0)采用了PVC全互联的拓扑结构,但是实际应用中,为了节省费用,一般采用“中心-分支(Hub-and-Spooke)”的拓扑结构,即只有分支到中心的PVC,假如R1是中心路由器,R2和R3是分支路由器,配置命令修改如下:
FRS(config)#int s0/1
FRS(config-if)#no frame-relay route 203 int s0/2 302
FRS(config)#int s0/2
FRS(config-if)#no frame-relay route 302 int s0/1 203
说明:R2和R3这时是不通的,因为R1的s0/0接口可能开启了水平分割致使R2、R3收不到去往对方的路由条目,或
者即使是关闭了水平分割而在帧中继交换机中也没有R2、R3之间的映射,所以说在“中心-分支”的拓扑结构
中不适合用动态映射,应该使用静态映射。
R1(config)#int s0/0
R1(config-if)#no frame-relay inverse-arp
R1(config-if)#frame-relay map ip 172.16.123.2 102 broadcast
R1(config-if)#frame-relay map ip 172.16.123.3 103 broadcast
R1(config-if)#frame-relay map ip 172.16.123.1 102
//配置到自己接口的IP地址的映射(102或103都可以),目的是使自己能ping通本接口的IP地址
R2(config)#int s0/0
R2(config-if)#no frame-relay inverse-arp
R2(config-if)#frame-relay map ip 172.16.123.1 201 broadcast
R2(config-if)#frame-relay map ip 172.16.123.3 201 broadcast
R2(config-if)#frame-relay map ip 172.16.123.2 201
R3(config)#int s0/0
R3(config-if)#no frame-relay inverse-arp
R3(config-if)#frame-relay map ip 172.16.123.1 301 broadcast
R3(config-if)#frame-relay map ip 172.16.123.2 301 broadcast
R3(config-if)#frame-relay map ip 172.16.123.3 301
R1/R2/R3#show frame-relay map
以上输出表明路由器R1、R2、R3每个封装了帧中继的接口下都采用静态映射。
R1/R2/R3#show ip route rip
以上输出表明个路由器的RIP路由信息正确,但是与上面动态映射实验的路由表相比,R2路由表中的R3环回接口网络和R3路由表中的R2环回接口网络的跳数发生了变化。我们还注意到R2的路由表中到达“172.16.3.0/24”网络的路由条目的下一跳地址为“172.16.123.3”而不是“172.16.123.1”,所以在R2的s0/0接口上必须有到“172.16.123.3”的映射,即“frame-relay map ip 172.16.123.3 201 broadcast”。R3也是同理。
总结:
①全互联拓扑结构中:使用静态映射或动态映射都可以;水平分割开启或关闭都可以。
③“中心-分支”拓扑结构中:只能使用静态映射;水平分割只能关闭。
帧中继多点子接口下配置OSPF
命令
R1(config-if)#ip ospf network point-to-point //修改OSPF网络类型
R1(config)#int s0/0.1 multipoint //创建帧中继多点子接口
R1(config-router)#neighbor 172.16.123.2 //手动指定OSPF邻居
R2(config-subif)#ip ospf priority 0 //设置OSPF端口优先级为0,即不参与DR/BDR选举
说明:
①在接口模式下可以通过如下命令修改OSPF的网络类型:
R1(config-if)#ip ospf network {broadcast|non-broadcast|point-to-multipoint|point-to-point}
②interface serial slot-number/interface-number.subinterface-number {multipoint|point-to-point}
命令用来创建帧中继子接口,其中:
1>solt-number/interface-number:物理接口号;
2>subinterface-number:子接口号,范围为1-4294967293;
3>multipoint和point-to-point:子接口的类型,即多点类型、点到点类型,该项是必须选择项的,因为如果
在物理接口启用帧中继封装后,进入子接口时系统要求用户必须指定接口类型;
4>“no int s0/0.1”命令删除子接口,但是需要重启路由器,该子接口才真正被删除;
5>子接口不能解决接口水平分割的问题,只是节省了物理接口而已。
③在帧中继网络上,OSPF接口默认的网络类型为NON_BROADCAST(NBMA)。在这种模式下OSPF不会在帧中继接口上
发送Hello包,因此无法建立最基本的OSPF邻接关系。可以手动使用“neighbor”命令来指定邻居,这时Hello
包以单播形式传送。
④NAMA属于多路访问型网络,所以要进行DR/BDR的选举。由于Hello包只能传1跳,所以在“Hub-and-Spoke”结
构中,必须控制处于“Hub”端的路由器成为DR。最保险的办法就是将“Spoke”端路由器OSPF接口优先级配置
为0,使之不参与DR/BDR的选举,“Hub”端的路由器自然就成为DR了;否则可能会导致路由学习不正常。
R0(config)#hostname FRS
FRS(config)#frame-relay switching
FRS(config)#int s0/0
FRS(config-if)#clock rate 64000
FRS(config-if)#encapsulation frame-relay
FRS(config-if)#frame-relay lmi-type cisco
FRS(config-if)#frame-relay intf-type dce
FRS(config-if)#frame-relay route 102 int s0/1 201
FRS(config-if)#frame-relay route 103 int s0/2 301
FRS(config-if)#no sh
FRS(config)#int s0/1
FRS(config-if)#clock rate 64000
FRS(config-if)#encapsulation frame-relay
FRS(config-if)#frame-relay lmi-type cisco
FRS(config-if)#frame-relay intf-type dce
FRS(config-if)#frame-relay route 201 int s0/0 102
FRS(config-if)#no sh
FRS(config)#int s0/2
FRS(config-if)#clock rate 64000
FRS(config-if)#encapsulation frame-relay
FRS(config-if)#frame-relay lmi-type cisco
FRS(config-if)#frame-relay intf-type dce
FRS(config-if)#frame-relay route 301 int s0/0 103
FRS(config-if)#no sh
R1(config)#int lo0
R1(config-if)#ip add 172.16.1.1 255.255.255.0
R1(config-if)#ip ospf network point-to-point
R1(config)#int s0/0
R1(config-if)#no ip address
R1(config-if)#encapsulation frame-relay
R1(config-if)#no frame-relay inverse-arp
R1(config-if)#no sh
R1(config)#int s0/0.1 multipoint
R1(config-subif)#ip add 172.16.123.1 255.255.255.0
R1(config-subif)#frame-relay map ip 172.16.123.2 102 broadcast
R1(config-subif)#frame-relay map ip 172.16.123.3 103 broadcast
R1(config-subif)#frame-relay map ip 172.16.123.1 102
R1(config-subif)#no frame-relay inverse-arp
R1(config)#router ospf 1
R1(config-router)#router-id 1.1.1.1
R1(config-router)#network 172.16.1.0 0.0.0.255 area 0
R1(config-router)#network 172.16.123.0 0.0.0.255 area 0
R1(config-router)#neighbor 172.16.123.2
R1(config-router)#neighbor 172.16.123.3
R2(config)#int lo0
R2(config-if)#ip add 172.16.2.2 255.255.255.0
R2(config-if)#ip ospf network point-to-point
R2(config)#int s0/0
R2(config-if)#no ip address
R2(config-if)#encapsulation frame-relay
R2(config-if)#no frame-relay inverse-arp
R2(config-if)#no sh
R2(config)#int s0/0.1 multipoint
R2(config-subif)#ip add 172.16.123.2 255.255.255.0
R2(config-subif)#ip ospf priority 0
R2(config-subif)#frame-relay map ip 172.16.123.1 201 broadcast
R2(config-subif)#frame-relay map ip 172.16.123.3 201 broadcast
R2(config-subif)#frame-relay map ip 172.16.123.2 201
R2(config-subif)#no frame-relay inverse-arp
R2(config)#router ospf 1
R2(config-router)#router-id 2.2.2.2
R2(config-router)#network 172.16.2.0 0.0.0.255 area 0
R2(config-router)#network 172.16.123.0 0.0.0.255 area 0
R3(config)#int lo0
R3(config-if)#ip add 172.16.3.3 255.255.255.0
R3(config-if)#ip ospf network point-to-point
R3(config)#int s0/0
R3(config-if)#no ip address
R3(config-if)#encapsulation frame-relay
R3(config-if)#no frame-relay inverse-arp
R3(config-if)#no sh
R3(config)#int s0/0.1 multipoint
R3(config-subif)#ip add 172.16.123.3 255.255.255.0
R3(config-subif)#ip ospf priority 0
R3(config-subif)#frame-relay map ip 172.16.123.1 301 broadcast
R3(config-subif)#frame-relay map ip 172.16.123.2 301 broadcast
R3(config-subif)#frame-relay map ip 172.16.123.3 301
R3(config-subif)#no frame-relay inverse-arp
R3(config)#router ospf 1
R3(config-router)#router-id 3.3.3.3
R3(config-router)#network 172.16.3.0 0.0.0.255 area 0
R3(config-router)#network 172.16.123.0 0.0.0.255 area 0
说明:
①试验中“no ip address”命令用于删除物理接口的IP地址,如果没有配置IP地址,可不用此命令。
注意:在配置子接口IP地址时,要保证子接口所在的物理接口没有IP地址,否则子接口将收不到信息。
②使用“no sh”命令激活接口时,需要激活物理接口,而子接口不需要使用此命令。
实验调试
R1#show frame-relay map
命令
R1(config)#int s0/0.12 point-to-point //创建帧中继点到点子接口
R1(config-subif)#frame-relay interface-dlci 102 //配置帧中继映射
说明:在物理接口和多点子接口下可以使用“frame-relay map ip”命令来配置帧中继的静态映射;而在多点子
接口下需要改用“frame-relay interface-dlci”命令来配置帧中继的静态映射。
FRS(config)#frame-relay switching
FRS(config)#int s0/0
FRS(config-if)#clock rate 64000
FRS(config-if)#encapsulation frame-relay
FRS(config-if)#frame-relay lmi-type cisco
FRS(config-if)#frame-relay intf-type dce
FRS(config-if)#frame-relay route 102 int s0/1 201
FRS(config-if)#frame-relay route 103 int s0/2 301
FRS(config-if)#no sh
FRS(config)#int s0/1
FRS(config-if)#clock rate 64000
FRS(config-if)#encapsulation frame-relay
FRS(config-if)#frame-relay lmi-type cisco
FRS(config-if)#frame-relay intf-type dce
FRS(config-if)#frame-relay route 201 int s0/0 102
FRS(config-if)#no sh
FRS(config)#int s0/2
FRS(config-if)#clock rate 64000
FRS(config-if)#encapsulation frame-relay
FRS(config-if)#frame-relay lmi-type cisco
FRS(config-if)#frame-relay intf-type dce
FRS(config-if)#frame-relay route 301 int s0/0 103
FRS(config-if)#no sh
R1(config)#int lo0
R1(config-if)#ip add 172.16.1.1 255.255.255.0
R1(config-if)#ip ospf network point-to-point
R1(config)#int s0/0
R1(config-if)#no ip address
R1(config-if)#encapsulation frame-relay
R1(config-if)#no frame-relay inverse-arp
R1(config-if)#no sh
R1(config)#int s0/0.12 point-to-point
R1(config-subif)#ip add 172.16.12.1 255.255.255.0
R1(config-subif)#frame-relay interface-dlci 102
R1(config)#int s0/0.13 point-to-point
R1(config-subif)#ip add 172.16.13.1 255.255.255.0
R1(config-subif)#frame-relay interface-dlci 103
R1(config)#router ospf 1
R1(config-router)#router-id 1.1.1.1
R1(config-router)#network 172.16.1.0 0.0.0.255 area 0
R1(config-router)#network 172.16.12.0 0.0.0.255 area 0
R1(config-router)#network 172.16.13.0 0.0.0.255 area 0
R2(config)#int lo0
R2(config-if)#ip add 172.16.2.2 255.255.255.0
R2(config-if)#ip ospf network point-to-point
R2(config)#int s0/0
R2(config-if)#no ip address
R2(config-if)#encapsulation frame-relay
R2(config-if)#no frame-relay inverse-arp
R2(config-if)#no sh
R2(config)#int s0/0.12 point-to-point
R2(config-subif)#ip add 172.16.12.2 255.255.255.0
R2(config-subif)#frame-relay interface-dlci 201
R2(config)#router ospf 1
R2(config-router)#router-id 2.2.2.2
R2(config-router)#network 172.16.2.0 0.0.0.255 area 0
R2(config-router)#network 172.16.12.0 0.0.0.255 area 0
R3(config)#int lo0
R3(config-if)#ip add 172.16.3.3 255.255.255.0
R3(config-if)#ip ospf network point-to-point
R3(config)#int s0/0
R3(config-if)#no ip address
R3(config-if)#encapsulation frame-relay
R3(config-if)#no frame-relay inverse-arp
R3(config-if)#no sh
R3(config)#int s0/0.13 point-to-point
R3(config-subif)#ip add 172.16.13.3 255.255.255.0
R3(config-subif)#frame-relay interface-dlci 301
R3(config)#router ospf 1
R3(config-router)#router-id 3.3.3.3
R3(config-router)#network 172.16.3.0 0.0.0.255 area 0
R3(config-router)#network 172.16.13.0 0.0.0.255 area 0
实验调试
R1/R2/R3#show frame-relay map
以上输出表明路由器使用了点到点子接口,由于点到点的特性,在每条映射条目中,只看到该子接口下的DLCI,没有对端的IP地址,这一点和多点子接口是不同的。
R1#show ip ospf interface
以上各路由器的路由表的输出表明了整个网络是互通的。
R2#show ip ospf neighbor detail