Search code examples
virtualizationvirtualboxvagrant

Capturing Vagrant Network Traffic


I've got a VM running. I use HTTP Scoop for debugging Ajax requests, but unfortunately, with bridged networking and a static IP, I cannot see network activity to my VM.

Is there a configuration change I need to make?


Solution

  • Vagrant is wrapper around VirtualBox. You can use package capture and analyse it in Wireshark.

    Network tracing Network problems could be detected by enabling packet logging at the guest side or at the host side, but using the built-in capability of VirtualBox to create pcap files might provide even more useful information because it contains a log of really all packets received and sent by guest.

    To enable network tracing do the following:

    VBoxManage modifyvm [your-vm] --nictrace[adapter-number] on --nictracefile[adapter-number] file.pcap

    For example

    VBoxManage modifyvm "ubuntu" --nictrace1 on --nictracefile1 trace1.pcap

    If you use vagrant add following lines to Vagrantfile:

    config.vm.customize ["modifyvm", :id, "--nictrace1", "on"]
    config.vm.customize ["modifyvm", :id, "--nictracefile1", "trace1.pcap"]
    

    Then open trace1.pcap file in Wireshark.