Skip to content

Commit 8aa85e0

Browse files
author
NerdOfCode
committed
Added new mx_lookup script
1 parent 939703b commit 8aa85e0

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

Bash/mx_lookup.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
#Purpose: Look up MX records using a simple two step process
3+
4+
#Colors for all warnings and errors
5+
RED='\033[0;31m'
6+
NONE='\033[0m'
7+
8+
$(which dig >/dev/null 2>&1)
9+
10+
if [ $? != 0 ]
11+
then
12+
echo "Please install the 'dig' command"
13+
exit 1
14+
fi
15+
16+
read -p "Enter host domain: " host
17+
18+
mx_target=$(dig +short MX $host | awk -F " " '{print $2}')
19+
20+
ip=$(ping -c 1 $mx_target | awk -F " " '{print $5}' | sed 's/[^0-9.]*//g' | xargs)
21+
22+
23+
echo "MX record: $mx_target"
24+
25+
if [ -z $ip ]
26+
then
27+
printf "${RED}NOTE:${NONE} it is likely this IP blocks ICMP or ping requests\n"
28+
fi
29+
echo "IP: $ip"

0 commit comments

Comments
 (0)