Created
April 11, 2017 21:59
-
-
Save boina-n/d8c89e4be286579824554f7a05a158c5 to your computer and use it in GitHub Desktop.
This is memo script that replay the DNS traffic captured in order to load a DNS Server for test purpose.
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
# 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