Skip to content

Instantly share code, notes, and snippets.

@boina-n

boina-n/DNS_Bench.sh

Created Apr 11, 2017
Embed
What would you like to do?
This is memo script that replay the DNS traffic captured in order to load a DNS Server for test purpose.
# To be executed on the DNS server and output to be copied
dif=bond1
dip=$(ip addr show dev $dif | egrep -o '(addr:)?([0-9]*\.){3}[0-9]*' | head -n1)
dmac=$(ip link show dev $dif | egrep -o '(link/ether:)?([0-9a-f]{2}\:){5}[0-9a-f]{2}' |head -n1)
echo -e "dmac=$dmac \ndip=$dip"
#To be executed on the injector
#Past the previous copied content from the DNS server
sif=bond1
sip=$(ip addr show dev $sif | egrep -o '(addr:)?([0-9]*\.){3}[0-9]*' | head -n1)
smac=$(ip link show dev $sif | egrep -o '(link/ether:)?([0-9a-f]{2}\:){5}[0-9a-f]{2}' |head -n1)
time=$(date +"%Y%m%d-%H.%M.%S")
echo $time
# Rewrite IP and mac @ on a new capture
tcprewrite -i dnstraffic01.pcap -S 0.0.0.0/0:$sip/32 --enet-smac=$smac --enet-vlan=del -D 0.0.0.0/0:$dip/32 --enet-dmac=$dmac -C -o dnstrafic01-rewritten.$time
#Replay the DNS capture
tcpreplay --enable-file-cache --timer=gtod -i $sif -p 35000 -l0 dnstrafic01-rewritten.$time
#Monitor the bandwith on the DNS server
sar -n DEV 1 1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.