查看系统日志是专业的网路管理者必做的功课,因为透过查看系统日志可以帮助你分析及查明问题的原因;并可以事先进行防范。在Cisco ASA上有许多设定系统日志的方法,找一个你喜欢的方式开始进行监控吧。
ciscoasa(config)# logging enable //启用系统日志功能
ciscoasa(config)# logging debug-trace //系统日志包括debug的讯息
INFO: ‘logging debug-trace’ is enabled. All debug messages are currently being redirected to syslog and will not appear in any monitor session
ciscoasa(config)# logging emblem //系统日志使用EMBLEM 格式
ciscoasa(config)# logging timestamp //发送出来的系统日志要有日期栏位
ciscoasa(config)# logging list Web***_Errors level errors class web***
//指定要送出的事件讯息,这样所试范的为:只有关于Web***相关「class web*** 的错误讯息「level errors」, 当然你也可以自行定义所需的系统日志
//指定要如何将事件讯息传送出去,你可以按照需要把不同的日志发到不同的地方
Internal Buffer – 发送到Pix/ASA设备中的缓存区。
优点:不需要借助任何软件和硬件,日志就存在设备本身中。
缺点:缓冲区的大小受硬件限制,默认为4K bytes。一旦超过设定大 小就会覆盖之前的日志。(可以把写满的日志发到FTP服务器上来避免被覆盖)
命令:logging buffered [severity_level]
范例:ciscoasa(config)# logging flash-bufferwrap
ciscoasa(config)# logging flash-maximum-allocation 2000
ciscoasa(config)# logging flash-minimum-free 4000
Syslog message server – 发送到Syslog 服务器
优点:可以存储大量的日志文件,利于翻查历史日志。
缺点:需要syslog服务器来收集syslog message。
命令:logging host [interface_name] [tcp[/port] | udp[/port]] (预设为UDP 514)
logging trap [severity_level]
范例:ciscoasa(config)# logging trap Web***_Errors
Email – 发送到指定的邮件地址
优点:及时把日志发送到邮件。如果有黑莓的话,随时随地都可以收到。
缺点:需要SMTP服务器来转发邮件。
命令:logging mail [severity_level]
logging receipient-address [email_address]
logging from-address [email_address]
smtp-server [ip_address]
范例:ciscoasa(config)# logging mail Web***_Errors
ciscoasa(config)# logging from-address [email protected] //设定寄件者
ciscoasa(config)# logging recipient-address [email protected] level errors
Console – 发送到控制台
优点:实时。不需要其他软硬件的支持。
缺点:需要物理上连接到控制口,而且无法保存。当网络流量大的时候,开启这项会影响性能。
命令:logging console [severity_level]
范例:ciscoasa(config)# logging console Web***_Errors
Telnet/SSH Session – 发送到Telnet/SSH 虚拟终端
优点:实时。不需物理上连接到设备。
缺点:无法保存。
命令:logging monitor [severity_level]
terminal monitor
范例:ciscoasa(config)# logging monitor Web***_Errors
ASDM – 发送到Pix/ASA图形化管理界面
优点:实时。在图像界面下实现过滤等功能更为简便。
缺点:无法保存。
命令:logging asdm [severity_level]范例:
ciscoasa(config)# logging asdm Web***_Errors
SNMP server – 发送到SNMP服务器
优点:可以存储大量的日志文件,利于翻查历史日志。
缺点:需要SNMP服务器来收集snmp trap。
命令:logging history [severity_level]
snmp-server host [if_name] [ip_address]
snmp-server location [text]
snmp-server contact [text]
snmp-server community [key]
snmp-server enable traps范例:
ciscoasa(config)# logging history Web***_Errors
实例说明:将日志文件送至Syslog Server
ciscoasa(config)# logging trap Web***_Errors //指定要送出的事件讯息。
ciscoasa(config)# logging host inside 192.168.0.10 format emblem //设定连接的Log Server ,连结埠为UDP 514,输出格式为EMBLEM
ciscoasa(config)# logging host inside 192.168.0.11 6/1470 secure //设定第二的Syslog Server ,连结埠为TCP 1470,并使用SSL加密方式输出。
WARNING: A secure logging connection can only be established with a
SSL/TLS capable syslog server. If a SSL/TLS connection cannot
be established, all new connections will be denied.
This default behavior may be changed by enabling logging
permit-hostdown.
设定要输出的讯息
ciscoasa(config)# logging trap Web***_Errors //自订输出的
ciscoasa(config)# logging trap debugging //7级以上的
ciscoasa(config)# logging permit-hostdown
实例说明:将日志文件送至E-mail
设定用Mail 输出讯息
ciscoasa(config)# logging mail Web***_Errors
ciscoasa(config)# logging from-address [email protected] //设定寄件者
ciscoasa(config)# logging recipient-address [email protected] level errors //设定收件者
ciscoasa(config)# smtp-server 192.168.0.10 192.168.0.20 //设定SMTP Server
实例说明:将讯息先存在flash再转存至FTP
ciscoasa(config)# logging flash-bufferwrap //启用flash储存功能
WARNING: Enabling the logging flash-bufferwrap feature could cause a
depletion of all available memory under high syslog
rates. Please adjust your buffered logging level
appropriately
ciscoasa(config)# logging flash-maximum-allocation 2000
ciscoasa(config)# logging flash-minimum-free 4000
ciscoasa(config)# logging ftp-bufferwrap //启用FTP储存功能
WARNING: Enabling the logging ftp-bufferwrap feature could cause a
depletion of all available memory under high syslog
rates. Please adjust your buffered logging level
appropriately
ciscoasa(config)# logging ftp-server 192.168.0.10 . cisco P@ssw0rd //设定FTP Server IP,帐号及密码。
参考资料:
ciscoasa# sh logging //查看logging 设定
Cisco日志等级一共分为8级,0级最高,7级最低。具体划分如下:
Emergency (severity 0)—The system is unusable
Alert (severity 1)—Immediate action is needed
Critical (severity 2)—Critical condition
Error (severity 3)—Error condition
Warning (severity 4)—Warning condition
Notification (severity 5)—Normal but significant condition
Informational (severity 6)—Informational message
Debugging (severity 7)—Debugging message