Skip to content

Commit f6cf2ff

Browse files
author
Ravi Sankar Penta
committed
Ensure non-zero minimum TTL for the domain in egress network policy
1 parent f62ffd8 commit f6cf2ff

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pkg/network/common/dns.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,13 @@ func (d *DNS) getIPsAndMinTTL(domain string) ([]net.IP, time.Duration, error) {
154154
case *dns.A:
155155
ips = append(ips, t.A)
156156

157-
if minTTL == 0 || t.Hdr.Ttl < minTTL {
158-
minTTL = t.Hdr.Ttl
157+
// We could potentially get zero TTL as we try to query the DNS
158+
// server at the end of the TTL value for the domain.
159+
// Adding 1 sec will ensure non zero minTTL
160+
ttl := t.Hdr.Ttl + 1
161+
162+
if minTTL == 0 || ttl < minTTL {
163+
minTTL = ttl
159164
}
160165
}
161166
}

0 commit comments

Comments
 (0)