diff --git a/README b/README index 8aca18b..e74e8a7 100644 --- a/README +++ b/README @@ -15,4 +15,4 @@ policyd-550.sh Grep the mail.log for e-mails rejected by policyd-weight and sc rblcheck.sh Check if your server is listed on an DNSBL tls_stats.sh If you own a mailserver sending e-mails via TLS, show stats of peers www-perms.sh Analyze your $documentroot for files writable by www user/group - +getiface.sh Shows which interface would be used to connect to a specific host/IP diff --git a/getiface.sh b/getiface.sh new file mode 100755 index 0000000..ea7a67e --- /dev/null +++ b/getiface.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Shows which interface would be used +# to connecto to an IP address/hostname + +INPUT=$1 + +if [ -z $INPUT ]; then + echo "Need an IP/hostname" + exit +fi + +if [ $(echo $INPUT | grep -c '[a-z]') -gt 0 ]; then + INPUT=$(dig +short $INPUT | tail -1) +fi + +echo -n "Interface: " +ip -o route get $INPUT | perl -nle 'if(/dev\s+(\S+)/) {print $1}'