We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 939703b commit 8aa85e0Copy full SHA for 8aa85e0
1 file changed
Bash/mx_lookup.sh
@@ -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
27
+ printf "${RED}NOTE:${NONE} it is likely this IP blocks ICMP or ping requests\n"
28
29
+echo "IP: $ip"
0 commit comments