• Use Wireshark to capture loopback traffic without a loopback adapter (转)


    Use Wireshark to capture loopback traffic without a loopback adapter

        If you’ve ever used Wireshark for debugging applications you may have noticed that it only seems to pick up traffic that is actually transmitted over the wire and ignores all traffic sent to your local ip address or localhost. If you want to watch this traffic without having to install a special loopback adapter you can use the following trick.

    How to force local traffic to your default gateway
    1) Open a command prompt (Run as Administrator for Vista/7)
    2) Type ipconfig/all (note your local ip address(es) and default gateway)
    3) Type “route add <your ip address> mask 255.255.255.255 <default gateway IP address> metric 1″

        This instructs windows to send any requests for your local ip address to your default gateway, which will in turn forward the request back to your machine. Be aware that this route will disappear once you restart your machine unless you include the -p switch after the route command. You may also notice an echo effect if you’re using Wireshark because you see each request and response twice. You can remove this problem by applying the following filter at the top.

        ip.src==<default gateway> or ip.dst==<default gateway>

        Consider the default gateway as a client trying to reach your machine and all traffic sent to the default gateway as your machine’s response.

        To remove the route, type “route delete <the ip address you entered>”.

        If you have an application running locally that uses localhost, you can map localhost to the IP address you added a route for. Just don’t forget you mapped localhost to a different IP than 127.0.0.1!

    How to map localhost
    1) Open notepad (Run as Administrator in Vista/7)
    2) Navigate to C:WindowsSystem32driversetc and open the hosts file (there’s no extension).
    3) Add this entry “<the IP address you added a route for> localhost”. Note that the space between the ip address and localhost is a tab.

        Now, when your machine tries to send something to localhost, it will resolve to the IP address you added a route for and send its traffic to your default gateway.

    (Important!) Remember to unblock the port used for incoming traffic on your machine. Also, if you find that an application you’re using doesn’t seem to send out traffic the way you expect, try flushing the dns cache with ipconfig/flushdns.

    转自:http://blog.sina.com.cn/s/blog_53d3653e0100t2kq.html

     
  • 相关阅读:
    程序界真正的高帅富团体:Valve
    How Unreal Engine 4 Will Change The Next Games You Play【纯搬运】
    互联网“百年老店”是彻头彻尾的扯淡!
    如何关闭VS10中的IntelliSense
    发人深省周鸿祎:少功利多学习 做力所能及的事情
    FlashCS4 快捷键大全
    《1万小时成功定律——解构成功》
    通过AutoExpand调试Unreal内置数据类型
    14 Ways to Motivate Yourself
    关于C++ 动态定义数组
  • 原文地址:https://www.cnblogs.com/Persue-A-Good-Life/p/4533361.html
Copyright © 2020-2023  润新知