雏鹰部落

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4505|回复: 11

不连续网络使用辅助接口达到全网互联的弱智理解~

[复制链接]
发表于 2008-3-22 15:59:16 | 显示全部楼层 |阅读模式
全局声明:本文为某bm原创,其中参照了TCP/IP路由技术中文版第一卷(第二版)
感谢: Jeff Doyle CCIE#1919
      Jennifer Carroll MM, CCIE#1402 在书上对偶的支持~
      还有传说中的沉sir ,Justice,某sunmars~
版权没有 随便转载
配置如下拓扑

配置信息
R1
R11#sh run
Building configuration...
Current configuration : 762 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname R11
!
!
ip subnet-zero
!
ip ssh time-out 120
ip ssh authentication-retries 3
!
crypto mib ipsec flowmib history tunnel size 200
crypto mib ipsec flowmib history failure size 200
!
!
!
interface Loopback0                          //给换回接口配置IP
ip address 172.16.1.1 255.255.255.0
!         
interface Ethernet0
no ip address
shutdown
!
interface Ethernet1
no ip address
shutdown
!
interface Serial0                     //给S0口配置IP
ip address 10.0.0.1 255.255.255.0
!
interface Serial1
no ip address
shutdown
!
router rip
version 1                          //指定端口1
network 10.0.0.0                   //指定需要运行RIP路由进程的网络
network 172.16.0.0                 //同上
!
ip classless
ip http server
ip pim bidir-enable
!
!
!
line con 0
line aux 0
line vty 0 4
!
end

R2
R22#sh run
Building configuration...
Current configuration : 734 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname R22
!
!
ip subnet-zero
!
ip ssh time-out 120
ip ssh authentication-retries 3
!
crypto mib ipsec flowmib history tunnel size 200
crypto mib ipsec flowmib history failure size 200
!
!
!
interface Loopback0
ip address 172.16.3.1 255.255.255.0
!         
interface Ethernet0
no ip address
shutdown
!
interface Ethernet1
no ip address
shutdown
!
interface Serial0
ip address 10.0.0.2 255.255.255.0
clockrate 64000
!
interface Serial1
no ip address
shutdown
!
router rip
version 1
network 10.0.0.0
network 172.16.0.0
!
ip classless
no ip http server
ip pim bidir-enable
!
!
!
line con 0
line aux 0
line vty 0 4
!
end

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
 楼主| 发表于 2008-3-22 16:00:24 | 显示全部楼层
此时R1,R2路由表中只有直连网络[em3]
R11#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route

Gateway of last resort is not set

     172.16.0.0/24 is subnetted, 1 subnets
C       172.16.1.0 is directly connected, Loopback0
     10.0.0.0/24 is subnetted, 1 subnets
C       10.0.0.0 is directly connected, Serial0

R22#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route

Gateway of last resort is not set

     172.16.0.0/24 is subnetted, 1 subnets
C       172.16.3.0 is directly connected, Loopback0
     10.0.0.0/24 is subnetted, 1 subnets
C       10.0.0.0 is directly connected, Serial0

由于R1,R2直连的Loopback0是相同主类网络,并且中间夹杂了一个A类网络 所以形成了不连续的网络
如果在这个网络上启用有类动态路由协议那么就会造成路由器学不到对方直连的网段 因为子网掩码
在有类路由选择协议中是不传递的,有类路由协议只通告接口上直连网络的主网地址
所谓主网地址,就要知道常用的ABC三种有类地址 他们的子网掩码长度分别是8,16,24 子网掩码全为
1的部分称为网络位,在有类路由协议中 如果网络位不同 那么他们的主类地址也不同.
比如说 有类网络192.168.1.0与192.168.2.0 就不属于一个主类网络
               172.16.2.0与172.16.3.0属于一个主类网络

某人可以在路由器上开启Debug ip rip 来查看rip的通讯内容
ps:RIP每30s更新一次,如果不想等待30s 可以使用clear ip route * 清除所有路由条目 让RIP立即更新


