subspacecommunity / subspace

A fork of the simple WireGuard VPN server GUI community maintained
MIT License
1.8k stars 131 forks source link

Document how to make nameserver change to `/etc/resolv.conf` permanent #105

Open jerrac opened 4 years ago

jerrac commented 4 years ago

Is your feature request related to a problem? Please describe. The README says to add nameserver 1.1.1.1 to /etc/resolv.conf. It does not explain why. Since I know Ubuntu 18.04 wipes out /etc/resolv.conf on boot, I ignored that section of the README. End result was I got confused about why the host was unable to lookup dns hostnames unless I stopped Subspace and restarted systemd-resolved.

Describe the solution you'd like Document that the /etc/resolv.conf symlink needs to be replaced by an actual file.

The file should contain:

nameserver <dns server ip>

The dns server ip should be your LAN dns provider, or you can use public dns servers like CloudFlare's 1.1.1.1, or Google's 8.8.8.8.

Optionally you can add a search directive like:

search example.org

That enables dns lookups based on the first part of hostnames like foo.example.org.

A full example:

nameserver 192.168.1.1
search example.org

Additional context Feel free to use what I wrote, though I do hope someone can word it better.... :\

Thanks!

edwardch commented 3 years ago

@jerrac I came across this: https://musaamin.web.id/set-permanent-resolv-conf-ubuntu/

A few sites recommended installing resolvconf

# Update nameservers so you can download the package
sudo sh -c "echo nameserver 1.1.1.1 > /etc/resolv.conf"
sudo sh -c "echo nameserver 1.0.0.1 >> /etc/resolv.conf"

# Install resolvconf
sudo apt-get install resolvconf

# Start & Enable the service
sudo systemctl start resolvconf.service
sudo systemctl enable resolvconf.service

# Edit the config
sudo nano /etc/resolvconf/resolv.conf.d/head

# Add these lines to the file:
nameserver 1.1.1.1
nameserver 1.0.0.1

# I use my own DNS servers here ^^

# Run updates
sudo resolvconf --enable-updates
sudo resolvconf -u  

# Restart the service
sudo systemctl restart resolvconf.service

# Ping
ping www.cloudflare.com

Out of interest, does anyone else recommend not doing this for any reason?

jerrac commented 3 years ago

I gave up on subspace not too long after posting this issue. Since then I've learned that systemd-resolved's dns servers can be modified in /etc/systemd/resolved.conf.

Not sure how that would interact with subspace and/or resolvconf. I have a feeling installing resolvconf would be meant to replace systemd-resolved.

Anyway, just wanted to mention what I'd learn since I'm going through my github notifications. I do still think solid documentation on how to properly implement dns for the vpn is needed, if it hasn't been created yet.

edwardch commented 3 years ago

Thanks for the response @jerrac.

I agree regarding the documentation, which I don't believe has been created. The rest of the setup was fairly straightforward.

What bought me to your issue was that after a few days of the VPN running, my requests (on the server) were not being resolved. The only way I could fix it was to update the DNS IP in /etc/resolv.conf, and then restart Subspace.

By using resolvconf per my comment/steps above, I was able to prolong my "uptime" to about a week, but I still need to log in and restart Subspace to restore internet connectivity to anyone connected to the VPN.

BTW I'm using NextDNS IPs for my DNS config.

I understand you don't use Subspace anymore, but would you have any ideas or pointers? I'd like to get it working (without having to restart) and documented for the rest of the community.

TIA

jerrac commented 3 years ago

Only thing I can think of would be to enable debug logging in subspace and see if any clues show up there. Hopefully someone else will see this and chime in with something more useful....

edwardch commented 3 years ago

Of course, I should've done that in the first place. Will give it a shot and see if I can get more info. If I do, I'll keep the thread going. Thanks again.