-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathlint-hostname
executable file
·32 lines (28 loc) · 1.06 KB
/
lint-hostname
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#which ifconfig &>dev/null && IP=$(ifconfig | grep "^.*inet" |awk '{print $2}' |head -1)
#dnsdomainname can be as domain in resolv.conf depending on nsswitch.conf
IP=$(hostname -I|awk '{print $1}'|head -1)
FQDN=$(host $IP |awk '{print $NF}' | sed s,.$,,)
HS=$(hostname -s)
HF=$(hostname -f)
EH=$(cat /etc/hostname)
DOMAIN=$(hostname -d)
echo "hostname -s $HS"
echo "hostname -f $HF"
echo "/etc/hostname $EH"
echo "dnsdomainname $DOMAIN"
echo "IP $IP"
echo "DNS $FQDN"
echo
if [ ! $HS = $EH ]; then echo hostname -s does not match /etc/hostname; fi
if [ ! $HF = $EH.$DOMAIN ]; then echo hostname -f does not match hostname -s with dnsdomainname attached; fi
if [ ! $FQDN = $HF ]; then echo DNS entry does not match hostname -f; fi
grep "$IP.*$FQDN.*$HS" /etc/hosts >/dev/null || echo "$IP\t$FQDN\t$HS entry not found in /etc/hosts"
# hostnamectl set-hostname whatever --static
# also check DNS with
# /etc/resolv.conf
# resolvectl
# systemctl status systemd-resolved
#host -t soa $DOMAIN
#host -t ns $DOMAIN
#host -t mx $DOMAIN
#host -a $DOMAIN