Skip to content
Snippets Groups Projects
Commit e2bdbeef authored by Thomas Woerner's avatar Thomas Woerner
Browse files

infra/image system-services: Fix DNS forwarder

The DNS forwarder is set while deploying the IPA server. This forwarder
might not be correct later on.

The old /etc/resolv.conf is copied to /etc/resolv.conf.fixnet by the
fixnet service and later on the fixipaip service is trying to get the
nameserver from the copied file. If the retrieval failed of if the
namesever is 127.0.0.1, then the nameserver will be set to 8.8.8.8.

After fixing the IP addresses for the forward and reverse zone, also the
forwarder is set for the dnsserver "${HOSTNAME}".
parent 88dc4c69
No related branches found
No related tags found
No related merge requests found
...@@ -44,11 +44,16 @@ if [ -z "${PTR}" ] || [ -n "${PTR//[0-9]}" ]; then ...@@ -44,11 +44,16 @@ if [ -z "${PTR}" ] || [ -n "${PTR//[0-9]}" ]; then
echo "ERROR: Failed to get PTR from IPv4 address: '${PTR}'" echo "ERROR: Failed to get PTR from IPv4 address: '${PTR}'"
exit 1 exit 1
fi fi
FORWARDER=$(grep -s -m 1 ^nameserver /etc/resolv.conf.fixnet | cut -d" " -f 2)
if [ -z "${FORWARDER}" ] || [ "${FORWARDER}" == "127.0.0.1" ]; then
FORWARDER="8.8.8.8"
fi
echo "Fix IPA IP:" echo "Fix IPA:"
echo " HOSTNAME: '${HOSTNAME}'" echo " HOSTNAME: '${HOSTNAME}'"
echo " IP: '${IP}'" echo " IP: '${IP}'"
echo " PTR: '${PTR}'" echo " PTR: '${PTR}'"
echo " FORWARDER: '${FORWARDER}'"
if ! echo "SomeADMINpassword" | kinit -c "${KRB5CCNAME}" if ! echo "SomeADMINpassword" | kinit -c "${KRB5CCNAME}"
then then
...@@ -77,6 +82,8 @@ for zone in ${ZONES}; do ...@@ -77,6 +82,8 @@ for zone in ${ZONES}; do
fi fi
done done
ipa dnsserver-mod "${HOSTNAME}" --forwarder="${FORWARDER}"
kdestroy -c "${KRB5CCNAME}" -A kdestroy -c "${KRB5CCNAME}" -A
exit 0 exit 0
...@@ -51,7 +51,11 @@ else ...@@ -51,7 +51,11 @@ else
echo -e "$IP\t${HOSTNAME} ${HOSTNAME%%.*}" >> /etc/hosts echo -e "$IP\t${HOSTNAME} ${HOSTNAME%%.*}" >> /etc/hosts
fi fi
echo "nameserver 127.0.0.1" > /etc/resolv.conf cp -a /etc/resolv.conf /etc/resolv.conf.fixnet
cat > /etc/resolv.conf <<EOF
search ${HOSTNAME#*.}
nameserver 127.0.0.1
EOF
echo "/etc/hosts:" echo "/etc/hosts:"
cat "/etc/hosts" cat "/etc/hosts"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment