Skip to content

Instantly share code, notes, and snippets.

@dojci
Last active Oct 24, 2019
Embed
What would you like to do?
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