Skip to content

Instantly share code, notes, and snippets.

@dojci
Last active October 24, 2019 12:48
Show Gist options
  • Save dojci/df7c249f674affcc40e753dad8b6fa0f to your computer and use it in GitHub Desktop.
Save dojci/df7c249f674affcc40e753dad8b6fa0f to your computer and use it in GitHub Desktop.
Pod resolv.conf modification on the fly
#!/bin/bash
set -ex
export DNS_TCP=${DNS_TCP:-false}
if [ "$DNS_TCP" == true ]; then
# enable tcp DNS resloving
if [ $(grep -w options /etc/resolv.conf | wc -l) -eq 0 ]
then
echo "options use-vc" >> /etc/resolv.conf
else
mapfile </etc/resolv.conf resolv && sed -r 's/(options.*)/\1 use-vc/g; s/^\s+//g' <<<"${resolv[*]}" > /etc/resolv.conf
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment