我是靠谱客的博主 温暖红酒,最近开发中收集的这篇文章主要介绍wireshark抓取本地程序之间的封包Loopback capture setup,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

from: http://www.cnweblog.com/fly2700/archive/2008/06/23/289245.html

Windows下传统的抓包工具如Wireshark/Ethereal不能对本地程序之间的网络通信抓包,如果即想要对本地通信进行抓包可如下设置。

http://wiki.wireshark.org/CaptureSetup/Loopback详细介绍了如何操作但比较麻烦,其实只要最后一步就可以实现了:

在命令行提示下面输入: route add 192.168.10.10 mask 255.255.255.255 192.168.10.1 metric 1 就这么简单!其中192.168.10.10是自己的IP,192.168.10.1是自己的网关

Loopback capture setup

The following will explain capturing on loopback interfaces a bit.

If you are trying to capture traffic from a machine to itself, that traffic will not be sent over a real network interface, even if it's being sent to an address on one of the machine's network adapters. This means that you will not see it if you are trying to capture on, for example, the interface device for the adapter to which the destination address is assigned. You will only see it if you capture on the "loopback interface", if there is such an interface and it is possible to capture on it; see the next section for information on the platforms on which you can capture on the "loopback interface".

Supported Platforms

See  for Wireshark capturing support on various platforms. Summary: you can capture on the loopback interface on Linux, on various BSDs including Mac OS X, and on Digital/Tru64 UNIX, and you might be able to do it on Irix and AIX, but you definitely cannot do so on Solaris, HP-UX, or Windows.

Windows

IP 127.0.0.1

You can't capture on the local loopback address 127.0.0.1!

IP other

You can add a virtual network card called Microsoft Loopback Adapter, but in most cases that might not give results as expected either.

This adapter is available from Microsoft:

  • Microsoft: How to install the Microsoft Loopback Adapter in Microsoft Windows Server 2003

  • Microsoft: How to install the Microsoft Loopback adapter in Windows XP

  • Microsoft: How To Install Microsoft Loopback Adapter in Windows 2000

... and is quite different than the ones available for various UN*X systems. This adapter is a virtual network adapter you can add, but it will not work on the 127.0.0.1 IP addresses; it will take its own IP address. BTW: You can only add one Loopback Adapter to the system!

Beware: Capturing from this Loopback Adapter requires the WinPcap 3.1 release, 3.1 beta versions won't work!

Let's suppose you have set the IP address of the loopback adapter to 10.0.0.10 and are capturing on that interface. If you ping to this 10.0.0.10 address the ping will get ping replies, but you won't see any of this traffic in Wireshark (much like the 127.0.0.1 problem). If you ping on 10.0.0.11, you won't get ping replies as there is obviously no remote host, but you will see the corresponding ARP requests in Wireshark.

The only benefit I can see so far is if you use it with colinux (and probably other PC virtualization software) to capture the traffic between Windows and the virtual machine. - UlfLamping

Recipe (to capture traffic on ms loopback adapter / Windows XP): --- by mitra

1. go to MS Loopback adapter properties, set IP 10.0.0.10, MASK 255.255.255.0
2. ipconfig /all and look at the MAC-ID for your new adapter.
3. arp -s 10.0.0.10 <MAC-ID>
4. route add 10.0.0.10 10.0.0.10 mask 255.255.255.255
5. to test: "telnet 10.0.0.10"

I am now using the loopback adapter to capture traffic that I source into a Dyanmips/Dynagen virtual router network. This is a potentially very useful tool/feature that I will be testing further in the weeks to come. As it stands, I can connect my loopback adapter to a virtual router interface and capture ping, arp, etc. In the near future, I hope to tie a server w/ a loopback adapter to a virtual router and then capture a full client/server type of exchange across a Dynamips/Dynagen emulated network. -- Scott Vermillion

NOTE: To get to the Microsoft Loopback Adapter Properties: Start -> Settings -> Control Panel -> System -> Device Manager -> Network Adapters and right click Microsoft Loopback Adapter to select Properties. -- saran

Alternatives

A commercial network sniffer called CommView (from TamoSoft) allows to capture packets on the localhost network adapter but it dissects fewer protocols, so you can capture packets with CommView and save them into a file and open it with Wireshark.

An other alternative is to add a route to your local machine going through the network gateway:

route add <your_IP> mask 255.255.255.255 <the_gateway> metric 1

with <your_IP> being different from 127.0.0.1. It should (has to) be the result of ipconfig command (ip address field) <the_gateway> has to be the default gateway field taken from ipconfig /all result.

Doing so, every network traffic from your machine to itself will use the physical network interface, it will then go to the gateway, back to you. Therefor, you will see each packet twice, but it can be filtered on the view.

Be careful, since your machine will use the actual network to talk to itself, it may overload the network. It may be wise to remove the new route once you are done with the tests:

route delete <your_IP>
This is translated from French, based on the method described here.


 

最后

以上就是温暖红酒为你收集整理的wireshark抓取本地程序之间的封包Loopback capture setup的全部内容,希望文章能够帮你解决wireshark抓取本地程序之间的封包Loopback capture setup所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(49)

评论列表共有 0 条评论

立即
投稿
返回
顶部