1️⃣ Create the script
sudo nano /usr/local/bin/ping_host_keepalive.sh
Paste this:
#!/bin/bash
HOST=”192.168.1.18″ # replace with your Mac host IP
ping -c 1 -W 2 $HOST > /dev/null
2️⃣ Make it executable
sudo chmod +x /usr/local/bin/ping_host_keepalive.sh
3️⃣ Add to cron
sudo crontab -e
Add two lines (to run every 30 seconds):
* * * * * /usr/local/bin/ping_host_keepalive.sh
* * * * * sleep 30; /usr/local/bin/ping_host_keepalive.sh
That’s it. Your VM will now send a lightweight ping every 30 seconds, keeping the ARP entry active and the connection stable.