MikroTik NAT日志记录–MySQL版

本程序实现的功能:

  1. 可记录源MAC,源IP,目的IP,协议,源端口,目的端口,进入接口,出去接口,数据包大小。
  2. 可自定义保存到数据库,只需要nat表字段保持一致即可。

添加防火墙规则:

/ip firewall filter add action=log chain=forward
#红色IP地址改为运行本程序的电脑地址
/system logging action add name=SyslogServer remote=192.168.11.100 target=remote
/system logging add action=SyslogServer topics=firewall,info

注:运行该程序的电脑或服务器必须开放UDP 514端口否则会接收不到数据

MySQL表结构(表名不可更改):

-- auto-generated definition
create table nat
(
id int(255) auto_increment
primary key,
date datetime default '0000-00-00 00:00:00' not null,
mac varchar(17) null
comment 'mac地址',
srcip varchar(15) null
comment '源IP',
srcprot varchar(5) null
comment '源端口',
dstip varchar(15) null
comment '目的IP',
dstprot varchar(5) null
comment '目的端口',
int_in varchar(255) null
comment '进入接口',
int_out varchar(255) null
comment '出接口',
proto varchar(255) null
comment '协议',
datalen varchar(5) null
comment '数据包大小'
);

程序下载:MikroTik_log_MySQL_V2.exe
SQL文件下载:mikrotiklog.sql.zip
MD5:37391fb6a0393902e5eae5fd5d962bc8

2019年12月17日更新时间字段
程序下载:MikroTik_log_MySQL_V3.exe
MD5:4b9b918a0892c0ef884de50a51c361d2
SQL文件下载:mikrotiklog_3.sql

发表回复