基本信息全部在上图中,R1-R6全部用的4E接口,其中R4要求是配置默认路由,其余的是静态路由,目的:全部能够通信。
首先:
全部设置IP地址:(下面给出R1的设置ip过程)
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int e0/0
R1(config-if)#no sh
R1(config-if)#ip add
*Mar 1 00:02:59.459: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up
*Mar 1 00:03:00.459: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to up
R1(config-if)#ip add 16.24.2.1 255.255.255.0
R1(config-if)#int e0/1
R1(config-if)#no sh
R1(config-if)#ip add 16.24.
*Mar 1 00:03:19.707: %LINK-3-UPDOWN: Interface Ethernet0/1, changed state to up
*Mar 1 00:03:20.707: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to up
R1(config-if)#ip add 16.24.1.1 255.255.255.0
R1(config-if)#end
到达此步,已经相邻的都能通信了,
在就从R1开始:设置静态路由:
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#ip route 16.24.5.0 255.255.255.0 16.24.2.2 //目标网段 255.255.255.0 下一跳地址
R1(config)#ip route 16.24.3.0 255.255.255.0 16.24.2.2
R1(config)#ip route 16.24.4.0 255.255.255.0 16.24.2.2
R1(config)#end
R2:
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#ip route 16.24.1.0 255.255.255.0 16.24.2.1
R2(config)#ip route 16.24.4.0 255.255.255.0 16.24.3.2
R2(config)#end
//配置静态路由都是这个步骤:
接下来是配置默认路由R4
R4#conf t
R4(config)#ip classless //一定要加上
R4(config)#ip route 0.0.0.0 0.0.0.0 16.24.1.1 //前面8个0,后面的是下一跳地址
R4(config)#end
到了这里就大功告成了。
如果要检查ip 的话,在普通模式下:sh ip ro查看ip信息。(如图:)
还有一种情况是了已经配置好了的静态路由,要换成默认路由,这样做:
:conf t
:no ip route 网段 掩码 下一跳地址
:ip classless
:ip route 0.0.0.0 0.0.0.0 下一跳地址
示例:(将R5静态路由换成默认路由)
R5#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R5(config)#no ip route 16.24.4.0 255.255.255.0 16.24.5.1
R5(config)#no ip route 16.24.1.0 255.255.255.0 16.24.5.1
R5(config)#no ip route 16.24.2.0 255.255.255.0 16.24.5.1
R5(config)#no ip route 16.24.3.0 255.255.255.0 16.24.5.1
R5(config)#ip classless
R5(config)#ip route 0.0.0.0 0.0.0.0 16.24.5.1
R5(config)#end
检查:
终于写完了。12点47分