audit守护进程可以通过/etc/audit/auditd.conf文件进行配置,默认的auditd配置文件可以满足大多数环境的要求。

  1. local_events = yes
  2. write_logs = yes
  3. log_file = /var/log/audit/audit.log
  4. log_group = root
  5. log_format = RAW
  6. flush = INCREMENTAL_ASYNC
  7. freq =
  8. max_log_file =
  9. num_logs =
  10. priority_boost =
  11. disp_qos = lossy
  12. dispatcher = /sbin/audispd
  13. name_format = NONE
  14. ##name = mydomain
  15. max_log_file_action = ROTATE
  16. space_left =
  17. space_left_action = SYSLOG
  18. action_mail_acct = root
  19. admin_space_left =
  20. admin_space_left_action = SUSPEND
  21. disk_full_action = SUSPEND
  22. disk_error_action = SUSPEND
  23. use_libwrap = yes
  24. ##tcp_listen_port =
  25. tcp_listen_queue =
  26. tcp_max_per_addr =
  27. ##tcp_client_ports = -
  28. tcp_client_max_idle =
  29. enable_krb5 = no
  30. krb5_principal = auditd
  31. ##krb5_key_file = /etc/audit/audit.key
  32. distribute_network = no

如果你的环境需要满足严格的安全规则,如下的一些配置可以参考:

log_file:audit 日志放置的路径。这里放置日志的地方最好是一个独立的分区(mount point),这样可以避免其他进程消耗掉这个路径的空间,并且可以为auditd提供精确的剩余空间。

max_log_file:指定每一个单独的audit log文件的最大的size,单位为M,必须设置为充分利用保存着审计日志文件所在分区的可用空间。默认为8M。

max_log_file_action:当达到了日志的最大size后,需要执行的动作,设置为KEEP_LOGS时,可以避免日志被重写。我们先看下如下的记录:

  1. linux-xdYUnA:/var/log/audit # ll
  2. total
  3. -rw------- root root Mar : audit.log
  4. -r-------- root root Mar : audit.log.
  5. -r-------- root root Mar : audit.log.
  6. -r-------- root root Mar : audit.log.
  7. -r-------- root root Mar : audit.log.
  8. linux-xdYUnA:/var/log/audit # ll
  9. total
  10. -rw------- root root Mar : audit.log
  11. -r-------- root root Mar : audit.log.
  12. -r-------- root root Mar : audit.log.
  13. -r-------- root root Mar : audit.log.
  14. -r-------- root root Mar : audit.log.

第一次查询时,audit.log还没有写满到8M,第二次查询时应该是已经到了8M了,重新写的audit.log。那么之前的audit.log去哪里了呢,我们仔细看每个日志文件的大小,不难发现。第一次查询到的audit.log.4已经没有了,系统认为这个是最老的日志,因为我们设置的num_logs为5,所以这个最老的日志就被删除了,或者理解为新日志把最老的日志给覆盖了。如果我们不想让日志被覆盖,我们可以设置为KEEP_LOGS。如下所示,一直增长的audit的日志,最后无论num_logs设置为多少,日志都在继续增加,这样,最好要保证存放audit日志的空间是一个独立分区,不然会影响其他系统日志的记录。

  1. linux-xdYUnA:/var/log/audit # ll
  2. total
  3. -rw------- root root Mar : audit.log
  4. -r-------- root root Mar : audit.log.
  5. -r-------- root root Mar : audit.log.
  6. -r-------- root root Mar : audit.log.
  7. -r-------- root root Mar : audit.log.
  8. -r-------- root root Mar : audit.log.
  9. -r-------- root root Mar : audit.log.
  10. -r-------- root root Mar : audit.log.

