Day12、数据链路层及交换机工作原理
1.数据链路层工作的层次(2层 Data Link Layer)
2.传输单元:帧
3.帧结构:
- 帧头:目的Mac地址(6字节)+ 源Mac地址(6字节)+ 类型(2字节)= 14 字节
- MTU:1500字节(国内)
- 帧尾:4字节
4.类型的作用:识别上层协议
0x0800:上层为IP协议
0x0806:上层为ARP协议
5.交换机的工作原理:
收到一个数据帧后,
a.首先学习帧中的源Mac地址形成Mac地址表,
b.然后检查帧中的目的Mac地址,并匹配Mac地址表:
若表中存在匹配项,则进行单播转发,
若表中无匹配项,则除接受端口外广播转发
c.Mac地址表的老化时间默认是300秒(可以自行修改)
6.交换机端口
E 10Mb
F 100Mb
G 1000Mb
Te 10000Mb
F 0/1 ( 0:模块号 1:接口号 )
端口的状态:up/down
down的3种可能:
- 人为down掉
- 速率不匹配
- 双工模式不匹配(双工duplex)(全双工、半双工、单工)
7.交换机五大工作模式及命令
五大工作模式:
1)用户模式
Switch>
可以查看交换机基本简单信息,不能做任何修改配置!!!
2)特权模式
Switch>enable
Switch#
可以查看交换机所有配置,不能修改配置
但是可以做测试、保存、初始化等操作
3)全局配置模式
Switch# configure terminal
Switch(config)#
默认不能查看交换机的配置,但是可以修改配置(对全局生效)
4)接口模式
Switch(config)#interface f0/1
Switch(config-if)#
默认不能查看交换机的配置,但是可以修改配置(对端口生效)
5)console口/线/控制台模式
Switch(config-if)#line console 0
Switch(config)#line console 0
可以修改配置(对console口生效)
命令:
1)配置主机名
configure terminal
hostname 设备名
2)设置用户密码
configure terminal
line console 0
password 密码
login
exit
3)配置特权密码
configure terminal
enable password 密码 (明文)
enable secret 密码 (密文)
4)running-config
系统第一次开机,会自动在内存中生成一个干净的running-config
5)保存配置
copy running-config startup-config 或 write
6)清空/擦除/初始化配置
erase startup-config
7)交换机开机动作
首先从硬盘中查找startup-config文件,若存在,则直接复制到内存中并改名为running-config,反之,创建新的running-config
所以要记得保存配置(关机后就凉凉)
8)查看running-config配置
enable
show running-config
9)查看startup-config配置
enable
show startup-config
10)查看Mac地址表
show mac-address-table
11)查看接口状态
enable
show ip interface brief
12)手工关闭接口
interface f0/1
shutdown
exit
13)手工开启接口
interface f0/1
no shutdown
exit
14)重启设备
enable
reload
15)为三层端口配IP
enable
configure terminal
interface f0/1
ip address 10.1.1.254 255.255.255.0
no shutdown
exit




16)开启远程控制
configure terminal
line vty 0 4
- vty:Virtual type terminal.虚拟类型终端
- 0:console 0
- 4:允许远程终端登录的数量
transport input telnet/ssh/all/none
password 密码
login
exit
实验:
1.成功实现在pc上telnet或ssh远程连接到路由器上,其中只做login验证




configure terminal
hostname r1
ip domain-name qq.com(随便写)
crypto key generate rsa
line vty 0 4
login local
exit
username xx password xxxx
实验:
2.成功实现在pc上telnet或ssh远程连接到路由器上,其中要求做login local验证


实验:一台PC控制两台交换机和一台路由器

1.配IP,子网掩码,网关
2.给路由器配接口配IP,子网掩码
3.PC和路由器,PC和PC间能互相ping通
4.路由器设置login
5.给交换机配IP,子网掩码,网关
6.PC和交换机之间能ping通
7.交换机设置login
8.利用PC远程登录

17)给交换机配IP
configure terminal
interface VLAN 1
ip address IP地址 子网掩码
no shutdown
exit

18)给交换机配网关
configure terminal
ip default-gateway 网关地址

19)关闭自动解析功能
configure terminal
no ip domain-lookup
-------------------------------------------
个性签名:纸上学来终觉浅,绝知此事要躬行。
如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!

浙公网安备 33010602011771号