Skip to content

Instantly share code, notes, and snippets.

View bogdando's full-sized avatar

Bogdan Dobrelya bogdando

  • Red Hat
  • Poznan, Poland
View GitHub Profile
@bogdando
bogdando / ep.sh
Last active September 12, 2016 12:39
An entrypoint to capture net packets for a given command, in a dedicated netns
#!/bin/bash -ex
# An entrypoint to capture net packets for a given command, in a dedicated netns.
# Example usage: timeout -s KILL 15 docker run -e "SHARKFMT=pcap" -v \
# /tmp:/tmp -v /tmp/ep.sh:/usr/local/sbin/ep.sh:ro --entrypoint ep.sh \
# --privileged --cap-add ALL --rm bogdando/dbox nslookup kubernetes.io 10.233.0.2
# Then replay with: tcpick -C -yP -r /tmp/out.pcap or tcpdump -qns 0 -A -r /tmp/out.pcap
INT=${INT:-$(ip addr show | grep -E '^[ ]*inet' | grep -m1 global | awk '{ print $NF }' | sed -e 's/@//')}
IP=${IP:-$(ip addr show | grep -E '^[ ]*inet' | grep -m1 -E "global( $INT)?" | awk '{ print $2 }' | sed -e 's/\/.*//')}
TESTNETPREFIX=${TESTNETPREFIX:-192.168.163}