home · contact · privacy
In /etc/hosts-setting script, ignore IPv6s.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 26 Jun 2020 19:57:15 +0000 (21:57 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 26 Jun 2020 19:57:15 +0000 (21:57 +0200)
buster/setup_scripts/set_hostname_and_fqdn.sh

index 3f95590bce3b4ff47abeb206cdc60bd36fadabe0..a3b9f9a9651747229b7442eb5fea1e3a87a5d985 100755 (executable)
@@ -10,6 +10,8 @@
 # on our systems) or to 127.0.1.1 if not. On the reasoning for separating
 # localhost and hostname mapping to different IPs, see
 # <https://unix.stackexchange.com/a/13087>.
 # on our systems) or to 127.0.1.1 if not. On the reasoning for separating
 # localhost and hostname mapping to different IPs, see
 # <https://unix.stackexchange.com/a/13087>.
+#
+# Ignores IPv6s.
 set -e
 
 hostname="$1"
 set -e
 
 hostname="$1"
@@ -23,6 +25,9 @@ hostname "${hostname}"
 
 final_ip="127.0.1.1"
 for ip in $(hostname -I); do
 
 final_ip="127.0.1.1"
 for ip in $(hostname -I); do
+    if [ $(echo "${ip}" | grep ':' | wc -l) -eq 1 ]; then
+        continue
+    fi
     range_1=$(echo "${ip}" | cut -d "." -f 1)
     range_2=$(echo "${ip}" | cut -d "." -f 2)
     if [ "${range_1}" -eq 127 ]; then
     range_1=$(echo "${ip}" | cut -d "." -f 1)
     range_2=$(echo "${ip}" | cut -d "." -f 2)
     if [ "${range_1}" -eq 127 ]; then