Initial commit: add .gitignore and README
This commit is contained in:
53
fix-dns-now.sh
Executable file
53
fix-dns-now.sh
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Simple DNS fix that you can run with sudo
|
||||
# Usage: sudo ./fix-dns-now.sh
|
||||
|
||||
set -e
|
||||
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "This script must be run as root (use sudo)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Fixing DNS configuration..."
|
||||
|
||||
# Backup existing resolv.conf
|
||||
if [ -f /etc/resolv.conf ]; then
|
||||
cp /etc/resolv.conf /etc/resolv.conf.backup.$(date +%Y%m%d_%H%M%S)
|
||||
echo "✓ Backed up existing resolv.conf"
|
||||
fi
|
||||
|
||||
# Create new resolv.conf with reliable DNS servers
|
||||
cat > /etc/resolv.conf <<EOF
|
||||
# DNS configuration - fixed for Docker connectivity
|
||||
nameserver 8.8.8.8
|
||||
nameserver 8.8.4.4
|
||||
nameserver 1.1.1.1
|
||||
nameserver 10.255.255.254
|
||||
EOF
|
||||
|
||||
echo "✓ Updated /etc/resolv.conf"
|
||||
|
||||
# Prevent WSL from overwriting it (optional)
|
||||
if [ ! -f /etc/wsl.conf ]; then
|
||||
cat > /etc/wsl.conf <<EOF
|
||||
[network]
|
||||
generateResolvConf = false
|
||||
EOF
|
||||
echo "✓ Created /etc/wsl.conf to prevent auto-generation"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Testing DNS resolution..."
|
||||
if nslookup registry-1.docker.io > /dev/null 2>&1; then
|
||||
echo "✓ DNS resolution working!"
|
||||
else
|
||||
echo "⚠ DNS test failed, but configuration is updated"
|
||||
echo "You may need to restart WSL or Docker Desktop"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Done! Try running your Docker commands again."
|
||||
echo "If issues persist, restart Docker Desktop or run: wsl --shutdown (from Windows)"
|
||||
|
||||
Reference in New Issue
Block a user