This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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} |
NewerOlder