Skip to content

Commit

Permalink
Fix resolvconf default dns
Browse files Browse the repository at this point in the history
  • Loading branch information
xinnige committed Nov 6, 2024
1 parent 7e036e4 commit d406b32
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions plugins/dhcp/dhcp6_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
'use strict';

const pl = require('../plugin_loader.js');
const event = require('../../core/event.js');
const r = require('../../util/firerouter.js');
const fs = require('fs');
const Promise = require('bluebird');
Expand Down Expand Up @@ -51,7 +50,7 @@ class DHCP6Plugin extends DHCPPlugin {

if (nameservers.length > 0){
content.push(`dhcp-option=tag:${iface},option6:dns-server,${nameservers.map(a => `[${a}]`).join(",")}`);
} else { // return router's link-local address as RDNSS option in ra
} else { // return global address as RDNSS option in ra
content.push(`dhcp-option=tag:${iface},option6:dns-server,[::]`);
}

Expand Down
4 changes: 4 additions & 0 deletions plugins/interface/intf_base_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,10 +643,14 @@ class InterfaceBasePlugin extends Plugin {
let dnsservers = [];
if (this.networkConfig.nameservers && this.networkConfig.nameservers.length > 0 && this.networkConfig.nameservers.some(s => new Address4(s).isValid())) {
dnsservers = this.networkConfig.nameservers.filter(s => new Address4(s).isValid());
} else {
dnsservers = await this.getOrigDNSNameservers();
}

if (this.networkConfig.dns6Servers && this.networkConfig.dns6Servers.some(s => new Address6(s).isValid())) {
dnsservers = dnsservers.concat(this.networkConfig.dns6Servers.filter(s => new Address6(s).isValid()));
} else {
dnsservers = dnsservers.concat(await this.getOrigDNS6Nameservers());
}
if (dnsservers.length > 0) {
let nameservers = dnsservers.map((nameserver) => `nameserver ${nameserver}`).join("\n") + "\n";
Expand Down

0 comments on commit d406b32

Please sign in to comment.