EIGRP重分发

EIGRP重分发

还是以刚才的拓扑图作为例子,我们只在R1,R2,R3这三台设备上开启了EIGRP协议,并没有在R4上开启,所以R1和R 2是无法ping通R4的,那么我们如何将去往R4的路由通过rEIGRP告知R1和R2呢?
EIGRP重分发_第1张图片
我们选取的思路是在R3上写入一条通往R4的静态路由,再在R4上写入一条通往R3的静态路由。再通过EIGRP告知全网,那么具体实现如下:
一共有三种方式,方法一:
首先我们在R3上配置一条默认路由:

R3(config)#ip route 0.0.0.0 0.0.0.0 f0/0
R3(config)#do show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, 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 0.0.0.0 to network 0.0.0.0

     1.0.0.0/24 is subnetted, 1 subnets
D       1.1.1.0 [90/435200] via 192.168.2.1, 00:08:41, FastEthernet0/1
     2.0.0.0/24 is subnetted, 1 subnets
D       2.2.2.0 [90/409600] via 192.168.2.1, 00:08:10, FastEthernet0/1
     3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, Loopback0
D    192.168.1.0/24 [90/307200] via 192.168.2.1, 00:08:41, FastEthernet0/1
C    192.168.2.0/24 is directly connected, FastEthernet0/1
C    192.168.3.0/24 is directly connected, FastEthernet0/0
S*   0.0.0.0/0 is directly connected, FastEthernet0/0

可见,S*即为刚才添加的默认路由(S为静态路由,带*号的为默认路由)
同样的方法在R4上配置默认路由(为了数据包返回)
R4(config)#ip route 0.0.0.0 0.0.0.0 f 0/0
接下来就是如何将R3上的默认路由通过EIGRP宣告出去了
R3(config)#router eigrp 100
R3(config-router)#redistribute static
下面我们在R1上查看路由表

R1(config)#do show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, 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 192.168.1.2 to network 0.0.0.0

     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
     2.0.0.0/24 is subnetted, 1 subnets
D       2.2.2.0 [90/409600] via 192.168.1.2, 00:11:34, FastEthernet0/0
     3.0.0.0/24 is subnetted, 1 subnets
D       3.3.3.0 [90/435200] via 192.168.1.2, 00:11:27, FastEthernet0/0
C    192.168.1.0/24 is directly connected, FastEthernet0/0
D    192.168.2.0/24 [90/307200] via 192.168.1.2, 00:12:33, FastEthernet0/0
D    192.168.3.0/24 [90/332800] via 192.168.1.2, 00:12:05, FastEthernet0/0
D*EX 0.0.0.0/0 [170/332800] via 192.168.1.2, 00:00:30, FastEthernet0/0

我们看见多了一条标记为D*EX的路由,这里D表示这条路由来自EIGRP,*表示为默认路由,EX代表是EIGRP转发其他协议的路由。我们由R1pingR4的环回口试试网络是否连通:

R1#ping 4.4.4.4

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
..!!!
Success rate is 60 percent (3/5), round-trip min/avg/max = 56/66/76 ms

Ok!连通(前面两个数据包没有到达是因为RIP的原因)

方法二:
与方法一一样,先在R3和R4上写入默认路由,然后在R3上的操作略有区别:
R3(config)#router ei 100
R3(config-router)#no redistribute static
R3(config-router)#network 0.0.0.0 0.0.0.0
no redistribute static这条命令是移除刚才方法一的重分发静态路由的操作,然后我们直接将静态路由的网络边界通过network语句宣告出去,这下我们再来R1上查看一下路由表看是否有变化:

R1#show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, 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 192.168.1.2 to network 0.0.0.0

     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
     2.0.0.0/24 is subnetted, 1 subnets
D       2.2.2.0 [90/409600] via 192.168.1.2, 00:16:55, FastEthernet0/0
     3.0.0.0/24 is subnetted, 1 subnets
