上學時學過一學期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 顯示歷史命令