史上最详细计网实验(2) |
您所在的位置:网站首页 › 三层交换机配置路由协议 › 史上最详细计网实验(2) |
本篇博客继续讲解计算机网络中三层交换机与动态路由RIP协议实验。
先来介绍一下三层交换机,我们之前做的vlan实验使用的是两层交换机,其作用就是将pc机连接起来。而三层交换机在此基础上增加了类似路由器的连接不同局域网的作用,在局域网内部网络中可以用三层交换机来代替路由器,但在局域网与公网互联之间并不能完全取代路由器工作。我们之前用到的vlan,当赋予了网络号后,其实就可以表示一个局域网。
再来说说RIP协议,其实RIP协议就是路由器自动配置路由表的算法。我们之前配置的静态路由表是要我们人工手动输入,当面对多个路由器相连时就会非常繁琐,并且当线路或者设备出问题而导致的连接断开后,可以动态调整路由表,使pc机能正常通信。
路由器Router0设置: Router>en Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#int f 1/0 Router(config-if)#ip addr 192.168.1.1 255.255.255.0 ##给端口设置ip和掩码 Router(config-if)#no sh ##no shutdown的简写,开启端口 Router(config-if)# %LINK-5-CHANGED: Interface FastEthernet1/0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up Router(config-if)#exit Router(config)#int se 2/0 Router(config-if)#ip addr 192.168.2.1 255.255.255.0 Router(config-if)#no sh %LINK-5-CHANGED: Interface Serial2/0, changed state to down Router(config-if)#exit Router(config)#剩下的Router1同样如上设置,这里就不过多展示了。 配置完上述后我们先来给三层交换机中的vlan号配置ip。 Switch#conf t Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#int vlan 10 ##进入到vlan 10中并配置ip Switch(config-if)# %LINK-5-CHANGED: Interface Vlan10, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up Switch(config-if)#ip addr 192.168.1.2 255.255.255.0 ##可以发现其实跟配置路由器的端口ip一样,其作用就是接口vlan 10看成是路由器地址为192.168.1.2的接口 Switch(config-if)#no sh Switch(config-if)#exit Switch(config)#int vlan 50 Switch(config-if)# %LINK-5-CHANGED: Interface Vlan50, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan50, changed state to up Switch(config-if)#ip addr 192.168.5.1 255.255.255.0 Switch(config-if)#no sh Switch(config-if)#exit Switch(config)#ip routing ##这一步非常重要,相当于把vlan中ip信息更新并放入表中 Switch(config)#我们可以通过命令查看是否成功。 Switch#show ip route Codes: C - connected, S - static, I - IGRP, 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, E - EGP i - IS-IS, 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 C 192.168.1.0/24 is directly connected, Vlan10 ##出现这两行就表示成功了 C 192.168.5.0/24 is directly connected, Vlan50 Switch# 配置完vlan的ip后,我们已经可以通过三层交换机来分割不同局域网并进行通信了,接下来就开启三层交换机以及路由器的RIP协议。各个网段的网络号: 先三层交换机开启协议: Switch#en Switch#conf t Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#router rip ##配置命令 Switch(config-router)#network 192.168.1.0 ##申明本机的直连网段 Switch(config-router)#network 192.168.5.0 Switch(config-router)#exit Switch(config)#接下来时路由器Router 0开启协议: Router>en Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#router rip Router(config-router)#network 192.168.1.0 Router(config-router)#network 192.168.2.0 Router(config-router)#exit Router(config)#路由器Router 1类似,这里就不做展示了。完成后我们看看路由表。 三层交换机: Switch#show ip route Codes: C - connected, S - static, I - IGRP, 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, E - EGP i - IS-IS, 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 C 192.168.1.0/24 is directly connected, Vlan10 R 192.168.2.0/24 [120/1] via 192.168.1.1, 00:00:18, Vlan10 ##有R这两项就说明成功了 R 192.168.3.0/24 [120/2] via 192.168.1.1, 00:00:18, Vlan10 C 192.168.5.0/24 is directly connected, Vlan50 Switch#Router 0路由表: Router#show ip route Codes: C - connected, S - static, I - IGRP, 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, E - EGP i - IS-IS, 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 C 192.168.1.0/24 is directly connected, FastEthernet1/0 C 192.168.2.0/24 is directly connected, Serial2/0 R 192.168.3.0/24 [120/1] via 192.168.2.2, 00:00:18, Serial2/0 R 192.168.5.0/24 [120/1] via 192.168.1.2, 00:00:16, FastEthernet1/0 Router# 接下来就pc机之间看能不能ping通。 |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |