EIGRP的默認路由配置----四種方法實現內網訪問外網

R1和R2爲公司內網,R3爲外網,在R1和R2上配置EIGRP,在R2和R3上配置默認路由,實驗目的是用四種方法實現R1和R2內網可以訪問外網R3。

1.實驗拓撲:




2. 配置各路由器相連接口IP地址
R1(config)#int s1/0
R1(config-if)#ip add
R1(config-if)#ip address 10.1.1.1 255.255.252.0
R1(config-if)#no shut
R1(config-if)#int lo1
R1(config-if)#ip ad
R1(config-if)#ip address 11.11.11.11 255.255.255.255
R1(config-if)#int lo2
R1(config-if)#ip ad
R1(config-if)#ip address 172.16.9.1 255.255.255.0
R1(config-if)#int lo2
R1(config-if)#ip ad
R1(config-if)#ip address 172.16.10.1 255.255.255.0
R1(config-if)#int lo3
R1(config-if)#ip ad
R1(config-if)#ip address 172.16.11.1 255.255.255.0
R1(config-if)#int lo4
R1(config-if)#ip ad
R1(config-if)#ip address 172.16.12.1 255.255.255.0
R1(config-if)#
R2(config)#int s1/1
R2(config-if)#ip ad
R2(config-if)#ip address 10.1.1.2 255.255.255.252
R2(config-if)#no shut
R2(config-if)#int s1/0
R2(config-if)#ip ad
R2(config-if)#ip address 20.1.1.2 255.255.255.252
R2(config-if)#no shut
R2(config-if)#int lo1
R2(config-if)#ip ad
R2(config-if)#ip address 22.22.22.22 255.255.255.255
R2(config-if)#
R3(config)#int s1/1
R3(config-if)#ip ad
R3(config-if)#ip address 20.1.1.1 255.255.255.252
R3(config-if)#no shut
R3(config-if)#int lo1
R3(config-if)#ip ad
R3(config-if)#ip address 33.33.33.33 255.255.255.255
R3(config-if)#
3.R1R2上配置EIGRP協議,以建立內部網絡。
R1(config)#router eigrp 100
R1(config-router)#net
R1(config-router)#network 10.1.1.1 0.0.0.3
R1(config-router)#network 11.11.11.11 0.0.0.0
R1(config-router)#network 172.16.9.1 0.0.0.255
R1(config-router)#network 172.16.10.1 0.0.0.255
R1(config-router)#network 172.16.11.1 0.0.0.255
R1(config-router)#network 172.16.12.1 0.0.0.255
R2(config)#router eigrp 100          
R2(config-router)#network 22.22.22.22 0.0.0.0      
R2(config-router)#network 10.1.1.2 0.0.0.3          
注意R1R2的自治系統號兩邊要一至,還有在宣告網絡時加入通配符可以保證哪一些端口加入到EIGRP
4.R2查看路由表驗證EIGRP鄰居是否順利建立。
R2#show ip eigrp 100 neighbors
IP-EIGRP neighbors for process 100
H   Address                 Interface       Hold Uptime   SRTT   RTO Q Seq
                                           (sec)         (ms)       Cnt Num
0   10.1.1.1                Se1/1             10 00:13:13   98   588 0 31
可以看出鄰居關係已經建立好了
5.R2R3中配置默認路由
R2(config)#ip route 0.0.0.0 0.0.0.0 20.1.1.1
R3(config)#ip route 0.0.0.0 0.0.0.0 20.1.1.2
5.關閉自動彙總採用手工彙總
R1(config-router)#no auto-summary
R1(config)#int s1/0
R1(config-if)#ip summary-address eigrp 100 172.16.9.0 255.255.240.0
6.查看一下R2的路由表
R2#
R2# 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 20.1.1.1 to network 0.0.0.0
    20.0.0.0/30 is subnetted, 1 subnets
C       20.1.1.0 is directly connected, Serial1/0
172.16.0.0/21 is subnetted, 1 subnets      路由被彙總成一條
D       172.16.8.0 [90/2297856] via 10.1.1.1, 00:00:06, Serial1/1
    22.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C       22.22.22.22/32 is directly connected, Loopback1
D       22.0.0.0/8 is a summary, 00:10:09, Null0這一條路由沒有配置,是自動生成的,作用是防止路由環路
    10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C       10.1.1.0/30 is directly connected, Serial1/1
D       10.0.0.0/8 is a summary, 00:10:09, Null0
    11.0.0.0/32 is subnetted, 1 subnets
D       11.11.11.11 [90/2297856] via 10.1.1.1, 00:01:58, Serial1/1
S*   0.0.0.0/0 [1/0] via 20.1.1.1
7.看一下R2可不可以訪問R3
R2#ping 20.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 20.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/40/64 ms
顯然可以
然後在看一下R1可不可以訪問R3呢?
R1#ping 20.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 20.1.1.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
顯然不可以
8.採用第一種方法靜態路由重分佈實現內網和外網可以互達
9.現在在R2上配置靜態路由重分佈
R2(config)#router eigrp 100
R2(config-router)#re
R2(config-router)#redistribute s
R2(config-router)#redistribute static
10.在查看一下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 10.1.1.2 to network 0.0.0.0
    172.16.0.0/16 is variably subnetted, 4 subnets, 2 masks
