Skip to content

Instantly share code, notes, and snippets.

@nyrahul
Created April 16, 2021 18:55
Show Gist options
  • Save nyrahul/c18cf5f4478b35b0e1592204c54cb549 to your computer and use it in GitHub Desktop.
Save nyrahul/c18cf5f4478b35b0e1592204c54cb549 to your computer and use it in GitHub Desktop.
tcpdump for pod controlled by cilium
#!/bin/bash
# Usage: $0 <pod> [tcpdump-filter]
[[ "$1" == "" ]] && echo "Usage: $0 <pod> [tcpdump-filter]" && exit 1
ep_id=`kubectl get cep -A -o jsonpath="{.items[?(@.metadata.name==\"$1\")].status.id}"`
iface=`cilium endpoint get $ep_id -o jsonpath="{[*].status.networking.interface-name}"`
shift
[[ "$iface" != lxc* ]] && echo "Could not get interface for pod=[$1]" && exit 2
echo "Executing: tcpdump -i $iface $*"
tcpdump -i $iface $*
@navarrothiago
Copy link

🚀

@nyrahul
Copy link
Author

nyrahul commented Aug 5, 2021

FYI: This script will work only within cilium development env.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment