Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting K8S_DNS instead of getting it from default resov.conf #60

Merged
merged 2 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions bin/gateway_sidecar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ if [ ! -f /etc/resolv.conf.org ]; then
echo "/etc/resolv.conf.org written"
fi

# Get K8S DNS (only IPv4 addresses)
K8S_DNS=$(grep 'nameserver' /etc/resolv.conf.org | awk '/nameserver [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/ {print $2}')

# Get K8S DNS if not set (only IPv4 addresses)
if [ -z "$DNS_LOCAL_SERVER" ]; then
DNS_LOCAL_SERVER=$(grep nameserver /etc/resolv.conf.org | awk '/nameserver [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/ {print $2}')
fi

cat << EOF > /etc/dnsmasq.d/pod-gateway.conf
# DHCP server settings
Expand Down Expand Up @@ -56,7 +57,7 @@ fi
for local_cidr in $DNS_LOCAL_CIDRS; do
cat << EOF >> /etc/dnsmasq.d/pod-gateway.conf
# Send ${local_cidr} DNS queries to the K8S DNS server
server=/${local_cidr}/${K8S_DNS}
server=/${local_cidr}/${DNS_LOCAL_SERVER}
EOF
done

Expand Down
2 changes: 2 additions & 0 deletions config/settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ VPN_LOCAL_CIDRS="10.0.0.0/8 192.168.0.0/16"
# DNS queries to these domains will be resolved by K8S DNS instead of
# the default (typcally the VPN client changes it)
DNS_LOCAL_CIDRS="local"
# Dns to use for local resolution, if unset, will use default resolv.conf
DNS_LOCAL_SERVER=

# dnsmasq monitors directories. /etc/resolv.conf in a container is in another
# file system so it does not work. To circumvent this a copy is made using
Expand Down
Loading