下面让我看一下max_log_file_action总共有几个不同的动作的具体英文解释吧。

  1. This parameter tells the system what action to take when the system has detected that the max file size limit has been reached.
    Valid values are ignore, syslog, suspend, rotate and keep_logs. If set to ignore, the audit daemon does nothing.
    syslog means that it will issue a warning to syslog. suspend will cause the audit daemon to stop writing records to the disk.
    The daemon will still be alive. The rotate option will cause the audit daemon to rotate the logs.
    It should be noted that logs with higher numbers are older than logs with lower numbers. This is the same convention used by the logrotate utility.
    The keep_logs option is similar to rotate except it does not use the num_logs setting. This prevents audit logs from being overwritten.

space_left:明确出磁盘剩余多少空间时,执行space_left_action指定的动作,这个值的设定需要保证,管理员有足够的时间响应并且清理磁盘空间,这个值的设定依赖于audit日志产生的速率。默认为75M。

space_left_action:磁盘空间快要不足时设定的动作。还是看英文解释吧。

  1. This parameter tells the system what action to take when the system has detected that it is starting to get low on disk space.
    Valid values are ignore, syslog, email, exec, suspend, single, and halt. If set to ignore, the audit daemon does nothing.
    syslog means that it will issue a warning to syslog.
    Email means that it will send a warning to the email account specified in action_mail_acct as well as sending the message to syslog.
    exec /path-to-script will execute the script. You cannot pass parameters to the script.
    suspend will cause the audit daemon to stop writing records to the disk. The daemon will still be alive.
    The single option will cause the audit daemon to put the computer system in single user mode.
    halt option will cause the audit daemon to shutdown the computer system.

admin_space_left:指出最低的磁盘剩余空间大小,当到达这个值时,执行admin_space_left_action指定的动作。

admin_space_left_action:可以设置为single,使系统成为single-user mode,然后让管理员释放磁盘空间。按照默认的来设置比较好。达到space_left时,执行syslog上报warning,达到admin_space_left时,停止记录日志。

  1. his parameter tells the system what action to take when the system has detected that it is low on disk space.
    Valid values are ignore, syslog, email, exec, suspend, single, and halt.

disk_full_action:当分区上没有空间时,执行的动作。默认为suspend。

disk_error_action:当分区出现error时,执行的动作。这些动作都依据你所需要的安全规则。

flush:这个参数与freq联合使用,freq表示的是在与硬件驱动强制同步前,有多少个记录可以发送到磁盘。这个确保audit数据与磁盘中的log文件保持同步。保持默认值即可。

更具体的配置参数可以参考

https://linux.die.net/man/5/auditd.conf

linux audit审计(3)--audit服务配置的更多相关文章

  1. linux的基本操作(NFS服务配置)

    服务配置 [什么是NFS] NFS会经常用到,用于在网络上共享存储.这样讲,你对NFS可能不太了解,笔者不妨举一个例子来说明一下NFS是用来做什么的.假如有三台机器A.B.C,它们需要访问同一个目录, ...

  2. Linux(Unix)时钟同步ntpd服务配置方法

    http://xu20cn.blog.51cto.com/274020/69689 假定时钟服务器IP地址为:192.168.0.1 服务器端配置: 1:置/etc/ntp.conf文件内容为: se ...

  3. windows + myeclipse 调试 linux + tomcat 的java web服务 配置方式

    一.linux tomcat配置和启动 1.catalina.sh第一行加入 declare -x CATALINA_OPTS="-Xdebug -Xrunjdwp:transport=dt ...

  4. windows虚拟机中DNS服务配置

    在linux虚拟机中进行DNS服务配置并进行正向解析反向解析我博客中已经写过,下面 我来介绍一下在windows虚拟机中DNS服务的配置使用. 1.打开一台windows虚拟机中服务器管理器——角色— ...

  5. linux audit审计(5)--audit规则配置

    audit可以配置规则,这个规则主要是给内核模块下发的,内核audit模块会按照这个规则获取审计信息,发送给auditd来记录日志. 规则类型可分为: 1.控制规则:控制audit系统的规则: 2.文 ...

  6. linux audit审计(6)--audit永久生效的规则配置

    定义reboot系统后,仍然生效的审计规则,有两种办法: 1.直接写入/etc/audit/audit.rules文件中,在service文件中需要加入ExecStartPost=-/sbin/aud ...

  7. linux的审计功能(audit)

    为了满足这样的需求:记录文件变化.记录用户对文件的读写,甚至记录系统调用,文件变化通知.什么是auditThe Linux Audit Subsystem is a system to Collect ...

  8. linux audit审计(4)--audit的日志切分,以及与rsyslog的切分协同使用

    audit的规则配置稍微不当,就会短时间内产生大量日志,所以这个规则配置一定要当心.当audit日志写满后,可以看到如下场景: -r-------- 1 root root 8388609 Mar 3 ...

  9. Oracle Audit 审计功能的认识与使用

    1.Audit的概念 Audit是监视和记录用户对数据库进行的操作,以供DBA进行问题分析.利用Audit功能,可以完成以下任务: 监视和收集特定数据库活动的数据.例如管理员能够审计哪些表被更新,在某 ...