R11#debug ip rip  
RIP protocol debugging is on
R11#clear ip route *
00:47:07: RIP: sending request on Serial0 to 255.255.255.255      //从所有加入RIP进程的接口发送广播更新请求
00:47:07: RIP: sending request on Loopback0 to 255.255.255.255
00:47:07: RIP: received v1 ** ** 10.0.0.2 on Serial0        //R2响应了请求 并把自己直连的主类地址172.16.0.0发送给R1
00:47:07:      172.16.0.0 in 1 hops
00:47:09: RIP: sending v1 flash ** to 255.255.255.255 via Loopback0 (172.16.1.1) //从自身进程接口发送更新
00:47:09: RIP: build flash ** entries
00:47:09:       network 10.0.0.0 metric 1
00:47:09: RIP: sending v1 flash ** to 255.255.255.255 via Serial0 (10.0.0.1)
00:47:09: RIP: build flash ** entries
00:47:09:       network 172.16.0.0 metric 1


R22#debug ip rip
RIP protocol debugging is on
R22#clear ip route *
00:51:49: RIP: sending request on Serial0 to 255.255.255.255        //从所有加入RIP进程的接口发送广播更新请求
00:51:49: RIP: sending request on Loopback0 to 255.255.255.255
00:51:49: RIP: received v1 ** ** 10.0.0.1 on Serial0        //R1响应了请求 并把自己直连的主类地址172.16.0.0发送给R2
00:51:49:      172.16.0.0 in 1 hops
00:51:51: RIP: sending v1 flash ** to 255.255.255.255 via Loopback0 (172.16.3.1) //从自身进程接口发送更新
00:51:51: RIP: build flash ** entries
00:51:51:       network 10.0.0.0 metric 1
00:51:51: RIP: sending v1 flash ** to 255.255.255.255 via Serial0 (10.0.0.2)
00:51:51: RIP: build flash ** entries
00:51:51:       network 172.16.0.0 metric 1


RIP更新完后,再用Sh ip route查看双方路由表
R11#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route

Gateway of last resort is not set

     172.16.0.0/24 is subnetted, 1 subnets
C       172.16.1.0 is directly connected, Loopback0
     10.0.0.0/24 is subnetted, 1 subnets
C       10.0.0.0 is directly connected, Serial0

R22#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route

Gateway of last resort is not set

     172.16.0.0/24 is subnetted, 1 subnets
C       172.16.3.0 is directly connected, Loopback0
     10.0.0.0/24 is subnetted, 1 subnets
C       10.0.0.0 is directly connected, Serial0

 楼主| 发表于 2008-3-22 16:02:24 | 显示全部楼层
只有直连网络,没有远端网络 原因如下:
1-00:47:09: RIP: sending v1 flash ** to 255.255.255.255 via Serial0 (10.0.0.1)
2-00:47:09: RIP: build flash ** entries
3-00:47:09:       network 172.16.0.0 metric 1

这个是给远端路由器发送自己直连网段的路由条目,发送给对端的路由更新内容只有自己的主类网络
172.16.0.0 这是因为在有类路由协议中 相同主类网络使用相同的子网掩码.如果发送路由更新的端口与自
己的想要发送的主类网络不同 那么就使用发送出去路由更新条目的默认主类掩码.如果发送端口与更新条目
的主类网络与子网掩码都相同,那么就使用发送端口上主类网络的子网掩码..因为相同主类网络与子网掩码使用相同的子网掩码..

那么解决方法就应运而生了 ,那就是让发送方的端口与路由条目的网络主类相同就可以,第一种方法就是多加一条
链路 比把R1R2的Ethernet0口用交叉线连起来 然后使用与Loopback0相同的主类网络..并配上不连续网络两端相同的子网掩码
然后如果R1,R2再发起更新 那么路由条目就会从各自的Ethernet0广播出去由于主类相同 那么就使用相同的子网掩码24
那么也就保留了两个Loopback0直连的网络的不同点,那就是:
使用/24位子网掩码可以区分172.16.1.0 与172.16.3.0 /24
如果没有这条Ethernet0链路 单从10.0.0.0/24位线路上传输路由更新,那么更新地址就不属于发送接口的主网..所以就使用默认子网掩码发送.
这样 R1会通告给R2一个到达172.16.0.0/16的路由更新 下一跳是R1,但是R2上已经有一个关于172.16.0.0网络的直连信息了,并且AD比
要经过R1的路由条目的优先级要高. 所以相互之间就不会接收各自的子网信息....