D       3.3.3.0 [90/435200] via 192.168.1.2, 00:16:48, FastEthernet0/0
C    192.168.1.0/24 is directly connected, FastEthernet0/0
D    192.168.2.0/24 [90/307200] via 192.168.1.2, 00:17:54, FastEthernet0/0
D    192.168.3.0/24 [90/332800] via 192.168.1.2, 00:17:26, FastEthernet0/0
D*   0.0.0.0/0 [90/332800] via 192.168.1.2, 00:01:44, FastEthernet0/0

可见没有了EX标记,因为这条路由是通过EIGRP宣告出来的,是属于EIGRP协议内邻居转发来的路由,而不是重分发的静态路由,所以没哟EX标志。我们再来尝试一下R1pingR4:

R1#ping 4.4.4.4

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/55/76 ms

Ok!连通
方法三(思科官方推荐方法)
方法三为思科官方推荐做法,本方法配置默认路由的方法和刚刚略有区别,我们先来R3上配置默认路由:

R3(config)#no ip route 0.0.0.0 0.0.0.0 f0/0
R3(config)#ip route 4.0.0.0 255.0.0.0 f0/0
R3(config)#do show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, 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

     1.0.0.0/24 is subnetted, 1 subnets
D       1.1.1.0 [90/435200] via 192.168.2.1, 00:23:47, FastEthernet0/1
     2.0.0.0/24 is subnetted, 1 subnets
D       2.2.2.0 [90/409600] via 192.168.2.1, 00:23:17, FastEthernet0/1
     3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, Loopback0
S    4.0.0.0/8 is directly connected, FastEthernet0/0
D    192.168.1.0/24 [90/307200] via 192.168.2.1, 00:23:47, FastEthernet0/1
C    192.168.2.0/24 is directly connected, FastEthernet0/1
C    192.168.3.0/24 is directly connected, FastEthernet0/0
R3(config)#ip default-network 4.0.0.0
R3(config)#do show ip route          
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, 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

     1.0.0.0/24 is subnetted, 1 subnets
D       1.1.1.0 [90/435200] via 192.168.2.1, 00:24:07, FastEthernet0/1
     2.0.0.0/24 is subnetted, 1 subnets
D       2.2.2.0 [90/409600] via 192.168.2.1, 00:23:36, FastEthernet0/1
     3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, Loopback0
S*   4.0.0.0/8 is directly connected, FastEthernet0/0
D    192.168.1.0/24 [90/307200] via 192.168.2.1, 00:24:07, FastEthernet0/1
C    192.168.2.0/24 is directly connected, FastEthernet0/1
C    192.168.3.0/24 is directly connected, FastEthernet0/0
R3(config)#router ei 100
R3(config-router)#net 4.0.0.0 0.255.255.255

我们为了和0.0.0.0(默认路由)区别,我们使用4.0.0.0来配置这个默认路由(R4的环回口4.4.4.4被包含在内),首先我们将4.0.0.0这条路由写入为静态,然后我们使用ip default-network命令来使它成为默认路由,之后我们再在EIGRP上通过network将其宣告出去
我们再在R1上查看路由表,并且pingR4:

R1#show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, 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 192.168.1.2 to network 4.0.0.0

     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
     2.0.0.0/24 is subnetted, 1 subnets
D       2.2.2.0 [90/409600] via 192.168.1.2, 00:28:15, FastEthernet0/0
     3.0.0.0/24 is subnetted, 1 subnets
D       3.3.3.0 [90/435200] via 192.168.1.2, 00:28:07, FastEthernet0/0
D*   4.0.0.0/8 [90/332800] via 192.168.1.2, 00:04:40, FastEthernet0/0
C    192.168.1.0/24 is directly connected, FastEthernet0/0
D    192.168.2.0/24 [90/307200] via 192.168.1.2, 00:29:14, FastEthernet0/0
D    192.168.3.0/24 [90/332800] via 192.168.1.2, 00:28:46, FastEthernet0/0
R1#ping 4.4.4.4

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 32/58/76 ms

接收到了这条路由并且可以联通

你可能感兴趣的:(网络)