Home Database Mysql Tutorial debian下利用MySQL保存iptables日志

debian下利用MySQL保存iptables日志

Jun 07, 2016 pm 04:51 PM
debian mysql skills

本文介绍如何在 debian下,通过 ulogd 把 iptables 的日志保存到 MySQL 中。这样做的好处很多,最主要的好处莫过于以后的日志统计

本文介绍如何在 debian下,通过 ulogd 把 iptables 的日志保存到 MySQL 中。这样做的好处很多,最主要的好处莫过于以后的日志统计会非常的便利。

安装 ulogd 以及 ulogd-mysql

首先执行如下命令:

$ sudo apt-get install ulogd
$ sudo apt-get install ulogd-mysql

安装完毕后,下面开始配置 ulogd。

首先,需要把 ulogd 的数据库脚本导入到数据库中:

$ mysql
mysql> create database ulogd;
mysql> use ulogd;
mysql> source /usr/share/doc/ulogd-mysql/mysql.table

然后再修改 ulogd.conf 的配置文件:

$ sudo vi /etc/ulogd.conf

找到# output plugins.行的字样,大约在43行左右,找到plugin=”/usr/lib/ulogd/ulogd_LOGEMU.so”将其注释掉,并取消 plugin=”/usr/lib/ulogd/ulogd_MYSQL.so”行的注释,,表示输出到 MySQL 中。接下来再找到配置文件中 MySQL 配置字段,大约在 59 行左右:

[MYSQL]
table="ulog"
pass=""
user="root"
db="ulogd"
host="localhost"

修改为相应选项即可。修改完毕,启动 ulogd 服务。

$ sudo /etc/init.d/ulogd restart

如果没有遇到什么错误提示,就说明已经成功了。

Step 2:配置 iptables

设置你要记录的 iptables 规则,比如要记录 80 端口的包。

-A INPUT -p tcp -m tcp –dport 80 -j ULOG

不过要注意的是,ULOG 不对包进行过滤,匹配上这一条规则之后,数据依旧继续往下匹配。

这样就基本配置完毕了,当服务器上的 80 端口有数据的时候,报文的一些信息就会被记录到 MySQL 中,便于以后的查看与统计。 

linux

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to install Snap on Debian 12 How to install Snap on Debian 12 Mar 20, 2024 pm 08:51 PM

Snap is an external package manager designed for Linux systems that provides you with a convenient way to install containerized applications. Snap allows you to easily download and install packages without worrying about installing additional dependencies. The manager automatically resolves the dependencies required by the package, ensuring that the package runs smoothly on your system. Snap complements the native apt package manager, giving you another option for installing and running applications on your system. In this guide, you will find a complete guide on how to install Snap on Debian12. Outline: How to install Snap on Debian12 How to find package availability on Snap How to find information about packages on Snap

Debian installation of Wine and Debian installation of Wine tutorial Debian installation of Wine and Debian installation of Wine tutorial Feb 12, 2024 am 10:36 AM

Wine is a compatibility layer that can run Windows applications on Linux systems. It allows users to seamlessly run Windows applications on Linux systems without the need for dual-system installation or virtual machine setup. This article will introduce how to run Windows applications on Debian systems. Install Wine and provide some related tutorials. Installing Wine Installing Wine on a Debian system is very simple, just use the apt command, open a terminal, and enter the following command: ```shellsudoapt-getupdatesudoapt-getinstallwine```This will update your package list and install Wine , after the installation is complete, you can

A complete guide to installing Debian and deb files under Windows A complete guide to installing Debian and deb files under Windows Feb 14, 2024 pm 11:03 PM

Installing Debian in Windows systems and installing deb files directly in Windows are ways for many Linux enthusiasts to explore dual systems or try new software. This article will detail the steps and precautions for these two installation methods. Installing Debian under Windows To install Debian in a Windows system, you usually need to use virtual machine software, such as VirtualBox. The following are the specific steps: 1. Download and install VirtualBox, which is a free virtualization software that can run on the same computer. Multiple operating systems. 2. Download the Debian ISO image file. You can find the download link on the Debian official website. 3. in

How to install Steam on Debian 12 How to install Steam on Debian 12 Mar 21, 2024 pm 10:10 PM

STEAM is a popular gaming platform developed by Valve Corporation that allows you to buy, download, install and play games. It provides features such as automatic updates, matchmaking, and a community forum to resolve software-related issues. In addition to this, you can also use Steam to interact with other players and developers as it has extensive community support. In this guide you will learn: How to install Steam on Debian12 How to run Steam on Debian12 How to remove Steam from Debian12 Conclusion How to install Steam on Debian12 You can install Steam on Debian12: Debian Official Repository deb packages

How to add desktop shortcut icon on Debian11 How to add desktop shortcut icon on Debian11 Jan 09, 2024 am 10:06 AM

How to create application shortcuts on the desktop in Debian11? Windows system installation programs generally create application shortcuts on the desktop. How to create them in Debian11? Let’s take a look at the detailed tutorial below. Right-click on a blank space on the desktop and select [Create Launcher]. In the pop-up interface, set the program to create a shortcut in [Command]. The editor takes the terminal emulator as an example. The user can set the icon by himself. After the setting is completed, click [Create]. Then you can see the shortcut, as shown in the picture below. When the shortcut is no longer needed, right-click on the icon and select [Delete].

Detailed guide to installing GCC and GCC10 on Debian Detailed guide to installing GCC and GCC10 on Debian Feb 10, 2024 pm 03:57 PM

Debian is a popular Linux distribution, widely used in servers and desktop systems. GCC (GNUCompilerCollection) is an open source compiler suite used to compile C, C++, Fortran and other programming languages. In the Debian system, Installing GCC and GCC10 is very simple. This article will provide you with a detailed installation guide. Install GCC1. Open Terminal and use the following command to update the package list: ```shellsudoaptupdate``` 2. Install GCC and its related tools: sudoaptinstallbuild-essential This command will install

How to log out or shut down the system in Debian 11 How to log out or shut down the system in Debian 11 Dec 27, 2023 pm 02:22 PM

How to shut down the system in Debian11? Let’s take a look at the specific operations with the editor. Method 1: Click [All Apps] - [Log Out]. In the pop-up interface, click [Shut Down]. Method 2: Execute the following command in the terminal: sudoshutdown-hnow

How to build Nginx and Tomcat servers under Debian to achieve load balancing How to build Nginx and Tomcat servers under Debian to achieve load balancing May 19, 2023 pm 10:31 PM

The basic concept of load balancing Load balancing (loadbalancing) is a computer network technology used to distribute load among multiple computers (computer clusters), network connections, CPUs, disk drives or other resources to achieve optimal resource usage. The purpose is to maximize throughput, minimize response time, and avoid overload. Using multiple server components with load balancing instead of a single component can improve reliability through redundancy. Load balancing services are usually performed by specialized software and hardware. One of the most important applications of load balancing is the use of multiple servers to provide a single service. This solution is sometimes called a server farm. Usually, load balancing is mainly used in web websites, large-scale Internet

See all articles