上学时学过一学期NA的课程,但是后来就再没用过,基本忘没了,工作中会用到,复习一下。
用这个软件:PacketTracer53
一、几种配置模式:
switch> 用户命令模式
switch#特权命令模式
switch(config)#全局配置模式
switch(config-if)#端口配置模式
enanble可以从用户模式进入特权模式
- Switch>enable
- Switch#
disable退出全局模式
- Switch#disable
- Switch>
conf t可以从特权模式进入全局配置模式
- Switch#configure terminal
- Enter configuration commands, one per line. End with CNTL/Z.
- Switch(config)#
hostname可以修改名字,全局配置模式下才行
- Switch(config)#hostname xiaoqi
- xiaoqi(config)#
interface f0/1从全局配置模式进入端口配置模式
- xiaoqi(config)#interface fastEthernet 0/1
- xiaoqi(config-if)#
二、检查、查看命令
sh ver 查看IOS版本
- xiaoqi#show version
- Cisco Internetwork Operating System Software
- IOS (tm) C2950 Software (C2950-I6Q4L2-M), Version 12.1(22)EA4, RELEASE SOFTWARE(fc1)
- Copyright (c) 1986-2005 by cisco Systems, Inc.
- Compiled Wed 18-May-05 22:31 by jharirba
- Image text-base: 0x80010000, data-base: 0x80562000
- .......
sh flash查看内存使用状况
- xiaoqi#show flash:
- Directory of flash:/
- 1 -rw- 3058048 <no date> c2950-i6q4l2-mz.121-22.EA4.bin
- 64016384 bytes total (60958336 bytes free)
sh mac-address-table查看MAC地址表
- xiaoqi#show mac-address-table
- Mac Address Table
- -------------------------------------------
- Vlan Mac Address Type Ports
- ---- ----------- -------- -----
sh interface f0/1 查看某个端口信息
- xiaoqi#show interfaces f0/1
- FastEthernet0/1 is down, line protocol is down (disabled)
- Hardware is Lance, address is 0010.11d2.7a01 (bia 0010.11d2.7a01)
- BW 100000 Kbit, DLY 1000 usec,
- reliability 255/255, txload 1/255, rxload 1/255
- Encapsulation ARPA, loopback not set
- Keepalive set (10 sec)
- Half-duplex, 100Mb/s
sh ? 所有可以查看的信息
- xiaoqi#show ?
- access-lists List access lists
- arp Arp table
- boot show boot attributes
- cdp CDP information
- clock Display the system clock
- dtp DTP information
- etherchannel EtherChannel information
- flash: display information about flash: file system
- history Display the session command history
- hosts IP domain-name, lookup style, nameservers, and host table
- interfaces Interface status and configuration
- ip IP information
- logging Show the contents of logging buffers
- mac-address-table MAC forwarding table
- mls Show MultiLayer Switching information
- port-security Show secure port information
- privilege Show current privilege level
- processes Active process statistics
- running-config Current operating configuration
- sessions Information about Telnet connections
- snmp snmp statistics
- spanning-tree Spanning tree topology
- startup-config Contents of startup configuration
- storm-control Show storm control configuration
- tcp Status of TCP connections
- tech-support Show system information for Tech-Support
- terminal Display terminal configuration parameters
- users Display information about terminal lines
- version System hardware and software status
- vlan VTP VLAN status
- vtp VTP information
三、密码设置
进入全局配置模式后enable password ***可以设置从用户模式进入特权模式的密码。
- xiaoqi>enable //先进入特权模式
- xiaoqi#conf t //再进入全局配置模式
- Enter configuration commands, one per line. End with CNTL/Z.
- xiaoqi(config)#enable password xiaoqi //将密码设为xiaoqi
- xiaoqi(config)#line console 0 //进入console配置模式
- xiaoqi(config-line)#password xiaoqi //设置连接console口所需密码
- xiaoqi(config-line)#login //生效
- xiaoqi(config-line)#line vty 0 4 //设置远程连接
- xiaoqi(config-line)#password xiaoqi //设置远程连接密码
- xiaoqi(config-line)#login //生效
service password-encryption设置密码已加密的形式存放
- xiaoqi(config)#service password-encryption //在全局配置模式下
四、配置IP地址及默认网关
- xiaoqi(config)#interface vlan 1 //进入vlan1
- xiaoqi(config-if)#ip address 192.168.0.253 255.255.255.0 //设置vlan1的ip
- xiaoqi(config-if)#ip default-gateway 192.168.0.254 //设置vlan1的网关
五、管理mac地址表
- xiaoqi>show mac-address-table
- xiaoqi#show mac-address-table
显示MAC地址表两种模式都能看
- xiaoqi#clear mac-address-table
清空mac地址表,只能在特权模式下清空,全局模式不行
- xiaoqi(config)#mac-address-table static 00d0.baa9.975c vlan 1 interface fa0/1 //设置mac地址(在全局模式)
- xiaoqi#sh mac-address-table
- Mac Address Table
- -------------------------------------------
- Vlan Mac Address Type Ports
- ---- ----------- -------- -----
- 1 00d0.baa9.975c STATIC Fa0/1
- Switch(config-if)#mac-address 12.12.12 //改变端口的MAC
六、配置端口安全
- xiaoqi#conf terminal
- Enter configuration commands, one per line. End with CNTL/Z.
- xiaoqi(config)#interface fa0/2
- xiaoqi(config-if)#switchport mode access
switchport mode access,端口的默认模式,可以连电脑,另一种模式是trunk,用于交换机级联传输vlan信息。
- Switch(config-if)#switch port-security maximum 4 //允许该端口下MAC条目最大数量为4
- Switch(config-if)#switch port-security mac-address 0019.5535.b828
- //允许0019.5535.b828设备介入本端口
- Switch(config-if)#switchport port-security violation shutdown //?
七、其他
exit 退回到上级模式
end 直接回到特权模式
enable secert *** 配置进入特权模式的密码,密码加密
no ip domain-lookup 路由器不适用dns服务器解析主机的ip地址
logging synchonous 对路由器上的提示信息进行同步,防止信息干扰我们输入命令
no ip routing 关闭路由器的路由功能
show line 显示个线路的状态
line 33 48 进入33-38线路模式
transport input all 允许所有协议进入线路
int loopback0 进入loopback0接口
alias exec crl clear line 33 为命令起一个别名
privilege exec level 0 clear line 把命令clear line的登记该为0,在用户模式下也可以执行
banner motd 设置用户登陆路由器的提示信息
sh running-config 显示当前配置
保存配置信息
- Switch#copy running-config startup-config
- Destination filename [startup-config]?
- Building configuration...
- [OK]
sh history 显示历史命令