實驗五十九:IP Default-network
實驗目標:掌握ip default-network命令的使用環境和配置
批註:路由器接口默認是關閉的,所以應將對應的接口開啓
如上基本配置,下面我們來描述ip default-network命令使用的環境:
觀察上面的拓撲,我們假設R1和R2組成一個企業的內部網絡,運行在EIGRP進程12中,這時R1作爲整個企業的網關與Internet對接,當然對於企業而言,它只希望自己可以上公網就OK了,對於去往公網在R1的路由表中使用的是明細還是彙總路由都是不重要的(就效果而言)。但對於企業而言,它是不希望在自己的路由表中維護公網的路由條目的(只要能夠訪問公網即可),並且如果要維護,那將是一個驚人的數量,這對於設備本身的要求就會是非常高的;對於Internet的管理人員(比如ISP)而言,他們也不希望將自己的路由泄露給企業,這樣會導致很多安全上的問題。所以對於運行EIGRP協議的路由器,可以通過ip default-network命令來精簡路由表的條目
具體的配置步驟如下:
(1)先使R1可以訪問Internet(以R3環回口3.3.3.3模擬),通過在R1與R3上分別配置默認路由實現。
R3(config)#ip route 0.0.0.0 0.0.0.0 s1/0
R1(config)#ip route 0.0.0.0 0.0.0.0 s2/0
檢查連通性
R1#ping 3.3.3.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max= 28/69/112 ms
//R1訪問3.3.3.3正常
(2)在R1和R2上運行EIGRP路由協議,R2自動彙總狀態對本實驗無影響,此例中我們關閉
R1(config)#router eigrp 12
R1(config-router)#network 1.1.1.0 0.0.0.255
R1(config-router)#network 12.1.1.0 0.0.0.255
R2(config)#router eigrp 12
R2(config-router)#no auto-summary
R2(config-router)#network 2.2.2.0 0.0.0.255
R2(config-router)#network 12.1.1.0 0.0.0.255
//此時的配置我們記爲標準配置。
(3)R1開啓自動彙總,將R1與R3相連網段宣告進eigrp進程。
R1(config-router)#auto-summary
R1(config-router)#network 13.1.1.0 0.0.0.255
查看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 NSSAexternal type 1, N2 - OSPF NSSA external type 2
E1 - OSPF externaltype 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 interarea, * - candidate default, U - per-user static route
o - ODR, P -periodic downloaded static route
Gateway of last resort is not set
D 1.0.0.0/8 [90/2297856] via 12.1.1.1,00:05:18, Serial2/0
2.0.0.0/24 is subnetted, 1subnets
C 2.2.2.0 is directlyconnected, Loopback0
12.0.0.0/24 is subnetted, 1subnets
C 12.1.1.0 isdirectly connected, Serial2/0
D 13.0.0.0/8 [90/2681856] via 12.1.1.1,00:04:35, Serial2/0
//R2此時已經正常學習到R1的LO0和S2/0接口網段的信息,注:都是彙總後的信息
(4)在R1的全局模式下配置ip default-network命令
R1(config)#ipdefault-network 13.0.0.0
這時我們查看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 NSSAexternal type 1, N2 - OSPF NSSA external type 2
E1 - OSPF externaltype 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 interarea, * - candidate default, U - per-user static route
o - ODR, P -periodic downloaded static route
Gateway of last resort is 12.1.1.1 to network 13.0.0.0
D 1.0.0.0/8 [90/2297856] via 12.1.1.1,00:10:43, Serial2/0
2.0.0.0/24 is subnetted, 1subnets
C 2.2.2.0 is directlyconnected, Loopback0
12.0.0.0/24 is subnetted, 1subnets
C 12.1.1.0 isdirectly connected, Serial2/0
D* 13.0.0.0/8 [90/2681856] via 12.1.1.1,00:00:36, Serial2/0
//對比上面R2的路由表,我們發現R2學習到的13.0.0.0/8網段信息的表示狀態由D變成了D*。在這兒我們先來了解一下路由器的路由查找原則,我們知道路由器的路由查找默認是按照最長匹配原則,D*的意思表示如果R2要去往當前路由表中沒有路由的目的網絡,那麼可以匹配D*路由後的下一跳/逃出接口來將數據發出,也就是說,當前R2的路由表中沒有去往公網3.3.3.3的路由,那麼會將所有去往3.3.3.3的數據從D*後的逃出接口即R2自身的S2/0接口發送出去
這時,我們來測試一下R2去往3.3.3.3的連通性
R2#ping 3.3.3.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max= 40/40/40 ms
//此時已經可以訪問
以上就是ip default-network命令的使用。
探索:
(1)因爲R2訪問外網是關鍵,我們一直都在關注R2路由表,現在我們來看看R1路由表。
R1#sh ip ro
Codes: C - connected, S - static, R - RIP, M - mobile, B- BGP
D - EIGRP, EX -EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSAexternal type 1, N2 - OSPF NSSA external type 2
E1 - OSPF externaltype 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 interarea, * - 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/8 is variably subnetted,2 subnets, 2 masks
C 1.1.1.0/24 isdirectly connected, Loopback0
D 1.0.0.0/8 is asummary, 00:02:15, Null0
D 2.0.0.0/8 [90/2297856] via 12.1.1.2,00:01:53, Serial1/0
12.0.0.0/8 is variablysubnetted, 2 subnets, 2 masks
C 12.1.1.0/24 isdirectly connected, Serial1/0
D 12.0.0.0/8 is asummary, 00:02:15, Null0
* 13.0.0.0/8 is variably subnetted, 2subnets, 2 masks
C 13.1.1.0/24 isdirectly connected, Serial2/0
D* 13.0.0.0/8 is a summary,00:02:12, Null0
S* 0.0.0.0/0 is directly connected, Serial2/0
我們關注D* 13.0.0.0/8 isa summary, 00:02:12, Null0這一條目,R1會將所有13網段數據丟棄。我們通過在R3上建立新環回口13.2.2.2/24來驗證。
R3(config-if)#ip add
R3(config-if)#ip address 13.2.2.2 255.255.255.0
R1上開啓debug測試。
R1#debug ip pac
R1#ping 13.2.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 13.2.2.2, timeout is 2seconds:
*Mar 1 00:11:50.559: IP: tableid=0, s=13.1.1.1 (local), d=13.2.2.2 (Null0), routed via RIB
*Mar 1 00:11:50.563: IP: s=13.1.1.1 (local),d=13.2.2.2 (Null0), len 100, sending.
*Mar 1 00:11:58.559: IP: s=13.1.1.1 (local),d=13.2.2.2 (Null0), len 100, sending
(省略一部分信息)
可見確實會被丟包,我們可以通過靜態路由來彌補這一問題。因爲Null0路由爲eigrp防環產生,而13網段爲公網地址,eigrp域內其它都是私網地址,s1/1對端R3並不與R1運行eigrp協議,可以認爲修改此條路由並無環路風險。
R1(config)#iproute 13.0.0.0 255.0.0.0 s1/1
R1上進行測試:
R1(config)#
R1#
*Mar 1 00:16:25.167: %SYS-5-CONFIG_I: Configuredfrom console by console
R1#ping 13.2.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 13.2.2.2, timeout is 2seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max= 20/75/136 ms
成功,可見自動彙總還是會帶來一些問題。
(2)R1要求開啓自動彙總,但我們通常習慣於關閉eigrp的自動彙總,我們嘗試關閉彙總但仍保持連通。
在R1上關閉自動彙總
R1(config)#router eigrp 12
R1(config-router)#no auto-summary
查看R2路由表:
R2#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B- BGP
D - EIGRP, EX - EIGRPexternal, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSAexternal type 1, N2 - OSPF NSSA external type 2
E1 - OSPF externaltype 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 interarea, * - 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, 1subnets
D 1.1.1.0[90/2297856] via 12.1.1.1, 00:00:03, Serial2/0
2.0.0.0/24 is subnetted, 1subnets
C 2.2.2.0 is directlyconnected, Loopback0
12.0.0.0/24 is subnetted, 1subnets
C 12.1.1.0 isdirectly connected, Serial2/0
13.0.0.0/24 is subnetted, 1 subnets
D 13.1.1.0 [90/2681856]via 12.1.1.1, 00:00:03, Serial2/0
//由於關閉自動彙總,D*彙總路由已經消失。
我們試着通過手動彙總來加入缺失的彙總路由。
R1(config)#int s1/0
R1(config-if)#ipsummary-address eigrp 12 13.0.0.0 255.0.0.0
再查看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 NSSAexternal type 1, N2 - OSPF NSSA external type 2
E1 - OSPF externaltype 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 interarea, * - candidate default, U - per-user static route
o - ODR, P -periodic downloaded static route
Gateway of last resort is 12.1.1.1 to network 13.0.0.0
1.0.0.0/24 is subnetted, 1subnets
D 1.1.1.0[90/2297856] via 12.1.1.1, 00:01:25, Serial2/0
2.0.0.0/24 is subnetted, 1subnets
C 2.2.2.0 is directlyconnected, Loopback0
12.0.0.0/24 is subnetted, 1subnets
C 12.1.1.0 isdirectly connected, Serial2/0
D* 13.0.0.0/8 [90/2681856] via 12.1.1.1,00:00:13, Serial2/0
//彙總路由出現,而且是D*標識。
測試:
R2#ping 3.3.3.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max= 40/40/40 ms
由上可見,對於ip default-network命令,我們可以關閉自動彙總功能,只要保證D*網段的彙總條目存在且被其它路由器學到即可。
補充:其它實現方法(以下配置都在基本配置上進行改動。連通都成功,省略檢測步驟)
(1)彙總0.0.0.0 0.0.0.0條目
我們對R1配置做一些修改
R1(config)#router eigrp 12
R1(config-router)#no auto-summary
R1(config-router)#exit
R1(config)#interface serial 1/0
R1(config-if)#ipsummary-address eigrp 12 0.0.0.0 0.0.0.0
//R1關閉自動彙總,在S1/0接口上手工彙總成0.0.0.0 0.0.0.0缺省
查看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 NSSAexternal type 1, N2 - OSPF NSSA external type 2
E1 - OSPF externaltype 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 interarea, * - candidate default, U - per-user static route
o - ODR, P -periodic downloaded static route
Gateway of last resort is 12.1.1.1 to network 0.0.0.0
2.0.0.0/24 is subnetted, 1subnets
C 2.2.2.0 is directlyconnected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 isdirectly connected, Serial2/0
D* 0.0.0.0/0 [90/2297856] via 12.1.1.1,00:01:39, Serial2/0
//R2的路由表中出現一條從R1學習到的D*缺省路由
(2)重發布靜態默認路由
在R1上進行靜態重發布
R1(config)#router eigrp 12
R1(config-router)#no auto-summary
R1(config-router)#redistribute static metric 1000 1000 255 1 1500
查看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 NSSAexternal type 1, N2 - OSPF NSSA external type 2
E1 - OSPF externaltype 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 interarea, * - candidate default, U - per-user static route
o - ODR, P -periodic downloaded static route
Gateway of last resort is 12.1.1.1 to network 0.0.0.0
1.0.0.0/24 is subnetted, 1subnets
D 1.1.1.0[90/2297856] via 12.1.1.1, 00:04:22, Serial2/0
2.0.0.0/24 is subnetted, 1subnets
C 2.2.2.0 is directlyconnected, Loopback0
12.0.0.0/24 is subnetted, 1subnets
C 12.1.1.0 isdirectly connected, Serial2/0
D*EX0.0.0.0/0 [170/3328000] via 12.1.1.1, 00:03:14,Serial2/0
//R2路由表出現從R1學到的D*EX缺省路由
(3)手工配置靜態路由
在R2上手工配置默認靜態路由
R1(config)#router eigrp 12
R1(config-router)#no auto-summary
R2(config)#iproute 0.0.0.0 0.0.0.0 s2/0
查看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 NSSAexternal type 1, N2 - OSPF NSSA external type 2
E1 - OSPF externaltype 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 interarea, * - 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, 1subnets
D 1.1.1.0[90/2297856] via 12.1.1.1, 00:10:02, Serial2/0
2.0.0.0/24 is subnetted, 1subnets
C 2.2.2.0 is directlyconnected, Loopback0
12.0.0.0/24 is subnetted, 1subnets
C 12.1.1.0 isdirectly connected, Serial2/0
S* 0.0.0.0/0 is directly connected, Serial2/0
//R2路由表中爲S*靜態默認路由
算上ip default-network,前面3種方法都是在eigrp進程中注入一條缺省路由,原理大同小異。只有最後這種方法,每臺內網路由器上都要進行手工配置,但可用於不運行eigrp協議的路由器。