关于linux日志中存在大量martian source 日志信息的原因分析与理解

2023-10-14 06:40

本文主要是介绍关于linux日志中存在大量martian source 日志信息的原因分析与理解,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

在查看日常维护的一台Linux服务器的系统日志时,发现有大量的类似如下的信息:

 

Jan 17 00:33:34 test4 kernel: [ 2170.725322] martian source 192.168.10.255 from 192.168.10.10, on dev br1
Jan 17 00:33:34 test4 kernel: [ 2170.725328] ll header: ff:ff:ff:ff:ff:ff:00:0c:29:6f:cc:1f:08:00

在网上找到对于这类日志的英文解释

================================================================


A martian data packet is a network data packet that has an impossible source or destination IP, such as a packet that claims to have come from the broadcast address, 255.255.255.255. Another example of a martian packet would be if you received a packet from 192.168.0.1 through your networks external gateway.

IPs in the range of 192.168.* are not routable through gateways, so this situation should never happen. Usually martians are just the result of network misconfigurations or glitches of some sort, but they can be caused by deliberate mangling of the IP packet, such as when trying to hide the real origin of the packets during an attack against a server. If you see just a few martian packet messages then there probably isn't anything to worry about, but if you see lots of them then take a closer look.

Recent kernels print out the link level header of the packet along with the martian warning, and the header contains the destination and source MAC addresses. In the example below the destination MAC (for the server "aries") is 00:01:80:23:96:54, and the source MAC (the sender of the martian) is 00:e0:52:14:4d:9d. The "08:00″ at the end just indicates that this header is from an ipv4 over ethernet packet.

Apr 29 09:33:54 aries kernel: martian source 207.44.228.62 from 80.3.32.5, on dev eth0
Apr 29 09:33:42 aries kernel: ll header: 00:01:80:23:96:54:00:e0:52:14:4d:9d:08:00

If you do see lots of martians being logged, or have some other reason to suspect that the server is being attacked, a good place to look is in the Apache error log file. You may be able to find log entries for the martian IP addresses that record attack attempts.

For example, here is an error_log entry recording an attack attempt against the same server that logged the martian shown above.

