Skip to content

Commit 897932f

Browse files
committed
Customize resolv-setup and add debugging into it
1 parent 429f679 commit 897932f

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

ext/standard/tests/dns/resolv-setup.sh

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,47 @@ echo "Using interface: $IFACE"
2121
echo "Current configuration:"
2222
resolvectl status "$IFACE" | grep -E 'Current DNS Server:|DNS Servers:'
2323

24-
echo "Setting DNS to $LOCAL_DNS for $IFACE"
24+
# Store the original DNS server for fallback
25+
ORIGINAL_DNS=$(resolvectl status "$IFACE" | grep "DNS Servers:" | sed 's/.*DNS Servers: //' | awk '{print $1}')
26+
echo "Original DNS server: $ORIGINAL_DNS"
2527

26-
# Reset interface configuration
28+
echo "Setting DNS to $LOCAL_DNS for $IFACE (with fallback to $ORIGINAL_DNS)"
29+
30+
# Reset interface configuration first
2731
resolvectl revert "$IFACE"
2832

29-
# Set DNS to local
30-
resolvectl dns "$IFACE" "$LOCAL_DNS"
33+
# Set DNS with local server FIRST (this makes it primary)
34+
resolvectl dns "$IFACE" "$LOCAL_DNS" "$ORIGINAL_DNS"
3135

3236
# Confirm setup
3337
echo -e "\nUpdated configuration:"
3438
resolvectl status "$IFACE" | grep -E 'Current DNS Server:|DNS Servers:'
3539

40+
echo -e "\nTesting DNS resolution..."
41+
42+
# Test if our local DNS is working
43+
echo "Testing local BIND server directly:"
44+
if dig @127.0.0.1 www.basic.dnstest.php.net A +short; then
45+
echo "✓ Local BIND server is responding"
46+
else
47+
echo "✗ Local BIND server is not responding"
48+
exit 1
49+
fi
50+
51+
# Test system DNS resolution
52+
echo -e "\nTesting system DNS resolution:"
53+
if dig www.basic.dnstest.php.net A +short; then
54+
echo "✓ System DNS resolution is working"
55+
else
56+
echo "✗ System DNS resolution failed"
57+
fi
58+
59+
# Test with nslookup as well
60+
echo -e "\nTesting with nslookup:"
61+
nslookup www.basic.dnstest.php.net || echo "nslookup failed"
62+
63+
# Show which DNS server is actually being used
64+
echo -e "\nFinal verification:"
65+
resolvectl query www.basic.dnstest.php.net || echo "resolvectl query failed"
66+
3667
echo -e "\nDNS configuration has been updated."

0 commit comments

Comments
 (0)