C       172.16.12.0/24 is directly connected, Loopback4
D       172.16.8.0/21 is a summary, 00:07:28, Null0
C       172.16.10.0/24 is directly connected, Loopback2
C       172.16.11.0/24 is directly connected, Loopback3
D    22.0.0.0/8 [90/2297856] via 10.1.1.2, 00:09:19, Serial1/0
    10.0.0.0/22 is subnetted, 1 subnets
C       10.1.0.0 is directly connected, Serial1/0
    11.0.0.0/32 is subnetted, 1 subnets
C       11.11.11.11 is directly connected, Loopback1
D*EX 0.0.0.0/0 [170/2681856] via 10.1.1.2, 00:01:24, Serial1/0
11.測試R1是否可以訪問R3
R1#ping 20.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 20.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 68/105/172 ms
顯然可以
12.現在我們刪除重分佈,採用第二種方法實現R1訪問外網,就是在R1上配置一條默認路由指向R2
R2(config)#router eigrp 100        
R2(config-router)#no redistribute static
R1#ping 20.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 20.1.1.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
13.顯然刪除了重分佈R1不可以訪問R3
再在R1上配置一條默認路由指向R2
R1(config)#ip route 0.0.0.0 0.0.0.0 10.1.1.2
R1(config)#^Z
R1#
R1#ping 20.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 20.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 88/116/164 ms
顯然配置了一條默認路由,R1就可以和外網R3互通了從上面的配置,可以總結得出要解決外部網絡無法訪問的問題就需要給內部路由器配置默認路由指向出口路由器R2。但試想一下,如果內部路由器數量非常多的情況下,豈不是要一個個路由器地去配置一條默認路由?明顯這樣是很不現實的。
14..現在我們刪除R1的默認路由,並且使用第三種方法ip default-network的方法實現R1訪問外網
R1(config)#no ip route 0.0.0.0 0.0.0.0 10.1.1.2
R1(config)#do ping 20.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 20.1.1.1, timeout is 2 seconds:
.....
顯然刪除了默認路由,R1就不可以和R3通信了
15.現在用第三種ip default-network的方法實現R1訪問外網
R2(config)#router eigrp 100        
R2(config-router)#net
R2(config-router)#network 20.0.0.0
R2(config-router)#ex
R2(config)#ip de
R2(config)#ip default-ne
R2(config)#ip default-network 20.0.0.0
現在查看一下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 10.1.1.2 to network 20.0.0.0
D*   20.0.0.0/8 [90/2681856] via 10.1.1.2, 00:01:02, Serial1/0
    172.16.0.0/16 is variably subnetted, 4 subnets, 2 masks
C       172.16.12.0/24 is directly connected, Loopback4
D       172.16.8.0/21 is a summary, 00:26:26, Null0
C       172.16.10.0/24 is directly connected, Loopback2
C       172.16.11.0/24 is directly connected, Loopback3
D    22.0.0.0/8 [90/2297856] via 10.1.1.2, 00:28:17, Serial1/0
    10.0.0.0/22 is subnetted, 1 subnets
C       10.1.0.0 is directly connected, Serial1/0
    11.0.0.0/32 is subnetted, 1 subnets
C       11.11.11.11 is directly connected, Loopback1
看一下R1可不可以訪問R3
R1#ping 20.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 20.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 80/119/164 ms
呵呵,可以啦
16.現在就差最後一種方法啦!現在用第四種方法,我們先把R2上的ip default-network配置刪除了,最後進行在EIGRP上宣告net 0.0.0.0實現R1訪問R3,
R2(config)#router eigrp 100        
R2(config-router)#net
R2(config-router)#network 20.0.0.0
R2(config-router)#ex
R2(config)#ip de
R2(config)#ip default-ne
R2(config)#ip default-network 20.0.0.0
R2(config)#no ip de                  
R2(config)#no ip default-n
R2(config)#no ip default-network 20.0.0.0
R2(config)#  
R2(config)#router eigrp 100              
R2(config-router)#no network 20.0.0.0          
R1#ping 20.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 20.1.1.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
刪除配置後,顯然R1不可以與R3通信了,現在進行最後一這噢乖方法的配置
R2(config)#router eigrp 100  
R2(config-router)#net
R2(config-router)#network 0.0.0.0
R2(config-router)#ex
在測試R1R3的連通性
R1#ping 20.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 20.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 136/164/184 ms
可以看出R1可以pingR3

寫到這裏已經用了四種方法實現了在EIGRP和默認路由中實現內網訪問外網的四種方法了,呵呵,這是我第一次寫的技術文章,裏面肯定有很多的不足,希望大家可以幫我指出。

呵呵,最後做一下宣傳,這篇文章已經參加了中國大學生IT博客大賽,如果你覺得寫得還可以的話,請去我的博客首頁鏈接中投我一票

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