summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-01-13 21:28:53 +0100
committerTom Gundersen <teg@jklm.no>2014-01-13 21:54:57 +0100
commit5be4d38e31281727b6f45ae869136bb01a1f7790 (patch)
tree13b707ff2040872ef6c4fde4d8de636f02185ef4
parent5681d7fb8be37771c152d21ea6e95597d664e3f1 (diff)
networkd: DHCPv4 - allow opting out of using DNS servers
Setting UseDNS=no will ignore any received DNS servers.
-rw-r--r--man/systemd-networkd.service.xml21
-rw-r--r--src/network/networkd-gperf.gperf1
-rw-r--r--src/network/networkd-link.c13
-rw-r--r--src/network/networkd-network.c4
-rw-r--r--src/network/networkd.h1
5 files changed, 34 insertions, 6 deletions
diff --git a/man/systemd-networkd.service.xml b/man/systemd-networkd.service.xml
index de45d10a78..2c1bbf7de5 100644
--- a/man/systemd-networkd.service.xml
+++ b/man/systemd-networkd.service.xml
@@ -193,6 +193,14 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><varname>DNS</varname></term>
+ <listitem>
+ <para>A DNS server address, which must be in the format described in
+ <citerefentry><refentrytitle>inet_pton</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+ .</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><varname>Bridge</varname></term>
<listitem>
<para>The name of the bridge to add the configured link to.</para>
@@ -233,7 +241,20 @@
prefixlength, if ommitted a full-length host route is assumed.</para>
</listitem>
</varlistentry>
+ </variablelist>
+
+ <para>The <literal>[DHCPv4]</literal> section accepts the following keys:</para>
+
+ <variablelist class='network-directives'>
+ <varlistentry>
+ <term><varname>UseDNS</varname></term>
+ <listitem>
+ <para>When true (the default) the DNS servers received from the DHCP server will
+ be used, and take precedence over any statically configured ones.</para>
+ </listitem>
+ </varlistentry>
</variablelist>
+
</refsect2>
</refsect1>
diff --git a/src/network/networkd-gperf.gperf b/src/network/networkd-gperf.gperf
index 92954a8365..3e20681c30 100644
--- a/src/network/networkd-gperf.gperf
+++ b/src/network/networkd-gperf.gperf
@@ -30,5 +30,6 @@ Address.Address, config_parse_address, 0, 0
Address.Label, config_parse_label, 0, 0
Route.Gateway, config_parse_gateway, 0, 0
Route.Destination, config_parse_destination, 0, 0
+DHCPv4.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp_dns)
Bridge.Description, config_parse_string, 0, offsetof(Bridge, description)
Bridge.Name, config_parse_ifname, 0, offsetof(Bridge, name)
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 5dd8e91007..6186f7f892 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -319,6 +319,7 @@ static void dhcp_handler(sd_dhcp_client *client, int event, void *userdata) {
int r;
assert(link);
+ assert(link->network);
if (link->state == LINK_STATE_FAILED)
return;
@@ -421,11 +422,13 @@ static void dhcp_handler(sd_dhcp_client *client, int event, void *userdata) {
addr = NULL;
rt = NULL;
- r = sd_dhcp_client_get_dns(client, &nameservers);
- if (r >= 0) {
- r = manager_update_resolv_conf(link->manager);
- if (r < 0)
- log_error("Failed to update resolv.conf");
+ if (link->network->dhcp_dns) {
+ r = sd_dhcp_client_get_dns(client, &nameservers);
+ if (r >= 0) {
+ r = manager_update_resolv_conf(link->manager);
+ if (r < 0)
+ log_error("Failed to update resolv.conf");
+ }
}
link_enter_set_addresses(link);
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index f987310011..498dea65fe 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -65,7 +65,9 @@ static int network_load_one(Manager *manager, const char *filename) {
if (!network->filename)
return log_oom();
- r = config_parse(NULL, filename, file, "Match\0Network\0Address\0Route\0", config_item_perf_lookup,
+ network->dhcp_dns = true;
+
+ r = config_parse(NULL, filename, file, "Match\0Network\0Address\0Route\0DHCPv4\0", config_item_perf_lookup,
(void*) network_gperf_lookup, false, false, network);
if (r < 0) {
log_warning("Could not parse config file %s: %s", filename, strerror(-r));
diff --git a/src/network/networkd.h b/src/network/networkd.h
index 607feba0e7..26d7f6baa6 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -85,6 +85,7 @@ struct Network {
char *description;
Bridge *bridge;
bool dhcp;
+ bool dhcp_dns;
LIST_HEAD(Address, static_addresses);
LIST_HEAD(Route, static_routes);