Skip to content

Commit

Permalink
baremetal: Add script to configure local DNS
Browse files Browse the repository at this point in the history
This was previously done with an option to dhclient, but this doesn't
work when doing DHCPv6.  Switch to a script run by NetworkManager to do
the same thing.

This matches the same approach moved to by the MCO in this PR:

openshift/machine-config-operator#1396
  • Loading branch information
russellb authored and stbenjam committed Feb 5, 2020
1 parent 3682b55 commit a7033a0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
@@ -0,0 +1,20 @@
#!/bin/bash
IFACE=$1
STATUS=$2
case "$STATUS" in
up)
logger -s "NM local-dns-prepender triggered by ${1} ${2}."
DNS_IP="127.0.0.1"
set +e
logger -s "NM local-dns-prepender: Checking if local DNS IP is the first entry in resolv.conf"
if grep nameserver /etc/resolv.conf | head -n 1 | grep -q "$DNS_IP" ; then
logger -s "NM local-dns-prepender: local DNS IP already is the first entry in resolv.conf"
exit 0
else
logger -s "NM local-dns-prepender: Looking for '# Generated by NetworkManager' in /etc/resolv.conf to place 'nameserver $DNS_IP'"
sed -i "/^# Generated by.*$/a nameserver $DNS_IP" /etc/resolv.conf
fi
;;
*)
;;
esac
7 changes: 0 additions & 7 deletions data/data/bootstrap/baremetal/files/etc/dhcp/dhclient.conf

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/asset/ignition/bootstrap/bootstrap.go
Expand Up @@ -275,7 +275,7 @@ func (a *Bootstrap) addStorageFiles(base string, uri string, templateData *boots

var mode int
appendToFile := false
if path.Base(path.Dir(uri)) == "bin" {
if path.Base(path.Dir(uri)) == "bin" || filename == "30-local-dns-prepender" {
mode = 0555
} else if filename == "motd" {
mode = 0644
Expand Down

0 comments on commit a7033a0

Please sign in to comment.