Ubuntu 22.04无头服务器网络故障求助:无法联网、WireGuard VPN连接异常及Docker容器相关问题
Ubuntu 22.04无头服务器网络故障求助:无法联网、WireGuard VPN连接异常及Docker容器相关问题
Hey there, sorry to hear you're stuck with this frustrating network mess—let's work through this step by step before even thinking about reinstalling Ubuntu (that's a last resort, and we can almost certainly fix this without wiping your setup!).
First, let's recap what we know to make sure we're on the same page:
- You're running a headless Ubuntu 22.04 server with Docker (Home Assistant, AdGuard Home)
- Issues started after setting up MAC-to-static IP mapping on your router + installing nmap/wireshark
- Current problems: Can't ping external sites like google.com, WireGuard won't connect properly, AdGuard Home isn't getting a host IP, and
/etc/resolv.confkeeps updating with changing IPv6 addresses - Deleting
/etc/resolv.conflets you ping google temporarily, but your router immediately crashes (requiring a reset)
Here's a structured troubleshooting plan to narrow down the root cause:
1. Verify Basic Static IP & DNS Configuration
- First, confirm your server's IP matches what you set in the router: Run
ip ato check your network interface's IP address, subnet mask, and default gateway. Make sure these values align exactly with the static IP you mapped to your server's MAC. - Ubuntu 22.04 uses
systemd-resolvedto manage DNS, so/etc/resolv.confis usually a symlink. Check where it points withls -l /etc/resolv.conf—it should link to either/run/systemd/resolve/stub-resolv.confor/run/systemd/resolve/resolv.conf. If it's a regular file (not a symlink), that's a red flag—someone/something overwrote it. - To fix fluctuating DNS, manually set reliable DNS servers in
systemd-resolved:- Edit the config file:
sudo nano /etc/systemd/resolved.conf - Uncomment the
DNSline and set it to public DNS (likeDNS=8.8.8.8 8.8.4.4) or your router's IP - Save and exit, then restart the service:
sudo systemctl restart systemd-resolved
This should stop/etc/resolv.conffrom getting filled with random IPv6 addresses.
- Edit the config file:
2. Check for Docker Network Conflicts
- Docker can sometimes mess with host network settings, especially if containers use
hostnetwork mode. For AdGuard Home:- Restart its container first:
docker restart <adguard-container-name> - Check its IP with
docker inspect <adguard-container-name> | grep IPAddress—if you're usinghostmode, it should show your server's IP. If not, double-check your container run command/compose file for network mode settings.
- Restart its container first:
- Verify Docker's global DNS config: Check if
/etc/docker/daemon.jsonexists. If not, create it with:
Then restart Docker:{ "dns": ["8.8.8.8", "8.8.4.4"] }sudo systemctl restart docker—this ensures containers use reliable DNS instead of inheriting broken host settings.
3. Troubleshoot WireGuard's Impact
- WireGuard modifies your host's routing table and DNS, which is likely why
/etc/resolv.confkeeps changing.- First, stop WireGuard temporarily:
sudo wg-quick down wg0(replacewg0with your WireGuard interface name) - Try pinging google.com again—if this works, the problem is almost certainly in your WireGuard config.
- Check your WireGuard config file (usually
/etc/wireguard/wg0.conf) for aDNSline. If it's set to an IPv6 address that's unreachable, that's causing the DNS chaos. Either remove the line or set it to a working DNS server. - Also, check your routing table after starting WireGuard:
ip route show—look for any routes that might be forcing all traffic through the VPN (even when it's not connected), which would block external access.
- First, stop WireGuard temporarily:
4. Rule Out Router & MAC Binding Issues
- The fact that deleting
/etc/resolv.confcrashes your router is unusual. This suggests your router might be relying on AdGuard Home as its primary DNS server—but if AdGuard isn't working, the entire network loses DNS resolution.- Log into your router and check:
- Is the static IP mapping for your server correct? Make sure no other device is using the same IP.
- Is the router's DNS server set to AdGuard Home's IP? If yes, temporarily switch it to a public DNS (like 8.8.8.8) to see if the router stops crashing when you test your server's network.
- Also, confirm your router's DHCP service is running properly—if it's conflicting with your static IPs, that could cause connectivity issues.
- Log into your router and check:
5. Clean Up Leftovers from nmap/Wireshark
- Even after uninstalling, these tools might leave behind network settings or permissions. Try resetting your network interface:
Replacesudo ip link set <your-interface-name> down sudo ip link set <your-interface-name> up<your-interface-name>with your actual network interface (you can find it withip a—look for names likeeth0orenp0s3).
Start with these steps, and share what you find along the way—we can dig deeper based on your results. Reinstalling Ubuntu should be the absolute last thing you do here!
备注:内容来源于stack exchange,提问作者Mc Nulty
相关产品推荐
相关产品推荐