虽然问题是解决了,但是这样就占据了宝贵的接口,还有一种解决方法 那就是传说中的辅助地址
在S0,S0上使用ip address <ipaddresss> <subnetmask> [secondary] 命令创建辅助地址,一定要在接口模式下使用~
这里的辅助地址可以理解成一条虚拟的通讯线路.. 信息是可以在上面通讯的~
下面再看看设置完辅助地址的网络:


R11#sh ru
01:27:36: %SYS-5-CONFIG_I: Configured ** console by consolen
Building configuration...

Current configuration : 783 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname R11
!
!
ip subnet-zero
!
ip ssh time-out 120
ip ssh authentication-retries 3
!
crypto mib ipsec flowmib history tunnel size 200
crypto mib ipsec flowmib history failure size 200
!
!
!
interface Loopback0
ip address 172.16.1.1 255.255.255.0
         
R11#
R11#
R11#
R11#
R11#sh run
Building configuration...

Current configuration : 783 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname R11
!
!
ip subnet-zero
!
ip ssh time-out 120
ip ssh authentication-retries 3
!
crypto mib ipsec flowmib history tunnel size 200
crypto mib ipsec flowmib history failure size 200
!
!
!
interface Loopback0
ip address 172.16.1.1 255.255.255.0
!         
interface Ethernet0
no ip address
shutdown
!
interface Ethernet1
no ip address
shutdown
!
interface Serial0
ip address 172.16.254.1 255.255.255.0 secondary //这里设置了辅助接口
ip address 10.0.0.1 255.255.255.0
!
interface Serial1
no ip address
shutdown
!
router rip
version 1
network 10.0.0.0
network 172.16.0.0
!
ip classless
ip http server
ip pim bidir-enable
!
!
!
line con 0
line aux 0
line vty 0 4
!
end

接着写~ [em5]

[ 本帖最后由 保命要紧 于 2008-3-23 20:46 编辑 ]
 楼主| 发表于 2008-3-22 16:04:58 | 显示全部楼层
R22#sh run
Building configuration...

Current configuration : 783 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname R22
!
!
ip subnet-zero
!
ip ssh time-out 120
ip ssh authentication-retries 3
!
crypto mib ipsec flowmib history tunnel size 200
crypto mib ipsec flowmib history failure size 200
!
!
!
interface Loopback0
ip address 172.16.3.1 255.255.255.0
!         
interface Ethernet0
no ip address
shutdown
!
interface Ethernet1
no ip address
shutdown
!
interface Serial0
ip address 172.16.254.2 255.255.255.0 secondary //同样~
ip address 10.0.0.2 255.255.255.0
clockrate 64000
!
interface Serial1
no ip address
shutdown
!
router rip
version 1
network 10.0.0.0
network 172.16.0.0
!
ip classless
no ip http server
ip pim bidir-enable
!
!
!
line con 0
line aux 0
line vty 0 4
!
end


注意 两个虚接口要设置成同一网段 不然无法通信~

再来看看Debug信息

