Merge: - install: fix DNS nameserver issue after we disable DNSStubListener on Ubuntu
* commit 'd31e9970419c393ac32af527bd94a940f6def990': + client: add autofix explanation to the install form - install: fix DNS nameserver issue after we disable DNSStubListener on Ubuntu
This commit is contained in:
commit
0ffe53405d
@ -202,9 +202,21 @@ If user clicks on "Fix" button, UI sends request to perform an automatic fix
|
|||||||
"dns":{"port":53,"ip":"127.0.0.1","autofix":true},
|
"dns":{"port":53,"ip":"127.0.0.1","autofix":true},
|
||||||
}
|
}
|
||||||
|
|
||||||
Deactivate (save backup as `resolved.conf.orig`) and stop DNSStubListener:
|
Deactivate DNSStubListener and update DNS server address. Create a new file: `/etc/systemd/resolved.conf.d/adguardhome.conf` (create a `/etc/systemd/resolved.conf.d` directory if necessary):
|
||||||
|
|
||||||
|
[Resolve]
|
||||||
|
DNS=127.0.0.1
|
||||||
|
DNSStubListener=no
|
||||||
|
|
||||||
|
Specifying "127.0.0.1" as DNS server address is necessry because otherwise the nameserver will be "127.0.0.53" which doesn't work without DNSStubListener.
|
||||||
|
|
||||||
|
Activate another resolv.conf file:
|
||||||
|
|
||||||
|
mv /etc/resolv.conf /etc/resolv.conf.backup
|
||||||
|
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
|
||||||
|
|
||||||
|
Stop DNSStubListener:
|
||||||
|
|
||||||
sed -r -i.orig 's/#?DNSStubListener=yes/DNSStubListener=no/g' /etc/systemd/resolved.conf
|
|
||||||
systemctl reload-or-restart systemd-resolved
|
systemctl reload-or-restart systemd-resolved
|
||||||
|
|
||||||
Server replies:
|
Server replies:
|
||||||
|
@ -433,5 +433,8 @@
|
|||||||
"example_rewrite_domain": "rewrite responses for this domain name only.",
|
"example_rewrite_domain": "rewrite responses for this domain name only.",
|
||||||
"example_rewrite_wildcard": "rewrite responses for all <0>example.org</0> subdomains.",
|
"example_rewrite_wildcard": "rewrite responses for all <0>example.org</0> subdomains.",
|
||||||
"disable_ipv6": "Disable IPv6",
|
"disable_ipv6": "Disable IPv6",
|
||||||
"disable_ipv6_desc": "If this feature is enabled, all DNS queries for IPv6 addresses (type AAAA) will be dropped."
|
"disable_ipv6_desc": "If this feature is enabled, all DNS queries for IPv6 addresses (type AAAA) will be dropped.",
|
||||||
|
"autofix_warning_text": "If you click \"Fix\", AdGuardHome will configure your system to use AdGuardHome DNS server.",
|
||||||
|
"autofix_warning_list": "It will perform these tasks: <0>Deactivate system DNSStubListener</0> <0>Set DNS server address to 127.0.0.1</0> <0>Replace symbolic link target of /etc/resolv.conf to /run/systemd/resolve/resolv.conf</0> <0>Stop DNSStubListener (reload systemd-resolved service)</0>",
|
||||||
|
"autofix_warning_result": "As a result all DNS requests from your system will be processed by AdGuardHome by default."
|
||||||
}
|
}
|
||||||
|
@ -213,18 +213,31 @@ class Settings extends Component {
|
|||||||
</div>
|
</div>
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
{dnsStatus &&
|
{dnsStatus &&
|
||||||
<div className="setup__error text-danger">
|
<Fragment>
|
||||||
{dnsStatus}
|
<div className="setup__error text-danger">
|
||||||
{isDnsFixAvailable &&
|
{dnsStatus}
|
||||||
<button
|
{isDnsFixAvailable &&
|
||||||
type="button"
|
<button
|
||||||
className="btn btn-secondary btn-sm ml-2"
|
type="button"
|
||||||
onClick={() => handleAutofix('dns', dnsIp, dnsPort)}
|
className="btn btn-secondary btn-sm ml-2"
|
||||||
>
|
onClick={() => handleAutofix('dns', dnsIp, dnsPort)}
|
||||||
<Trans>fix</Trans>
|
>
|
||||||
</button>
|
<Trans>fix</Trans>
|
||||||
}
|
</button>
|
||||||
</div>
|
}
|
||||||
|
</div>
|
||||||
|
<div className="text-muted mb-2">
|
||||||
|
<p className="mb-1">
|
||||||
|
<Trans>autofix_warning_text</Trans>
|
||||||
|
</p>
|
||||||
|
<Trans components={[<li key="0">text</li>]}>
|
||||||
|
autofix_warning_list
|
||||||
|
</Trans>
|
||||||
|
<p className="mb-1">
|
||||||
|
<Trans>autofix_warning_result</Trans>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</Fragment>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,9 +4,12 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@ -143,20 +146,34 @@ func checkDNSStubListener() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const resolvedConfPath = "/etc/systemd/resolved.conf.d/adguardhome.conf"
|
||||||
|
const resolvedConfData = `[Resolve]
|
||||||
|
DNS=127.0.0.1
|
||||||
|
DNSStubListener=no
|
||||||
|
`
|
||||||
|
const resolvConfPath = "/etc/resolv.conf"
|
||||||
|
|
||||||
// Deactivate DNSStubListener
|
// Deactivate DNSStubListener
|
||||||
func disableDNSStubListener() error {
|
func disableDNSStubListener() error {
|
||||||
cmd := exec.Command("sed", "-r", "-i.orig", "s/#?DNSStubListener=yes/DNSStubListener=no/g", "/etc/systemd/resolved.conf")
|
dir := filepath.Dir(resolvedConfPath)
|
||||||
log.Tracef("executing %s %v", cmd.Path, cmd.Args)
|
err := os.MkdirAll(dir, 0755)
|
||||||
_, err := cmd.Output()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("os.MkdirAll: %s: %s", dir, err)
|
||||||
}
|
|
||||||
if cmd.ProcessState.ExitCode() != 0 {
|
|
||||||
return fmt.Errorf("process %s exited with an error: %d",
|
|
||||||
cmd.Path, cmd.ProcessState.ExitCode())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = exec.Command("systemctl", "reload-or-restart", "systemd-resolved")
|
err = ioutil.WriteFile(resolvedConfPath, []byte(resolvedConfData), 0644)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("ioutil.WriteFile: %s: %s", resolvedConfPath, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = os.Rename(resolvConfPath, resolvConfPath+".backup")
|
||||||
|
err = os.Symlink("/run/systemd/resolve/resolv.conf", resolvConfPath)
|
||||||
|
if err != nil {
|
||||||
|
_ = os.Remove(resolvedConfPath) // remove the file we've just created
|
||||||
|
return fmt.Errorf("os.Symlink: %s: %s", resolvConfPath, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd := exec.Command("systemctl", "reload-or-restart", "systemd-resolved")
|
||||||
log.Tracef("executing %s %v", cmd.Path, cmd.Args)
|
log.Tracef("executing %s %v", cmd.Path, cmd.Args)
|
||||||
_, err = cmd.Output()
|
_, err = cmd.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user