Check if IP address is in use.

This commit is contained in:
hackacad
2020-02-04 09:30:03 +01:00
parent f61c530265
commit 45f9247be9
2 changed files with 9 additions and 2 deletions

View File

@@ -58,7 +58,10 @@ validate_ip() {
exit 1
fi
done
echo -e "${COLOR_GREEN}Valid: ($ip).${COLOR_RESET}"
if ifconfig | grep -w "$ip" >/dev/null; then
echo -e "${COLOR_YELLOW}Warning: ip address already in use ($ip).${COLOR_RESET}"
else
echo -e "${COLOR_GREEN}Valid: ($ip).${COLOR_RESET}"
else
echo -e "${COLOR_RED}Invalid: ($ip).${COLOR_RESET}"
exit 1