Change the IPTables log file
http://www.networkinghowtos.com/howto/change-the-iptables-log-file/
An important aspect of any firewall are the log files. Iptables on Linux provides logging functionality, however by default, it will get outputted to the /var/log/messages log file. This can clutter things up, and make it hard to check the logs.
If you want to change the file that IPTables logs to, you need to set up your iptables rules to output a log prefix. Rsyslog will then be configured to pick up this prefix, and output the information to a custom log file, containing just the iptables log information.
Install rsyslog if it is not already installed.
$ sudo apt-get install -y rsyslog
Configure your iptables firewall rules to output a log prefix using the –log-prefix command:
$ sudo iptables -A INPUT -p tcp --dport 22 --syn -j LOG --log-prefix "iptables: "
(this will log connection attempts to the SSH port)
Next you need to configure rsyslog to pickup the iptables log prefix.
Create an empty rsyslog conf file for iptables.
$ sudo touch /etc/rsyslog.d/10-iptables.conf
Open this file up in a file editor.
$ sudo nano /etc/rsyslog.d/10-iptables.conf
Add the following two lines:
:msg, contains, "iptables: " -/var/log/iptables.log
& ~
Save the file and exit the editor.
The first line checks the log data for the word “iptables: ” and appends it into the /var/log/iptables.log file.
The second line simply halts the processing of the log information, so that it doesnt get logged into /var/log/messages as well as the iptables.log file.
Restart rsyslog:
$ sudo service rsyslog restart
The logs should now be appearing in /var/log/iptables.log
You can verify this by tailing the log file:
$ tail -f /var/log/iptables.log
Try and connect to SSH from another machine, and you should see a log entry get created, and appear on the screen automatically.
Eg:
$ tail -f /var/log/iptables.log
Feb 20 23:27:11 ubuntu kernel: [1988916.899165] iptables: IN=eth0 OUT= MAC=00:00:00:00:00:00:00:
00:00:00:00:00:00:00 SRC=192.168.0.3 DST=192.168.0.1 LEN=60 TOS=0x10 PREC=0x00 TTL=64 ID=30541
DF PROTO=TCP SPT=60148 DPT=22 WINDOW=5840 RES=0x00 SYN URGP=0
Close the ‘tail’ program using Ctrl+c.
Change the IPTables log file的更多相关文章
- ORACLE等待事件: log file parallel write
log file parallel write概念介绍 log file parallel write 事件是LGWR进程专属的等待事件,发生在LGWR将日志缓冲区(log_buffer)中的重做日志 ...
- Managing IIS Log File Storage
Managing IIS Log File Storage You can manage the amount of server disk space that Internet Informa ...
- bdb log file 预设长度的性能优化
看代码随手记:log_put.c, __log_write() /* * If we're writing the first block in a log file on a filesystem ...
- mysql从库Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'报错处理
年后回来查看mysql运行状况与备份情况,登录mysql从库查看主从同步状态 mysql> show slave status\G; *************************** . ...
- 完全揭秘log file sync等待事件-转自itpub
原贴地址:http://www.itpub.net/thread-1777234-1-1.html 谢谢 guoyJoe 老大 这里先引用一下tanel poder大师的图: 什么是log fil ...
- 'Could not find first log file name in binary log index file'的解决办法
数据库主从出错: Slave_IO_Running: No 一方面原因是因为网络通信的问题也有可能是日志读取错误的问题.以下是日志出错问题的解决方案: Last_IO_Error: Got fatal ...
- Oracle 联机重做日志文件(ONLINE LOG FILE)
--========================================= -- Oracle 联机重做日志文件(ONLINE LOG FILE) --================== ...
- Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'
setup slave from backup i got error Got fatal error 1236 from master when reading data from binary l ...
- oracle之 等待事件LOG FILE SYNC (awr)优化
log file sycn是ORACLE里最普遍的等待事件之一,一般log file sycn的等待时间都非常短 1-5ms,不会有什么问题,但是一旦出问题,往往都比较难解决.什么时候会产生log f ...
随机推荐
- .net 使用com组件操作word遇到的一些问题
1.警告: 方法“Microsoft.Office.Interop.Word._Document.Close(ref object, ref object, ref object)”和非方法“Micr ...
- C 计算身高
#include <stdio.h> int main(int argc, char **argv) { //输出一句话printf("请分别输入身高的英尺和英寸," ...
- 关于javascript的一个小问题,请问有人看出啥问题吗?
最近学习javascript,有一个问题挺奇怪的,先贴出代码: function binarySearch(){ var arr = [0,1,2,3]; var res = actbinarySea ...
- C语言struct中的长度可变数组(Flexible array member)
C_struct中的长度可变数组(Flexible array member) Flexible array member is a feature introduced in the C99 sta ...
- Java简单工厂模式
Java简单工厂模式 在阎宏博士的<JAVA与模式>一书中开头是这样描述简单工厂模式的:简单工厂模式是类的创建模式,又叫做静态工厂方法(Static Factory Method)模式.简 ...
- POJ 3525/UVA 1396 Most Distant Point from the Sea(二分+半平面交)
Description The main land of Japan called Honshu is an island surrounded by the sea. In such an isla ...
- Python中的slice操作
Python中slice操作的完整语法: # i默认是0 # j默认是len(S) # k的步长,默认为+1 S[i:j:k] 其中i,j,k都可以是负数: 若i < 0或者k<0,等价于 ...
- tabales1.10版参数详解
//@translator codepiano //@blog codepiano //@email codepiano.li@gmail.com //尝试着翻译了一下,难免有错误的地方,欢迎发邮件告 ...
- 内存转储文件调试系统崩溃bug
百度百科:内存转储文件 内存转储是用于系统崩溃时,将内存中的数据转储保存在转储文件中,供给有关人员进行排错分析用途.而它所保存生成的文件就叫做内存转储文件. 内存转储文件也被称作虚拟内存,它是用硬盘里 ...
- lintcode-178-图是否是树
178-图是否是树 给出 n 个节点,标号分别从 0 到 n - 1 并且给出一个 无向 边的列表 (给出每条边的两个顶点), 写一个函数去判断这张`无向`图是否是一棵树 注意事项 你可以假设我们不会 ...