In my network I have one linux host as a default gateway located at 192.168.150.1. On another host at 192.168.150.4 I have this script to measure time between sending an arp request and receiving it:
#!/usr/bin/env bash
for i in $(seq 30 $END); do
sudo ifconfig enp3s0 up
sleep 5s;
arping -I enp3s0 -c 1 192.168.150.1
echo $(date +%s.%5N) | tee -a ./ifuptimes.txt;
sleep 55s;
sudo ifconfig enp3s0 down;
sleep 1m;
done;
Strangely, when sending arping in the script the target at 192.168.150.1 responds to it only occasionally whereas when manually running it in terminal gets a response every time. Why does this happen and how can I fix it?