随机推荐

  1. Python中的单例模式——装饰器实现剖析

    Python中单例模式的实现方法有多种,但在这些方法中属装饰器版本用的广,因为装饰器是基于面向切面编程思想来实现的,具有很高的解耦性和灵活性. 单例模式定义:具有该模式的类只能生成一个实例对象. 先将 ...

  2. 小a的子序列 (线性dp)

    思路:设dp[i][j]表示最大数为j,i为第i的位置的萌值.那么推导过程就是两种情况:1.第i位数不放数字,则结果就是dp[i-1][j]; 2.第i位放数字,则结果就是前面的萌值sum+dp[i- ...

  3. NodeJS的优缺点

    我们知道NodeJS是2009年5月,由Ryan Dahl开发,实质是对Chrome V8引擎进行了封装.Node.js对一些特殊用例进行优化,提供替代的API,使得V8在非浏览器环境下运行得更好,解 ...

  4. 【vue】vue +element 搭建及开发中项目中,遇到的错误提示

    1. import Layout from '@/views/layout/Layout'; export default [ { // 配置路由,当路径为'/activePublic',使用组件ac ...

  5. ogg BR – BOUNDED RECOVERY 测试案例

    首先,我们来看两个OGG同步中可能的问题: l oracle在线日志包含已提交的和未提交的事务,但OGG只会将已提交的事务写入到队列文件.因此,针对未提交的事务,特别是未提交的长事务,OGG会怎样处理 ...

  6. 禁止 gVim 在 Linux 下自动生成 undo 文件 *.un~

    在配置文件 .vimrc 中加入配置项, set noundofile 完.

  7. Luogu P3378 【模板】堆

    ((^ 0.0 ^)    )~ 堆是一个完全二叉树,对于小根堆,所有父节点<=子节点,下标就和线段树是一样的 在STL里就是优先队列 只有堆顶元素可以操作(询问或弹出). 加入新元素时x,he ...

  8. 修改spring源码重写classloader实现项目加密

      (一)操作方法和spring源码添加修改部分 事先说明:spring源码要下载好,会有修改spring的源码操作,本文和本作者所依赖的spring项目的版本是3.1.1,spring4及以上源码对 ...

  9. django 接受 ajax 传来的数组对象

    django 接受 ajax 传来的数组对象 发送:ajax 通过 POST 方式传来一个数组 接收:django 接受方式 array = request.POST.getlist(‘key[]’) ...

  10. 【C#复习总结】垃圾回收机制(GC)1

    摘要:今天我们漫谈C#中的垃圾回收机制,本文将从垃圾回收机制的原理讲起,希望对大家有所帮助. GC的前世与今生 虽然本文是以.NET作为目标来讲述GC,但是GC的概念并非才诞生不久.早在1958年,由 ...