实验软件Packet Tracer 5.0
1.几种命令模式
Switch>
提示符表示在用户命令模式。只能使用一些查询命令
Switch#
这种提示符表示在特权模式下。
Switch(config)#
这种提示符表示在全局配置模式。
Switch(config-if)#
这种提示符表示在端口(interface)配置模式。
Switch>en
Switch#disable
Switch>enable
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int fa 0/1
Switch(config-if)#exit
Switch(config)#exit
Switch#
%SYS-5-CONFIG_I: Configured from console by console
Switch#disable
Switch>
2.检查、查看命令
这些命令是查看当前配置状况,通常是以show(sh)为开始命令。例如show version查看ios版本,show flash查看当前flash内存使用状况、show mac-address-table查看mac地址列表,show ? 查看帮助。
Switch# show version
Switch# sh flash
Switch#sh ?
Switch#show interface fa 0/1
3.密码设置命令
对路由器和交换机设置密码,是对于这些网络设备的基本安全性要求,但是后面为了试验的方便就不进行密码设置了。
Switch(config)#line console 0
Switch(config-line)#password line
Switch(config-line)#login
Switch(config-line)#line vty 0 4
Switch(config-line)#password vty
Switch(config-line)#login
Switch(config-line)#exit
解释:设置各种密码。line console 0进入设置控制台模式,password line设置密码,login启用密码认证(默认情况不启用),line vty 0 4标识可以同时打开5个telnet远程会话(vty远程登录的虚拟端口)。
默认情况下这些密码都是明文形式存储的,所以很容易查询到,以密文形式存储各种密码:
Switch(config)>service password-encryption
设置密文密码
Switch(config)#line vty 0 4
Switch(config-line)#password 7 082D45400C
password 7 082D45400C,第一个7表示加密方式,使用思科自己的加密方式 后面跟密码加密的密文(尴尬)。
4.配置IP地址和默认网关
Switch(config)#interface vlan 1
Switch(config-if)#ip address 192.168.0.253 255.255.255.0
Switch(config-if)#ip default-gateway 192.168.0.254
5.管理MAC地址表
Switch#show mac-address-table
解释:显示mac地址列表
Switch#clear mac-address-table dynamic
清除动态MAC地址列表
Switch(config)#mac-address-table static 00d0.baa9.975c vlan 1 interface fa0/1
6.配置端口安全
Switch(config)#int fa 0/2
Switch(config-if)#switchport mode access
Switch(config-if)#switchport port-security 打开端口防护
Switch(config-if)#switchport port-security maximum 4 允许最高5个MAC
7.实例
结构图如下:
配置过程如下:
1.添加设备
2.连接线路
3.添加备注(主机、交换机、路由器)
4.配置路由器
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int fa 0/0
Router(config-if)#ip address 192.168.1.1 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
Router(config-if)#exit
Router(config)#line vty 0 4
Router(config-line)#password asd
Router(config-line)#login
Router(config-line)#exit
Router(config)#enable password asd
5.配置交换机
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname S1
S1(config)#line vty 0 4
S1(config-line)#password asd
S1(config-line)#login
S1(config-line)#int vlan 1
S1(config-if)#ip address 192.168.1.2 255.255.255.0
S1(config-if)#no shutdown
S1(config-if)#
%LINK-5-CHANGED: Interface Vlan1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up
S1(config-if)#enable password asd
6.配置两个主机的地址、子网掩码
测试与其他设备的连通性
附录:常用简繁写说明
简写 | 全写 | 含义 |
---|---|---|
en | enable | 由用户模式进入特权模式 |
conf t | configure terminal | 由特权模式进入配置模式 |
sh | show | 在特权模式下,显示设备信息 |
vty | Virtual type terminal | 虚拟类型终端 |