CCNA学习笔记三 -- 路由和交换

网络畅通的条件

数据包能去能回
沿途的路由器必须知道到目标地址如何转发
沿途的路由器必须知道回来的数据包如何转发

路由器直连的网络 不用告诉路由器如何转发
路由器没有直连的网络 管理员需要告诉路由器到目标网络如何转发 即添加静态路由

1
2
3
4
5
6
(config)#ip route 192.168.1.0 255.255.255.0 192.268.2.0  设置数据包 到192.168.1.0/24的数据包下一跳给192.168.2.0
(config)#tracroute ip_address 跟踪数据包路径
#show ip route 查看路由表
(config)#no ip route 192.168.1.0 255.255.255.0 删除路由表
windows上添加路由表 route add ip_adress mask ip_web
windows查看路由表 netstat-r route print

动态路由

优先级 直连0 静态路由1 eigp90 rip120
RIP协议 跳数判断,周期性(30s)更新路由表,最大跳数16跳

1
2
3
4
5
6
7
8
(config)#router rip  启用rip协议  
(config-router)#network 192.168.1.0 该网段参与rip协议
#debug ip rip 显示rip协议信息
#undebug all 关闭rip协议信息显示
#show ip protocols 显示应用协议
EIGP协议 优先级高于RIP
(config)#router eigp 10 启用eigp协议,相同编号路由器才可以交换路由信息
(config-router)#network 192.168.1.0 该网段参与eigp协议

交换

集线器 不安全、冲突域、带宽共享
交换机 基于目标MAC地址转发、学习MAC地址、端口独享带宽、没有冲突、广播会出问题

1
2
3
4
5
6
7
8
9
#show mac-address-table 显示MAC地址表
#config terminal
(config)#interrface fastEthernet 0/4
(config-if)#switchport mode access 接机算机的接口
(config-if)#switchport port-security 启用安全
(config-if)#switchport port-security violation shutdown 违反安全规则down掉
(config-if)#switchport port-security maxium 2 限制连接数量
(config)#interrface range fastEthernet 0/1 - 24 选中1-24个口
(config-if-range)#switchport port-security mac-adddress sticky MAC地址终止学习

生成树协议

为了高可用局域网交换机连接有了环路
为了阻断网络中的广播有了生成树协议

1
2
3
#show spanning-tree 查看交换机端口以及生成树状态
(config)#spanning-tree vlan 1 priority 4096更改路由器优先级为4096,值越小优先级越高
(config)#no spanning-tree vlan 1 关闭生成树协议