Skip to content

Instantly share code, notes, and snippets.

@addeeandra
Last active November 6, 2024 10:28
Show Gist options
  • Save addeeandra/9a6e351f11153aa3c1fceab84736ea2a to your computer and use it in GitHub Desktop.
Save addeeandra/9a6e351f11153aa3c1fceab84736ea2a to your computer and use it in GitHub Desktop.
A snippet of bash script to check connectivity via `ping` and `curl` command
#!/bin/bash
IP_VLAN=10.22.2.1
if curl -s $IP_VLAN > /dev/null; then
echo "Access to $IP_VLAN (vlan) is open."
else
echo "Access to $IP_VLAN (vlan) is not available."
fi
#!/bin/bash
IP_VLAN=10.22.2.1
if ping -c 4 $IP_VLAN > /dev/null; then
echo "Connection to $IP_VLAN (vlan) is up."
else
echo "Connection to $IP_VLAN (vlan) is down."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment