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

2023-05-16

在查看日常维护的一台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中

 

 

 

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

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

  • 为什么我收到的数据包数据大小大于mss?

    我在两台 PC 上使用 ifconfig ethX mtu 300 修改了 MTU 并使用 netperf 测试网络 我用 WireShark 嗅探了 SYN 数据包中的 MSS 260 但我得到了一些大于 260 的数据包 为什么 嗅探器
  • 在 Mac OS X 上构建 Linux 内核

    我正在做一个修改Linux内核的项目 我有一台桌面 Linux 机器 在上面构建内核没有问题 不过 我要去旅行 我想在途中工作 我只有一台 MacBook 当我尝试构建 Linux 内核时 它抱怨说elf h was not found 我
  • 如何修复“iptables:没有该名称的链/目标/匹配”?

    我在我的 Linux 嵌入式系统上构建并安装了 iptables 如果我列出所有规则 则一切正常 iptables list Chain INPUT policy ACCEPT target prot opt source destinat
  • 从 PL/SQL 调用 shell 脚本,但 shell 以 grid 用户而非 oracle 身份执行

    我正在尝试使用 Runtime getRuntime exec 从 Oracle 数据库内部执行 shell 脚本 在 Red Hat 5 5 上运行的 Oracle 11 2 0 4 EE CREATE OR REPLACE proced
  • Elasticsearch 无法写入日志文件

    我想激活 elasticsearch 的日志 当我运行 elasticsearch 二进制文件时 我意识到我在日志记录方面遇到问题 无法加载配置 这是输出 sudo usr share elasticsearch bin elasticse
  • awk 子串单个字符

    这是columns txt aaa bbb 3 ccc ddd 2 eee fff 1 3 3 g 3 hhh i jjj 3 kkk ll 3 mm nn oo 3 我可以找到第二列以 b 开头的行 awk if substr 2 1 1
  • 强制卸载 NFS 安装目录 [关闭]

    Closed 这个问题不符合堆栈溢出指南 help closed questions 目前不接受答案 Locked 这个问题及其答案是locked help locked posts因为这个问题是题外话 但却具有历史意义 目前不接受新的答案
  • 抑制 makefile 中命令调用的回显?

    我为一个作业编写了一个程序 该程序应该将其输出打印到标准输出 分配规范需要创建一个 Makefile 当调用它时make run gt outputFile应该运行该程序并将输出写入一个文件 该文件的 SHA1 指纹与规范中给出的指纹相同
  • 应用程序无缘无故地被杀死。怀疑 BSS 高。如何调试呢?

    我已经在CentOs6 6中成功运行我的应用程序 最近 硬件 主板和内存 更新了 我的应用程序现在毫无理由地被杀死 root localhost PktBlaster PktBlaster Killed 文件和 ldd 输出 root lo
  • Jenkins中找不到环境变量

    我想在詹金斯中设置很多变量 我试过把它们放进去 bashrc bash profile and profile of the jenkins用户 但 Jenkins 在构建发生时找不到它们 唯一有效的方法是将所有环境变量放入Jenkinsf
  • 为什么 Linux perf 使用事件 l1d.replacement 来处理 x86 上的“L1 dcache misses”?

    在英特尔 x86 上 Linux用途 https stackoverflow com a 52172985 149138事件l1d replacements来实施其L1 dcache load misses event 该事件定义如下 计数
  • sendfile64 只复制约2GB

    我需要使用 sendfile64 复制大约 16GB 的文件 到目前为止我所取得的成就是 include
  • fopen 不返回

    我在 C 程序中使用 fopen 以只读模式 r 打开文件 但就我而言 我观察到 fopen 调用没有返回 它不返回 NULL 或有效指针 执行在 fopen 调用时被阻止 文件补丁绝对正确 我已经验证过 并且不存在与权限相关的问题 任何人
  • 域套接字“sendto”遇到“errno 111,连接被拒绝”

    我正在使用域套接字从另一个进程获取值 就像 A 从 B 获取值一样 它可以运行几个月 但最近 A 向 B 发送消息时偶尔会失败 出现 errno 111 连接被拒绝 我检查了B域套接字绑定文件 它是存在的 我也在另一台机器上做了一些测试 效
  • 如何在数组中存储包含双引号的命令参数?

    我有一个 Bash 脚本 它生成 存储和修改数组中的值 这些值稍后用作命令的参数 对于 MCVE 我想到了任意命令bash c echo 0 0 echo 1 1 这解释了我的问题 我将用两个参数调用我的命令 option1 without
  • linux perf:如何解释和查找热点

    我尝试了linux perf https perf wiki kernel org index php Main Page今天很实用 但在解释其结果时遇到了困难 我习惯了 valgrind 的 callgrind 这当然是与基于采样的 pe
  • nslookup 报告“无法解析 '(null)': 名称无法解析”,尽管它成功解析了 DNS 名称

    我在 ubuntu 上 并且正在运行 docker 默认桥接网络 我有 Zookeeper kafka 的容器化版本 以及我编写的与 kafka 对话的应用程序 I do a docker exec it
  • os.Mkdir 和 os.MkdirAll 权限

    我正在尝试在程序开始时创建一个日志文件 我需要检查是否 log如果不创建目录 则目录存在 然后继续创建日志文件 好吧 我尝试使用os Mkdir 也os MkdirAll 但无论我在第二个参数中输入什么值 我都会得到一个没有权限的锁定文件夹
  • Linux 可执行文件与 OS X“兼容”吗?

    如果您在基于 Linux 的平台上用 C 语言编译一个程序 然后将其移植以使用 MacOS 库 它会工作吗 来自编译器的核心机器代码在 Mac 和 Linux 上兼容吗 我问这个问题的原因是因为两者都是 基于 UNIX 的 所以我认为这是真
  • 安装J语言的JQt IDE,出现错误

    我一直按照这里的说明进行操作 http code jsoftware com wiki System Installation Linux http code jsoftware com wiki System Installation L

随机推荐