上学时学过一学期NA的课程,但是后来就再没用过,基本忘没了,工作中会用到,复习一下。 

用这个软件:PacketTracer53

一、几种配置模式:

  switch> 用户命令模式

  switch#特权命令模式

  switch(config)#全局配置模式

  switch(config-if)#端口配置模式

enanble可以从用户模式进入特权模式

 
  
  1. Switch>enable 
  2. Switch# 

disable退出全局模式

 
  
  1. Switch#disable 
  2. Switch> 

conf t可以从特权模式进入全局配置模式

 
  
  1. Switch#configure terminal  
  2. Enter configuration commands, one per line.  End with CNTL/Z. 
  3. Switch(config)# 

hostname可以修改名字,全局配置模式下才行

 
  
  1. Switch(config)#hostname xiaoqi  
  2. xiaoqi(config)#  

 

interface f0/1从全局配置模式进入端口配置模式

 
  
  1. xiaoqi(config)#interface fastEthernet 0/1 
  2. xiaoqi(config-if)# 

二、检查、查看命令

sh ver 查看IOS版本

 
  
  1. xiaoqi#show version 
  2. Cisco Internetwork Operating System Software 
  3. IOS (tm) C2950 Software (C2950-I6Q4L2-M), Version 12.1(22)EA4, RELEASE SOFTWARE(fc1) 
  4. Copyright (c) 1986-2005 by cisco Systems, Inc. 
  5. Compiled Wed 18-May-05 22:31 by jharirba 
  6. Image text-base: 0x80010000, data-base: 0x80562000 
  7. .......

sh flash查看内存使用状况

 
  
  1. xiaoqi#show flash:  
  2. Directory of flash:/ 
  3.  
  4.     1  -rw-     3058048          <no date>  c2950-i6q4l2-mz.121-22.EA4.bin 
  5.  
  6. 64016384 bytes total (60958336 bytes free) 

sh mac-address-table查看MAC地址表

 
  
  1. xiaoqi#show mac-address-table  
  2.           Mac Address Table 
  3. ------------------------------------------- 
  4.  
  5. Vlan    Mac Address       Type        Ports 
  6. ----    -----------       --------    ----- 

sh interface f0/1 查看某个端口信息

 
  
  1. xiaoqi#show interfaces f0/1 
  2. FastEthernet0/1 is down, line protocol is down (disabled) 
  3.   Hardware is Lance, address is 0010.11d2.7a01 (bia 0010.11d2.7a01) 
  4.  BW 100000 Kbit, DLY 1000 usec, 
  5.      reliability 255/255, txload 1/255, rxload 1/255 
  6.   Encapsulation ARPA, loopback not set 
  7.   Keepalive set (10 sec) 
  8.   Half-duplex, 100Mb/s 

sh ? 所有可以查看的信息

 
  
  1. xiaoqi#show ? 
  2.   access-lists       List access lists 
  3.   arp                Arp table 
  4.   boot               show boot attributes 
  5.   cdp                CDP information 
  6.   clock              Display the system clock 
  7.   dtp                DTP information 
  8.   etherchannel       EtherChannel information 
  9.   flash:             display information about flash: file system 
  10.   history            Display the session command history 
  11.   hosts              IP domain-name, lookup style, nameservers, and host table 
  12.   interfaces         Interface status and configuration 
  13.   ip                 IP information 
  14.   logging            Show the contents of logging buffers 
  15.   mac-address-table  MAC forwarding table 
  16.   mls                Show MultiLayer Switching information 
  17.   port-security      Show secure port information 
  18.   privilege          Show current privilege level 
  19.   processes          Active process statistics 
  20.   running-config     Current operating configuration 
  21.   sessions           Information about Telnet connections 
  22.   snmp               snmp statistics 
  23.   spanning-tree      Spanning tree topology 
  24.   startup-config     Contents of startup configuration 
  25.   storm-control      Show storm control configuration 
  26.   tcp                Status of TCP connections 
  27.   tech-support       Show system information for Tech-Support 
  28.   terminal           Display terminal configuration parameters 
  29.   users              Display information about terminal lines 
  30.   version            System hardware and software status 
  31.   vlan               VTP VLAN status 
  32.   vtp                VTP information 

三、密码设置

进入全局配置模式后enable password ***可以设置从用户模式进入特权模式的密码。

 
  
  1. xiaoqi>enable  //先进入特权模式
  2. xiaoqi#conf t   //再进入全局配置模式
  3. Enter configuration commands, one per line.  End with CNTL/Z. 
  4. xiaoqi(config)#enable password xiaoqi  //将密码设为xiaoqi

 
  
  1. xiaoqi(config)#line console 0  //进入console配置模式
  2. xiaoqi(config-line)#password xiaoqi  //设置连接console口所需密码
  3. xiaoqi(config-line)#login  //生效
  4. xiaoqi(config-line)#line vty 0 4  //设置远程连接
  5. xiaoqi(config-line)#password xiaoqi  //设置远程连接密码
  6. xiaoqi(config-line)#login   //生效

service password-encryption设置密码已加密的形式存放

 
  
  1. xiaoqi(config)#service password-encryption  //在全局配置模式下 

四、配置IP地址及默认网关

 
  
  1. xiaoqi(config)#interface vlan 1  //进入vlan1
  2. xiaoqi(config-if)#ip address 192.168.0.253 255.255.255.0  //设置vlan1的ip
  3. xiaoqi(config-if)#ip default-gateway 192.168.0.254  //设置vlan1的网关

五、管理mac地址表

 
  
  1. xiaoqi>show mac-address-table  
 
  
  1. xiaoqi#show mac-address-table  

 显示MAC地址表两种模式都能看

 
  
  1. xiaoqi#clear mac-address-table  

清空mac地址表,只能在特权模式下清空,全局模式不行

 
  
  1. xiaoqi(config)#mac-address-table static 00d0.baa9.975c vlan 1 interface fa0/1 //设置mac地址(在全局模式) 

 
  
  1. xiaoqi#sh mac-address-table  
  2.           Mac Address Table 
  3. ------------------------------------------- 
  4.  
  5. Vlan    Mac Address       Type        Ports 
  6. ----    -----------       --------    ----- 
  7.  
  8.    1    00d0.baa9.975c    STATIC      Fa0/1 
 
  
  1. Switch(config-if)#mac-address 12.12.12 //改变端口的MAC

六、配置端口安全

 
  
  1. xiaoqi#conf terminal  
  2. Enter configuration commands, one per line.  End with CNTL/Z. 
  3. xiaoqi(config)#interface fa0/2 
  4. xiaoqi(config-if)#switchport mode access 

 switchport mode access,端口的默认模式,可以连电脑,另一种模式是trunk,用于交换机级联传输vlan信息。

 
  
  1. Switch(config-if)#switch port-security maximum 4  //允许该端口下MAC条目最大数量为4

 
  
  1. Switch(config-if)#switch port-security mac-address 0019.5535.b828 
  2. //允许0019.5535.b828设备介入本端口

 
  
  1. 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 显示当前配置

     保存配置信息

 
  
  1. Switch#copy running-config startup-config  
  2. Destination filename [startup-config]?  
  3. Building configuration... 
  4. [OK] 

    sh history 显示历史命令