1.将交换机流量镜像到Hyper-V宿主的一块网卡(eth4)

2.在Hyper-V宿主上新建虚拟交换机(Network_Mirror),选择外部网络,扩展属性中启用“Microsoft NDIS捕获”,设置如下图所示:

 

3.在已创建好的虚机上,选择使用“Network_Mirror”虚拟交换机,然后在高级功能中,镜像模式选择“目标”,即该虚机用来接收镜像流量

4.选择流量来源,在Hyper-V宿主上运行PowerShell命令:

$VMSwitchPortFeature = Get-VMSystemSwitchExtensionPortFeature -FeatureName 'Ethernet Switch Port Security Settings' #选择扩展功能 - 交换机端口安全设置“类”
$VMSwitchPortFeature.SettingData.MonitorMode = 2 #MonitorMode参数说明(0 = 无, 1 = 目标, 2 = 来源)
Add-VMSwitchExtensionPortFeature -ExternalPort -SwitchName 'Network_Mirror' -VMSwitchExtensionFeature $VMSwitchPortFeature #将该功能加入到该虚拟交换机

注:All traffic hitting the hyper-v Host is also hitting the external port of the virtual switch. However for the NIC on the VM to get these packets, we need to now “mirror” this Switch port (on the Virtual switch) to let him know that he has to forward the packets onto the “DESTINATION” we had configured earlier.

5.在虚机(CentOS)上运行命令监控镜像流量:

tcpdump -i eth1 -w /tmp/a.txt

运行tail -f tmp/a.txt 可以看到捕获到的镜像流量

附:

参考:

https://blogs.technet.microsoft.com/networking/2015/10/16/setting-up-port-mirroring-to-capture-mirrored-traffic-on-a-hyper-v-virtual-machine/

https://dotblogs.com.tw/terrychuang/2015/01/19/148176

最新文章

  1. C#开发微信门户及应用(5)--用户分组信息管理
  2. 消除左递归c语言文法
  3. 前端模块化工具-webpack
  4. MJRefresh自定义刷新动画
  5. 获取当前 Windows 的安装序列号
  6. dp和px的转换
  7. 使用jquery.validate.js实现boostrap3的校验和验证
  8. java学习面向对象之多态
  9. [Unity-7] Update和FixedUpdate
  10. Piggy Back_KEY
  11. 阿里云服务器php环境的搭建
  12. Java 中的内部类
  13. linux 清理缓存buff/cache
  14. error_log
  15. linux忘记root密码
  16. Linux inode空间占满 “no space left on device”
  17. BZOJ4184:shallot(线段树分治,线性基)
  18. Git 生命周期
  19. <OFFER05> 05_ReplaceSpaces
  20. python定位性能的工具

热门文章

  1. kubelet集群网络配置flannel(覆盖网络)
  2. Java中char和String 的深入理解 - 字符编码
  3. greenev —— Python 异步网络服务框架
  4. MySQL高可用之组复制(1):组复制技术简介
  5. shell编程基础(七): 处理文件命令sed与awk
  6. for 循环 和 Array 数组对象
  7. 第一册:lesson nineteen。
  8. 从零开始学安全(十三)●SQL server 2008 R2 安装
  9. Java学习笔记之——自动装箱与拆箱
  10. Java基础篇——集合浅谈