R11#debug ip rip
RIP protocol debugging is on
R11#clear ip route *
01:30:21: RIP: sending request on Serial0 to 255.255.255.255
01:30:21: RIP: sending request on Loopback0 to 255.255.255.255
01:30:21: RIP: sending request on Serial0 to 255.255.255.255     //这个就是辅助地址啦
01:30:21: RIP: received v1 ** ** 10.0.0.2 on Serial0
01:30:21:      172.16.0.0 in 1 hops
01:30:21: RIP: received v1 ** ** 172.16.254.2 on Serial0
01:30:21:      172.16.3.0 in 1 hops
01:30:23: RIP: sending v1 flash ** to 255.255.255.255 via Loopback0 (172.16.1.1) //相同的主网,但对于10.0.0.0不是相同主网 所以用/8默认掩码
01:30:23: RIP: build flash ** entries
01:30:23:       network 10.0.0.0 metric 1
01:30:23:       subnet 172.16.0.0 metric 2
01:30:23:       subnet 172.16.3.0 metric 2
01:30:23:       subnet 172.16.254.0 metric 1
01:30:23: RIP: sending v1 flash ** to 255.255.255.255 via Serial0 (10.0.0.1)
01:30:23: RIP: build flash ** entries
01:30:23:       network 172.16.0.0 metric 1
01:30:23: RIP: sending v1 flash ** to 255.255.255.255 via Serial0 (172.16.254.1) //就是这里了,这里使用了发送端口上相同主类的子网掩码 对方会收下她的~
01:30:23: RIP: build flash ** entries
01:30:23:       subnet 172.16.1.0 metric 1
01:30:27: RIP: received v1 ** ** 10.0.0.2 on Serial0
01:30:27:      172.16.0.0 in 1 hops
01:30:27: RIP: received v1 ** ** 172.16.254.2 on Serial0
01:30:27:      172.16.3.0 in 1 hops                               //这个就是对方送过来的带子网掩码的信息~


R22#debug ip rip   
RIP protocol debugging is on
R22#clear ip route *
01:33:26: RIP: sending request on Serial0 to 255.255.255.255
01:33:26: RIP: sending request on Loopback0 to 255.255.255.255
01:33:26: RIP: sending request on Serial0 to 255.255.255.255
01:33:26: RIP: received v1 ** ** 10.0.0.1 on Serial0
01:33:26:      172.16.0.0 in 1 hops
01:33:26: RIP: received v1 ** ** 172.16.254.1 on Serial0
01:33:26:      172.16.1.0 in 1 hops
01:33:28: RIP: sending v1 flash ** to 255.255.255.255 via Loopback0 (172.16.3.1)
01:33:28: RIP: build flash ** entries
01:33:28:       network 10.0.0.0 metric 1
01:33:28:       subnet 172.16.0.0 metric 2
01:33:28:       subnet 172.16.1.0 metric 2
01:33:28:       subnet 172.16.254.0 metric 1
01:33:28: RIP: sending v1 flash ** to 255.255.255.255 via Serial0 (10.0.0.2)
01:33:28: RIP: build flash ** entries
01:33:28:       network 172.16.0.0 metric 1
01:33:28: RIP: sending v1 flash ** to 255.255.255.255 via Serial0 (172.16.254.2)
01:33:28: RIP: build flash ** entries
01:33:28:       subnet 172.16.3.0 metric 1

同样的~


结束咯~
发表于 2008-3-22 16:38:58 | 显示全部楼层
呵呵...

楼主辛苦啦~~~
发表于 2008-3-22 17:35:32 | 显示全部楼层
楼主干劲冲足,  用PDF 或PPT 排版一下发上来,看会比较舒服一点
发表于 2008-3-22 18:22:17 | 显示全部楼层
获奖感言:::感谢cctv,感谢mtv,感谢chanelv ,感谢我老婆对我的支持,感谢我的父母,感谢我小学,初中,高中以及大学和幼儿园的老师们对我的支持!谢谢!谢谢!!
发表于 2008-3-22 20:03:09 | 显示全部楼层
PDF下啊!!!!!!!!
 楼主| 发表于 2008-3-23 10:07:50 | 显示全部楼层
原帖由 zheng13 于 2008-3-23 01:20 发表
太长了。。一句话:用second address支持不连续子网。。[em2]



有意义吗?[em1]
发表于 2009-6-22 09:12:54 | 显示全部楼层
很不错,感谢,水一个,加钱钱
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|熊猫同学技术论坛|小黑屋| 网络工程师论坛 ( 沪ICP备09076391 )

GMT+8, 2024-11-22 19:24 , Processed in 0.096155 second(s), 19 queries , Gzip On.

快速回复 返回顶部 返回列表