设备小知识点实验.docx
《设备小知识点实验.docx》由会员分享,可在线阅读,更多相关《设备小知识点实验.docx(48页珍藏版)》请在冰豆网上搜索。
![设备小知识点实验.docx](https://file1.bdocx.com/fileroot1/2023-2/1/3e87341f-4d19-42b0-87db-0f1de7d49f66/3e87341f-4d19-42b0-87db-0f1de7d49f661.gif)
设备小知识点实验
日志
在console口和linevty下输入:
loggingsynchronous//当输入命令的时候不被日志给打断。
Exec-timeoutminutesminutesseconds//登陆后多久没有操作设备就自动退出
Exec-timeout00//表示永不超时
全局模式下:
loggingon//开启日志的总开关
loggingconsole//日志信息发送到console口
loggingfilterflash:
//yssqt.txt//将日志保存到flash上的yssqt.txt的文件中
loggingbuffered7//将7级以及7级以上的日志存放到缓冲区
logginghostX.X.X.X//把日志存ip地址为X.X.X.X的主机上
loggingtraplevel//设置存在X.X.X.X主机上日志的级别,level是日志的级别,范围是从0-7
R3#terminalmonitor//允许在vty的窗口显示日志信息例如:
R1远程登陆到了R3,那么默认R1登陆到R3后对R3所执行的操作是不弹出日志,只有R1登陆到R3后输入该命令才会弹出R1登陆R3后对R3所执行的操作的命令
R3(config)#loggingmonitor7//设置允许在VTY窗口(如telnet窗口)上显示的日志信息级别
R3#terminalnomonitor//关闭在vty窗口显示日志的功能
R1(config)#servicesequence-numbers//弹出的日志会显示序号
R1(config)#servicetimestampsdebug/logdatetime//在每种日志消息中添加一个时间戳显示准确的日期和时间 UTC格式 标准格式MMDDHH:
MM:
SS
R1(config)#servicetimestampsdebug/logupdate//在消息中包括路由器开机以来的时间
R1(config)#loggingconsole?
<0-7>Loggingseveritylevel
alertsImmediateactionneeded(severity=1)
criticalCriticalconditions(severity=2)
debuggingDebuggingmessages(severity=7)
discriminatorEstablishMD-Consoleassociation
emergenciesSystemisunusable(severity=0)
errorsErrorconditions(severity=3)
filteredEnablefilteredlogging
guaranteedGuaranteeconsolemessages
informationalInformationalmessages(severity=6)
notificationsNormalbutsignificantconditions(severity=5)
warningsWarningconditions(severity=4)
xmlEnablelogginginXML
选择弹出到console的日志的级别,从上往下从0开始到7,7级可看7级及7级以上的日志信息,默认是7级表示0-7级的都会显示。
日志的0、1、2这三个级别一定要密切关注,一般不常见,如果遇见基本上都是硬件马上要挂了,0级别日志叫紧急1级日志叫警觉、2级日志级别叫严重3级日志级别叫错误,4级别是警告、5级别是通知、6级别是一般性信息7级别的日志就是debug的信息
R1(config)#loggingfacility?
authAuthorizationsystem
cronCron/atfacility
daemonSystemdaemons
kernKernel
local0Localuse
local1Localuse
local2Localuse
local3Localuse
local4Localuse
local5Localuse
local6Localuse
local7Localuse
lprLineprintersystem
mailMailsystem
newsUSENETnews
sys10Systemuse
sys11Systemuse
sys12Systemuse
sys13Systemuse
sys14Systemuse
sys9Systemuse
syslogSyslogitself
userUserprocess
uucpUnix-to-Unixcopysystem
R1(config)#loggingfacility
facility是可以自已定义的,发往syslog的,比如交换机A可以设置成local0交换机B可设置成local1默认是local7这样在日志服务器上便于区分是哪台交换机发来的日志,可能还有别的方面的用途。
还可以给日志设置缓存:
loggingbuffered字节默认是4096个字节。
Showlogging//查看日志
R1(config)#loggingbuffered?
<0-7>Loggingseveritylevel
<4096-2147483647>Loggingbuffersize
alertsImmediateactionneeded(severity=1)
criticalCriticalconditions(severity=2)
debuggingDebuggingmessages(severity=7)
discriminatorEstablishMD-Bufferassociation
emergenciesSystemisunusable(severity=0)
errorsErrorconditions(severity=3)
filteredEnablefilteredlogging
informationalInformationalmessages(severity=6)
notificationsNormalbutsignificantconditions(severity=5)
warningsWarningconditions(severity=4)
xmlEnablelogginginXMLtoXMLloggingbuffer
Loggingbuffered4096设置日志缓存大小为4096个字节。
R1(config)#logging?
HostnameorA.B.C.DIPaddressofthelogginghost//把日志传到服务器上
alarmConfiguresyslogforalarms
bufferedSetbufferedloggingparameters
buginfEnablebuginfloggingfordebugging
cns-eventsSetCNSEventlogginglevel
consoleSetconsoleloggingparameters
countCounteverylogmessageandtimestamplastoccurrence
discriminatorCreateormodifyamessagediscriminator
dmvpnDMVPNConfiguration
esmSetESMfilterrestrictions
exceptionLimitsizeofexceptionflushoutput
facilityFacilityparameterforsyslogmessages
filterSpecifyloggingfilter
historyConfiguresysloghistorytable
hostSetsyslogserverIPaddressandparameters
message-counterConfigurelogmessagetoincludecertaincountervalue
monitorSetterminalline(monitor)loggingparameters
onEnableloggingtoallenableddestinations
origin-idAddoriginIDtosyslogmessages
persistentSetpersistentloggingparameters
queue-limitSetloggermessagequeuesize
rate-limitSetmessagespersecondlimit
reloadSetreloadlogginglevel
server-arpEnablesendingARPrequestsforsyslogserverswhen
firstconfigured
source-interfaceSpecifyinterfaceforsourceaddressinlogging
transactions
trapSetsyslogserverlogginglevel
userinfoEnableloggingofuserinfoonprivilegedmodeenabling
R1(config)#logginghost12.1.1.2
R1(config)#loggingdiscriminatorEXCESSseveritydrops6msg-bodydropsEXCESSCOLL
R1(config)#loggingbuffered50000
R1(config)#loggingconsolediscriminatorEXCESS
TFTP拷贝flash中的文件
R1(config)#tftp-serverflash:
ccie.txt?
//iou中用tftp-serverunix:
ccie.txt
<1-99>IPaccesslistofrequestinghosts
<1300-1999>IPexpandedaccesslistofrequestinghosts
aliasfilealias
//把R1配置成tftpserver其他路由器可以下载到R1的flash中的ccie.txt这个文件默认所有人都可以下载到,但可以用acl匹配哪些地址才可以下载到。
R1#copystartup-configflash:
ccie.txt//如果R1没有flash文件可以把当前的配置文件复制到flash,iou中时用unix来代替flash
上图所示:
iou中已经没有了flash的概念,而取而代之的是unix这个目录
R1#erasestartup-config//擦除现在flash中的配置文件
R2#copytftp:
//12.1.1.1/ccie.txtflash:
cisco.txt//把R1上flash中的ccie.txt文件拷贝到这台路由器的flash中,并重命名为cisco.txt
Showflash:
dirflash:
Moreflash:
文件名.格式
第一个数据包是R2发出的源端口号是随机目标端口号为69
第二个数据包是R1发出的,源端口号随机目标端口号为R2上次数据包的源端口号
第三个数据包还是R2发出的源端口号是之前的,目标端口号是上次R1发送的数据包的源端口号,然后之后交互的数据都全是这两个端口号
关闭或打开http/https服务,iphttpserver与iphttpsecure-server用来在网页上配置路由器,在网页中输入路由器或交换机的ip地址。
可以在全局模式下:
iphttpserver来打开http服务
noipserver来关闭http服务
可以在全局模式下:
iphttpsecure-server来打开https服务
noiphttpsecure-server关闭https服务
http服务和https服务的区别:
http传输的数据是不加密
https传输的数据是加密的(有些设备的版本不支持https)
EEM可以完成一系列的命令操作,类似于脚本命令
图如上:
把R1上的lo0口打开
R1(config)#eventmanagerappletShutdown//给这个管理事件命个名字叫Sutdown
R1(config-applet)#eventsyslogpattern“InterfaceLoopback0,changedstatetoadministrativelydown”//抓取部分系统日志的信息
R1(config-applet)#action1.0clicommand"enable"//当在命令行里输入“enable”时的这个动作
R1(config-applet)#action2.0clicommand"configureterminal"
R1(config-applet)#action3.0clicommand"interfaceloopback0"
R1(config-applet)#action4.0clicommand"noshutdown"
R1(config-applet)#action5.0syslogmsgF00Downpriority7//会弹出一个名字叫“Shutdown”关于eventmanager事件的日志,日志的内容是”F00Down”
R1#showrunning-config|beginevent
当把R1上的lo0口shutdown的时候,发现这个接口又自动打开了。
当关闭这个接口的时候,会弹出接口关闭的日志信息,上面抓取的内容就是接口关闭的日志信息,下面的动作就是当满足这个日子信息的时候就会执行自己所写的动作,所以接口它又立马打开了。
SCP(SecureCopy)
将R1的flash中的配置文件ccie.txt文件拷贝到R2的flash中
R2作为server,R1作为client
R2(config)#aaanew-model
//AAA是AuthenticationAuthorizationandAccounting(认证、授权和记账)的简称,它提供了对认证、授权和记账功能进行配置的一致性框架
R2(config)#aaaauthenticationlogindefaultlocal//配置认证
R2(config)#aaaauthorizationexecdefaultlocal//配置授权
R2(config)#usernameyssqtprivilege15passwordiloveyou
R2(config)#ipdomain-name
R2(config)#cryptokeygeneratersa
Howmanybitsintthemodulus[512]:
1024
R2(config)#ipscpserverenable
R1#copyflash:
ccie.txtscp:
//yssqt@12.1.1.2//此命令中的flash:
ccie是指R1flash中的文件,yssqt是指R2中设置的用户名,12.1.1.2是指R2与R1相连接的R2的f0/0接口地址。
//如果不能拷贝过去的原因是:
此文件不存在或用户名等级低和加密位数低或密码位数少。
自动命令
R2(config)#usernameciscoprivilege15passwordcisco//优先级过低提示自动命令无效
R2(config)#linevty015
R2(config-line)#loginlocal//不能用线下密码登陆,否则会提示自动命令无效
R2(config-line)#autocommandshowrunning-config
R2(config-line)#end
//当从R1登陆到R2后就开始自动显示showrunning-config命令的的内容
R1#telnet23.1.1.3
Trying23.1.1.3...Open
UserAccessVerification
Username:
cisco
Password:
Buildingconfiguration...
Currentconfiguration:
1097bytes//当前配置命令占用的字节数
!
version12.4
servicetimestampsdebugdatetimemsec
servicetimestampslogdatetimemsec
noservicepassword-encryption
!
hostnameR2
!
boot-start-marker
boot-end-marker
!
!
noaaanew-model
memory-sizeiomem5
noipicmprate-limitunreachable
ipcef
!
!
!
!
noipdomainlookup
!
multilinkbundle-nameauthenticated
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
--More—
//也可以针对用户来做
R2(config)#usernameciscoprivilege15passwordcisco
R2(config)#usernameciscoautocommandshowiproute
R1#telnet12.1.1.2
Trying12.1.1.2...Open
UserAccessVerification
Username:
cisco
Password:
Codes:
C-connected,S-static,R-RIP,M-mobile,B-BGP
D-EIGRP,EX-EIGRPexternal,O-OSPF,IA-OSPFinterarea
N1-OSPFNSSAexternaltype1,N2-OSPFNSSAexternaltype2
E1-OSPFexternaltype1,E2-OSPFexternaltype2
i-IS-IS,su-IS-ISsummary,L1-IS-ISlevel-1,L2-IS-ISlevel-2
ia-IS-ISinterarea,*-candidatedefault,U-per-userstaticroute
o-ODR,P-periodicdownloadedstaticroute
Gatewayoflastresortis0.0.0.0tonetwork0.0.0.0
12.0.0.0/24issubnetted,1subnets
C12.1.1.0isdirectlyconnected,FastEthernet0/1
S*0.0.0.0/0isdirectlyconnected,FastEthernet0/1
[Connectionto12.1.1.2closedbyforeignhost]
R1#
R2(config)#usernameccieprivilege2passwordccie
//当R1登陆到ccie这个用户名到R3后,发现R1根本无法进入到全局模式下,因为给的权限不够,有些命令无法操作。
R1#telnet12.1.1.2
Trying23.1.1.3...Open
UserAccessVerification
Username:
ccie
Password:
R3#
R3#
R2#showiproute
R2#showiproute
Codes:
C-connected,S-static,R-RIP,M-mobile,B-BGP
D-EIGRP,EX-EIGRPexternal,O-OSPF,IA-OSPFinterarea
N1-OSPFNSSAexternaltype1,N2-OSPFNSSAexternaltype2
E1-OSPFexternaltype1,E2-OSPFexternaltype2
i-IS-IS,su-IS-ISsummary,L1-IS-ISlevel-1,L2-IS-ISlevel-2
ia-IS-ISinterarea,*-candidatedefault,U-per-userstaticroute
o-ODR,P-periodicdownloadedstaticroute
Gatewayoflastresortis0.0.0.0tonetwork0.0.0.0
12.0.0.0/24issubnetted,1subnets
C12.1.1.0isdirectlyconnected,FastEthernet0/1
S*0.0.0.0/0isdirectlyconnected,FastEthernet0/1
R2#showrun
R2#showrun
R2#showrun
R2#showrunn
R2#showrunn
R2#showrunn
R2#conft
^
%Invalidinputdetectedat'^'marker.