Ulog會直接寫入資料庫
iptables log analyzer會先寫入syslog再寫入資料庫
apt-get install ulogd ulogd-mysql //安裝
你可以安裝 mysql 或 mariaDB
在Ubuntu 12.04上安裝mariaDB 10.0"瑪莉亞資料庫"
mysql -u root -p //進入資料庫
create database iptablelog; //建立iptablelog資料庫
//下載iptablelog-v0.9
wget http://ftp.jaist.ac.jp/pub/sourceforge/i/project/ip/iptablelog/iptablelog/v0.9/iptablelog-v0.9.tar.gz
tar zxvf iptablelog-v0.9.tar.gz -C /var/www/
cd /var/www/iptablelog/conf/ //切換到資料表的目錄
mysql -u root -p iptablelog < iptables.mysql //匯入資料表
原本的資料表不能匯入 , 所以修改
DROP TABLE IF EXISTS host_cache;
CREATE TABLE host_cache (
ip int(10) unsigned NOT NULL default '0',
host varchar(255) NOT NULL default '',
resolved timestamp(14) NOT NULL, //(14)取消
static enum('Y','N') NOT NULL default 'N',
PRIMARY KEY (ip)
) TYPE=MyISAM; //整個資料表的關鍵字TYPE修改為ENGINE
vi /etc/ulogd.conf //編輯ulogd.conf
plugin="/usr/lib/ulogd/ulogd_BASE.so"
plugin="/usr/lib/ulogd/ulogd_LOCAL.so" //追加這一行
# output plugins.
#plugin="/usr/lib/ulogd/ulogd_LOGEMU.so" //加上#
plugin="/usr/lib/ulogd/ulogd_MYSQL.so" //消去#
[MYSQL]
table="ulog"
pass="****"
user="root"
db="iptablelog"
host="localhost"
iptables -A INPUT -p tcp --dport 80 -j ULOG --ulog-nlgroup 1 --ulog-prefix "[IPTABLES FRACMENT]"
設定iptables規則
觀看 tcp 80 port 連線記錄iptables -A INPUT -p tcp --dport 80 -j ULOG --ulog-nlgroup 1 --ulog-prefix "[IPTABLES FRACMENT]"
//IPTABLES//規則關鍵字
iptables -A INPUT -j ULOG --ulog-nlgroup 1 --ulog-prefix "[IPTABLES FRACMENT]"
//設這樣, 資料會很雜亂
/etc/init.d/ulogd restart //啟動
//要確認ulog資料表是不是有資料一直寫入
//要確認ulog資料表是不是有資料一直寫入
//web介面的部分
cp /var/www/iptablelog/conf/config.php.default config.php //複製一份出來
vi config //編輯
# Host of the MySQL database
cp /var/www/iptablelog/conf/config.php.default config.php //複製一份出來
vi config //編輯
# Host of the MySQL database
$db_host="localhost";
# User of the MySQL database
$db_user="root";
# Password of the MySQL database
$db_password="****";
# Name of the database
$db_name="iptablelog";
# URL Path to your installation
$url_base="/iptablelog";
# File Path to your installation
$file_base="/var/www/iptablelog"; # i.e. "/var/www/html/iptablelog"
//修改紅字的部分
http://X.X.X.X/iptablelog
http://X.X.X.X/iptablelog
可安裝phpmyadmin檢視資料表
apt-get install apache2 php5 phpmyadmin
沒有留言:
張貼留言