Select Your Language

Infrastructure and Management

Cloud Computing

Storage

Runtimes

Integration and Automation

Running tcpdump inside a OpenShift 4 pod with SSH access to the nodes

Updated on

Request a new translation or translation update

A translation for your language preference does not exist. Click below to request a translation for your selected language.

Submit request

IMPORTANT: This article is for RHOCP4 or RHOCP5 with RHCOS9. For RHOCP5 with RHCOS10, please check this article instead.

  • SSH to the node and become root.

  • Start a toolbox container with the toolbox command - NOTE: disconnected installation must have a mirrored toolbox container image in their offline container image registry

    $ toolbox
    
  • If you want to capture from a Pod, you can follow these steps.

    • For RHOCP 4.9+ do as follows:
    $ NAME="<pod-name>"
    $ NAMESPACE="<pod-namespace>"
    $ INTERFACE_NAME="<pod-interface-where-we-are-capturing>" # e.g. "eth0" or "any"
    $ pod_id="$(chroot /host crictl pods --namespace ${NAMESPACE} --name ${NAME} -q)"
    $ ns_path="/host/$(chroot /host bash -c "crictl inspectp $pod_id | jq '.info.runtimeSpec.linux.namespaces[]|select(.type==\"network\").path' -r")"
    $ nsenter --net="${ns_path}" -- tcpdump -nn -i "${INTERFACE_NAME}" -w "/host/var/tmp/${HOSTNAME}_pod_${NAMESPACE}_${NAME}_${INTERFACE_NAME}_$(date +%d_%m_%Y-%H_%M_%S-%Z).pcap"
    
    • For RHOCP 4.8 and lower:
    $ NAME="<pod-name>"
    $ NAMESPACE="<pod-namespace>"
    $ INTERFACE_NAME="<pod-interface-where-we-are-capturing>" # e.g. "eth0" or "any"
    $ pod_id="$(chroot /host crictl pods --namespace ${NAMESPACE} --name ${NAME} -q)"
    $ pid="$(chroot /host bash -c "runc state $pod_id | jq .pid")"
    $ nsenter -n -t "${pid}" -- tcpdump -nn -i "${INTERFACE_NAME}" -w "/host/var/tmp/${HOSTNAME}_pod_${NAMESPACE}_${NAME}_${INTERFACE_NAME}_$(date +%d_%m_%Y-%H_%M_%S-%Z).pcap"
    
  • End the capture with Control-C when needed

  • List captured files:

    $ ls -l "/host/var/tmp/*.pcap"
    
  • Copy the tcpdump capture from the node (replace ${PCAP_FILE} with pcap file name from previous step):

    $ scp core@<nodename>:/var/tmp/${PCAP_FILE} ${PCAP_FILE}
    

    Alternatively, you can just upload it (from the toolbox container itself or from another machine you copied it to) to our secure SFTP server.
    Note: the support-tools container mounts the host file system at /host

This solution is part of Red Hat's fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Red Hat LinkedIn YouTube Facebook X, formerly Twitter

Quick Links

Help

Site Info

Related Sites

© 2026 Red Hat