[Mon Apr 28 20:26:18 2003] [error] [client 80.3.32.5] request failed: erroneouscharacters after protocol string: GET /images/Smilies%20gold%2018×18/shocked.gif(.x81cxf3×8axffxffxfdb4xd6a2×1171x94xd7xffxfbx92lxffx8dxe2×05x18Gvx8caP;"xxe1qx8cx1ax078Kx1cx0exb1×87

So don't worry too much about the martians, but be on guard lest they actually invade.

===============================================================

所谓martian source也就是impossible source,也就是linux根据路由表判断,认为不合理的,不应该出现的源地址。

常见的情况是源地址是诸如广播255.255.255.255或192.168.1.255之类的网络地址 或者不符合路由表规则的源地址(比如,我的机器配置两个网卡,eth0、eth1分别配置192.168.10.xxx和192.168.20.xxx 两个网段的IP,按理说,来自10网段的报文应该由eth0收到(因为eth0直连10网段),而来自20网段的报文则应由eth1收到(因为eth1直连20网段),而此时如果收到一个IP包,它的源地址是10网段的IP,但是却是从与20网段直连的eth1接收到的,那么linux就会认为这个包是个伪造包,也就是IP欺骗,从而产生martian source的日志信息)

我的情况就属于后者。

我的机器总共两张网卡,创建了两个网桥,两张网卡分别添加到这两个网桥,虚拟接口br0的 ip 为192.168.10.12,具体配置如下:

test4:~/Desktop # ifconfig
br0       Link encap:Ethernet  HWaddr 00:0C:29:83:22:AF 
          inet addr:192.168.10.12  Bcast:192.168.10.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe83:22af/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4696 errors:0 dropped:0 overruns:0 frame:0
          TX packets:53 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:562231 (549.0 Kb)  TX bytes:4850 (4.7 Kb)

br1       Link encap:Ethernet  HWaddr 00:0C:29:83:22:B9 
          inet6 addr: fe80::20c:29ff:fe83:22b9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4649 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:558320 (545.2 Kb)  TX bytes:468 (468.0 b)

eth0      Link encap:Ethernet  HWaddr 00:0C:29:83:22:AF 
          inet6 addr: fe80::20c:29ff:fe83:22af/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4901 errors:0 dropped:0 overruns:0 frame:0
          TX packets:53 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:654229 (638.8 Kb)  TX bytes:4850 (4.7 Kb)

eth1      Link encap:Ethernet  HWaddr 00:0C:29:83:22:B9 
          inet6 addr: fe80::20c:29ff:fe83:22b9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4945 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:658360 (642.9 Kb)  TX bytes:468 (468.0 b)

 

 test4:~/Desktop # brctl show
bridge name bridge id  STP enabled interfaces
br0  8000.000c298322af no  eth0
br1  8000.000c298322b9 no  eth1

在没有配置网桥之前,我在10网段的另外一台机器ping整个10网段

ping -b 192.168.10.255

结果在我的机器(test4)上,/var/log/messages并未出现martian source的相关信息

然后分别创建br0、br1两个网桥,并分别添加eth0、eth1两个物理网卡,然后再去ping整个10网段,结果出现martian source日志信息

这说明与网桥配置有关

然后尝试shutdown 掉br1,martian source日志随之消失,说明与双网桥配置有关。

为什么双网桥会出现这个问题呢?

网桥其实就相当于一个虚拟的交换机,把物理网卡添加到网桥中相当于将其转换成为这个虚拟交换机的二层接口,这将使其失去三层的功能,也就是你不能再在它上面配IP了;但是可以给网桥创建虚拟的三层接口并配上IP,类似于交换机上vlan接口,上面的br0就是这样的虚拟的三层接口。

Linux 的网桥模型(根据自身理解画的)

 

如上所示,当我从外部网络的另一台10网段的主机(192.168.10.10)ping整个10网段时

ping -b 192.168.10.255

将发送源地址为192.168.10.10, 目标IP为192.168.10.255的icmp请求报文。

因为这是一个广播报文,其目标MAC地址为ff : ff : ff : ff : ff : ff

所以该报文将会在外部的物理交换机以及内部两个虚拟交换机br0、br1所有端口转发,

最终,两个虚拟接口br0、br1都会收的该报文。

正如上面讨论的一样,br0配的是10网段的IP,所以收到来自10网段的报文,系统是认为正常的

但br1配的是20网段的IP所以,所以收的源地址为10网段的IP,系统会认为是非法的(根据路由表确定来自10网段报文只应该在br0这个接口收到),从而产生martian source的日志报错信息。

 

解决办法:

1.shutdown 其中一个网桥接口

ifconfig br1 down

2.系统配置中取消源路由验证和防IP欺骗

在/etc/sysctl.conf文件中加入下面的配置:

#取消源路由验证#
 net.ipv4.conf.default.rp_filter = 0

# 关掉IP spoofing protection#

net.ipv4.conf.br0.arp_filter = 0

net.ipv4.conf.br1.arp_filter = 0

net.ipv4.conf.all.arp_filter = 0

#在接口上停止记录martian source日志#

net.ipv4.conf.default.log_martians=0

net.ipv4.conf.lo.log_martians=0

net.ipv4.conf.eth0.log_martians=0

net.ipv4.conf.eth1.log_martians=0

net.ipv4.conf.eth2.log_martians=0

net.ipv4.conf.eth3.log_martians=0

net.ipv4.conf.br0.log_martians=0

net.ipv4.conf.br1.log_martians=0

net.ipv4.conf.all.log_martians=0

然后使用sysctl -p 或 重启使设置生效

当然也可以直接修改当前的系统参数,使设置即刻生效

echo 0 >/proc/sys/net/ipv4/conf/eth0/log_martians
echo 0 >/proc/sys/net/ipv4/conf/br1/log_martians
echo 0 >/proc/sys/net/ipv4/conf/br2/log_martians
echo 0 >/proc/sys/net/ipv4/conf/br3/log_martians
echo 0 >/proc/sys/net/ipv4/conf/all/log_martians

这将停止martian日志写到/var/log/messages中

 

 

 

 

这篇关于关于linux日志中存在大量martian source 日志信息的原因分析与理解的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/208816

相关文章

流媒体平台/视频监控/安防视频汇聚EasyCVR播放暂停后视频画面黑屏是什么原因?

视频智能分析/视频监控/安防监控综合管理系统EasyCVR视频汇聚融合平台,是TSINGSEE青犀视频垂直深耕音视频流媒体技术、AI智能技术领域的杰出成果。该平台以其强大的视频处理、汇聚与融合能力,在构建全栈视频监控系统中展现出了独特的优势。视频监控管理系统EasyCVR平台内置了强大的视频解码、转码、压缩等技术,能够处理多种视频流格式,并以多种格式(RTMP、RTSP、HTTP-FLV、WebS

linux-基础知识3

打包和压缩 zip 安装zip软件包 yum -y install zip unzip 压缩打包命令: zip -q -r -d -u 压缩包文件名 目录和文件名列表 -q:不显示命令执行过程-r:递归处理,打包各级子目录和文件-u:把文件增加/替换到压缩包中-d:从压缩包中删除指定的文件 解压:unzip 压缩包名 打包文件 把压缩包从服务器下载到本地 把压缩包上传到服务器(zip

认识、理解、分类——acm之搜索

普通搜索方法有两种:1、广度优先搜索;2、深度优先搜索; 更多搜索方法: 3、双向广度优先搜索; 4、启发式搜索(包括A*算法等); 搜索通常会用到的知识点:状态压缩(位压缩,利用hash思想压缩)。

性能分析之MySQL索引实战案例

文章目录 一、前言二、准备三、MySQL索引优化四、MySQL 索引知识回顾五、总结 一、前言 在上一讲性能工具之 JProfiler 简单登录案例分析实战中已经发现SQL没有建立索引问题,本文将一起从代码层去分析为什么没有建立索引? 开源ERP项目地址:https://gitee.com/jishenghua/JSH_ERP 二、准备 打开IDEA找到登录请求资源路径位置

Linux 网络编程 --- 应用层

一、自定义协议和序列化反序列化 代码: 序列化反序列化实现网络版本计算器 二、HTTP协议 1、谈两个简单的预备知识 https://www.baidu.com/ --- 域名 --- 域名解析 --- IP地址 http的端口号为80端口,https的端口号为443 url为统一资源定位符。CSDNhttps://mp.csdn.net/mp_blog/creation/editor

【Python编程】Linux创建虚拟环境并配置与notebook相连接

1.创建 使用 venv 创建虚拟环境。例如,在当前目录下创建一个名为 myenv 的虚拟环境: python3 -m venv myenv 2.激活 激活虚拟环境使其成为当前终端会话的活动环境。运行: source myenv/bin/activate 3.与notebook连接 在虚拟环境中,使用 pip 安装 Jupyter 和 ipykernel: pip instal

【测试】输入正确用户名和密码,点击登录没有响应的可能性原因

目录 一、前端问题 1. 界面交互问题 2. 输入数据校验问题 二、网络问题 1. 网络连接中断 2. 代理设置问题 三、后端问题 1. 服务器故障 2. 数据库问题 3. 权限问题: 四、其他问题 1. 缓存问题 2. 第三方服务问题 3. 配置问题 一、前端问题 1. 界面交互问题 登录按钮的点击事件未正确绑定,导致点击后无法触发登录操作。 页面可能存在

业务中14个需要进行A/B测试的时刻[信息图]

在本指南中,我们将全面了解有关 A/B测试 的所有内容。 我们将介绍不同类型的A/B测试,如何有效地规划和启动测试,如何评估测试是否成功,您应该关注哪些指标,多年来我们发现的常见错误等等。 什么是A/B测试? A/B测试(有时称为“分割测试”)是一种实验类型,其中您创建两种或多种内容变体——如登录页面、电子邮件或广告——并将它们显示给不同的受众群体,以查看哪一种效果最好。 本质上,A/B测

【生成模型系列(初级)】嵌入(Embedding)方程——自然语言处理的数学灵魂【通俗理解】

【通俗理解】嵌入(Embedding)方程——自然语言处理的数学灵魂 关键词提炼 #嵌入方程 #自然语言处理 #词向量 #机器学习 #神经网络 #向量空间模型 #Siri #Google翻译 #AlexNet 第一节:嵌入方程的类比与核心概念【尽可能通俗】 嵌入方程可以被看作是自然语言处理中的“翻译机”,它将文本中的单词或短语转换成计算机能够理解的数学形式,即向量。 正如翻译机将一种语言