Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Using tcpdump to capture traffic remotely but save output to a local file

    Scheduled Pinned Locked Moved General pfSense Questions
    6 Posts 3 Posters 9.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      jonathanbaird
      last edited by

      Hi,

      I have set up SSH and can successfully SSH into my pfSense machine. I can also run tcpdump no problem. My question is, would it be possible to run tcpdump remotely over either a VPN/WAN but save the output to a local machine using a ring buffer?

      I need to leave tcpdump running to try and capture an intermittent issue we are running into, and the packet capture GUI doesn't offer me the functionality I need to perform this.

      Any help or guidance would be great.

      Thank you in advance.

      Jonathan.

      1 Reply Last reply Reply Quote 0
      • GruensFroeschliG
        GruensFroeschli
        last edited by

        Even better:
        You can directly capture traffic remote with wireshark

        On your PC you start:

        
        nc -l -p 12345 | wireshark -k -i -
        
        

        This will start wireshark, with netcat listening on port 12345 and forwarding anything directly to wireshark.

        On the pfSense you start:

        
        tcpdump -i vr0 -U -w - | nc 10.0.42.2 12345
        
        

        This will capture traffic on the interface vr0 and forward everything to the PC at the address 10.0.42.2 on port 12345.
        Replace 10.0.42.2 with the IP of the PC running the wireshark and listening on port 12345

        _Edit:
        Instead of running wireshark you can also directly pipe into a file:

        
        nc -l -p 12345 > /home/user/somefile.pcap
        
        ```_

        We do what we must, because we can.

        Asking questions the smart way: http://www.catb.org/esr/faqs/smart-questions.html

        1 Reply Last reply Reply Quote 0
        • 2
          2chemlud Banned
          last edited by

          Very cool! 8-)

          1 Reply Last reply Reply Quote 0
          • J
            jonathanbaird
            last edited by

            This does look interesting! I'll take a look - thanks for your help.

            1 Reply Last reply Reply Quote 0
            • J
              jonathanbaird
              last edited by

              @GruensFroeschli:

              Even better:
              You can directly capture traffic remote with wireshark

              On your PC you start:

              
              nc -l -p 12345 | wireshark -k -i -
              
              

              This will start wireshark, with netcat listening on port 12345 and forwarding anything directly to wireshark.

              On the pfSense you start:

              
              tcpdump -i vr0 -U -w - | nc 10.0.42.2 12345
              
              

              This will capture traffic on the interface vr0 and forward everything to the PC at the address 10.0.42.2 on port 12345.
              Replace 10.0.42.2 with the IP of the PC running the wireshark and listening on port 12345

              _Edit:
              Instead of running wireshark you can also directly pipe into a file:

              
              nc -l -p 12345 > /home/user/somefile.pcap
              
              

              Hi,

              Thanks for your help with this. With the below command, can we add a ring buffer to this so that files are a total of 100MB in size?

              nc -l -p 12345 > /home/user/somefile.pcap
              

              I've done some testing with this but cannot seem to get this to work. I'm also using a Windows Server for this, if that makes any difference!?

              Regards,

              Jonathan._

              1 Reply Last reply Reply Quote 0
              • GruensFroeschliG
                GruensFroeschli
                last edited by

                I gave the answer to this in your other thread where you originally asked this question.
                https://forum.pfsense.org/index.php?topic=108668.msg605967#msg605967

                We do what we must, because we can.

                Asking questions the smart way: http://www.catb.org/esr/faqs/smart-questions.html

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.