#!/bin/ksh # $Id: mailmx,v 1.6 2008/10/26 18:53:16 ksb Exp $ # We're a netlint plugin that reports our lowest priority MX host (petef,ksb) # to the central netlint server (which will cross-reference with # the netlint report from that mx host) PROGNAME=`basename $0` : ${CARP:=echo} if [ _"$1" = _"-V" ]; then echo "$PROGNAME: "'$Id: mailmx,v 1.6 2008/10/26 18:53:16 ksb Exp $' exit 0 fi HOST=`hostname` if expr "$HOST" : "[^.]*" >/dev/null; then HOST="$HOST[^ ]*" fi #****a* mail/MAIL_MX # NAME # MAIL_MX # FORMAT # MAIL_MX: name integer # DESCRIPTION # This is the list of DNS MX records the host sees for itself from the local # resolver. # REMEDIATION # Fix DNS errors in the zone file on master-source in /etc/namedb/master. #*** # Get a list of IPs our hostname resolves to nslookup -q=mx `hostname` 2>/dev/null | sed -n -e "s,^$HOST[ ]*mail exchanger = \([0-9][0-9]*\) \(.*\)\.$,\1 \2,p" -e "s,^$HOST[ ]*preference = \([0-9][0-9]*\)\, mail exchanger = \(.*\),\1 \2,p" | sort -n | head -1 | sed -n -e 's,^\([0-9]*\) \(.*\)$,MAIL_MX: \2 \1,p' | xapply -f "$CARP '%1'" - exit 0