实验18ip default-network
1.实验目的
通过本实验可以掌握如何通过ip default-network 向网络中注入一条默认路由。
 
2.拓扑结构
实验拓扑如图所示。
3.实验步骤,配置如下:
1ip default-network 后面的网络一定要是主类网络;
2ip default-network 后面的网络可以是直连的或者通过其它协议学到的网络。
 
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#ho r0
r0(config)#no ip do loo
r0(config)#lin c 0
r0(config-line)#logg s
r0(config-line)#exec-t 00
r0(config-line)#exit
r0(config)#int loo 1
r0(config-if)#ip add
*Mar  1 00:04:06.075: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback1, changed state to up
r0(config-if)#ip add 2.2.2.2 255.255.255.0 
r0(config-if)#int f1/0
r0(config-if)#ip add 172.16.1.2 255.255.255.0
r0(config-if)#no sh
r0(config-if)#exit
r0(config)#
*Mar  1 00:04:31.031: %LINK-3-UPDOWN: Interface FastEthernet1/0, changed state to up
*Mar  1 00:04:32.031: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up
r0(config)#router rip
r0(config-router)#ve 2
r0(config-router)#no au
r0(config-router)#net 172.16.1.0
r0(config-router)#exit
r0(config)#ip default-network 2.0.0.0  
r0(config)#do sh 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
R       1.1.1.0 [120/1] via 172.16.1.1, 00:00:17, FastEthernet1/0
 *   2.0.0.0/24 is subnetted, 1 subnets
C       2.2.2.0 is directly connected, Loopback1
     172.16.0.0/24 is subnetted, 1 subnets
C       172.16.1.0 is directly connected, FastEthernet1/0
r0(config)#
 
 
 
Router(config)#ho r1
r1(config)#no ip do loo
r1(config)#lin c 0
r1(config-line)#logg s
r1(config-line)#exec-t 00
r1(config-line)#exit
r1(config)#int loo 1
r1(config-if)#ip add 1.1.
*Mar  1 00:03:09.895: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback1, changed state to up
r1(config-if)#ip add 1.1.1.1 255.255.255.0
r1(config-if)#int f1/0
r1(config-if)#ip add 172.16.1.1 255.255.255.0
r1(config-if)#no sh
r1(config-if)#
*Mar  1 00:03:35.879: %LINK-3-UPDOWN: Interface FastEthernet1/0, changed state to up
*Mar  1 00:03:36.879: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up
r1(config-if)#
r1(config-if)#exit
r1(config)#router rip
r1(config-router)#ve 2
r1(config-router)#no au
r1(config-router)#net 172.16.1.0
r1(config-router)#net 1.0.0.0
r1(config-router)#do sh 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 172.16.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, Loopback1
     172.16.0.0/24 is subnetted, 1 subnets
C       172.16.1.0 is directly connected, FastEthernet1/0
R*   0.0.0.0/0 [120/1] via 172.16.1.2, 00:00:13, FastEthernet1/0
r1(config-router)#
从以上输出可以看出R1 上的“ip default-network”命令确实向RIP 网络中注入一条
R*”的默认路由。