How to mirror IP traffic to another system for monitoring

本文介绍如何在Red Hat Enterprise Linux 6中使用tc命令进行IP流量镜像,以便于网络监控。通过创建ingress qdisc,设置过滤器匹配所有IP包并将其复制到指定接口,实现虚拟机间流量的监测。

https://access.redhat.com/solutions/881163

 SOLUTION 已验证 - 已更新 2014年七月10日13:33 - 

English 

环境

  • Red Hat Enterprise Linux (RHEL) 6

问题

  • How do I mirror IP traffic for monitoring?

决议

To mirror traffic to another system for monitoring, there are quite a few approaches. Typically, this would be done with specialized hardware, specifically switches and routers with the option to mirror traffic. Red Hat Enterprise Linux (RHEL) 6.x has a way of doing this as well. Using the tccommand (part of the iproute-2 package), the traffic can be controlled and mirrored to another interface for monitoring.

In the code below, assume that the security appliance is attached to the bridge interface "vnet0", and the virtual machine (VM) to be monitored is attached to bridge interface "vnet1".

Raw

# tc qdisc add dev vnet1 ingress

This creates a new qdisc called ingress. This is really a special qdisc that you can consider an "alternate root" for inbound packets. vnet1 is the interface that is being monitored, or the traffic to be mirrored.

Raw

# tc filter add dev vnet1 parent ffff: \
  protocol ip u32 match u8 0 0 \
  action mirred egress mirror dev vnet0

Here, packets generated by the VM are copied. A new filter is added, attached to the node "ffff: " which is the fixed ID of the ingress qdisc (queue discipline). The filter only matches for IP packets ("protocol ip"). The part "u32 match u8 0 0" specifies a matching expression. In this case, the "u32" matcher, with arguments "u8 0 0". This means match any packet where the first byte, when ANDed with the value 0, returns 0. In other words, all packets are selected. When the filter matches, the action "mirred" is executed with arguments "egress mirror dev vnet0". This tells mirred to copy the packet to the device "vnet0".

Raw

# tc qdisc replace dev vnet1 parent root prio 

This replaces the qdisc that is directly attached to the root node with a new qdisc of type "prio". You may select another qdisc if you desire, but the reason why we replace it is to make sure that we attach a classfull qdisc. By default, the classless qdisc "pfifo_fast" is used, and being a classless qdisc, it doesn't evaluate filters.

Raw

# tc filter add dev vnet1 parent 8002: \
  protocol ip u32 match u32 0 0 \
  action mirred egress mirror dev vnet0

This line copies packets that are destined towards the virtual machine. The filter is attached to the egress side of the bridge interface, which is where normally all qdiscs operate. The filter is added to the qdisc with node ID 8002:. This may be different on your system. After step 3 you should check the ID that has been allocated with "tc qdisc show dev vnet1". The protocol, match and action parameters are identical to step 2.

根源

  • Need to mirror traffic for monitoring

诊断步骤

Verified in virtual environment with RHEL 6.5 machine with 2 VMs running.

  • Each vnetX interface matches up to a VM
  • VM2 was the machine to monitor traffic on
  • The host was the machine that mirror packets were sent to
  • Following the commands in the resolution, with adjustments for interface names, this was successfully configured

I was able to use Wireshark to watch eth0 in the host as I sent traffic from VM1 to VM2. The Wireshark capture was receiving packets on eth0 that were copied to it from vnet1. This verified that the packets sent from VM1 to VM2 were mirrored to eth0. Web traffic was also copied to eth0 when using VM2 to access the internet. This solution will mirror IP traffic to another interface.

基于径向基函数神经网络RBFNN的自适应滑模控制学习(Matlab代码实现)内容概要:本文介绍了基于径向基函数神经网络(RBFNN)的自适应滑模控制方法,并提供了相应的Matlab代码实现。该方法结合了RBF神经网络的非线性逼近能力和滑模控制的强鲁棒性,用于解决复杂系统的控制问题,尤其适用于存在不确定性和外部干扰的动态系统。文中详细阐述了控制算法的设计思路、RBFNN的结构与权重更新机制、滑模面的构建以及自适应律的推导过程,并通过Matlab仿真验证了所提方法的有效性和稳定性。此外,文档还列举了大量相关的科研方向和技术应用,涵盖智能优化算法、机器学习、电力系统、路径规划等多个领域,展示了该技术的广泛应用前景。; 适合人群:具备一定自动控制理论基础和Matlab编程能力的研究生、科研人员及工程技术人员,特别是从事智能控制、非线性系统控制及相关领域的研究人员; 使用场景及目标:①学习和掌握RBF神经网络与滑模控制相结合的自适应控制策略设计方法;②应用于电机控制、机器人轨迹跟踪、电力电子系统等存在模型不确定性或外界扰动的实际控制系统中,提升控制精度与鲁棒性; 阅读建议:建议读者结合提供的Matlab代码进行仿真实践,深入理解算法实现细节,同时可参考文中提及的相关技术方向拓展研究思路,注重理论分析与仿真验证相结合。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值