summaryrefslogtreecommitdiff
path: root/src/network/networkd-link.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-01-05 23:01:10 +0100
committerTom Gundersen <teg@jklm.no>2014-01-12 15:37:21 +0100
commit3bef724f7e7f7eaca69881548b06e221b77d7031 (patch)
tree0b17e5a43d7e5c5d07dc696d23d4c829f9ab7200 /src/network/networkd-link.c
parent924fe4304af981ffd849346b4a1d415f11e9dd79 (diff)
networkd: generate resolv.conf
This adds support to generate a basic resolv.conf in /run/systemd/network. This file will not take any effect unless a symlink is created from /etc/resolv.conf. Nameservers received over DHCP takes precedence over statically configured ones. Note: /etc/resolv.conf is severely limited, so in the future we will likely rather provide a much more powerfull nss plugin (or something to that effect), but this should allow current users to function without any loss of functionality.
Diffstat (limited to 'src/network/networkd-link.c')
-rw-r--r--src/network/networkd-link.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 25d92c8aa4..5dd8e91007 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -378,6 +378,7 @@ static void dhcp_handler(sd_dhcp_client *client, int event, void *userdata) {
if (event == DHCP_EVENT_IP_CHANGE || event == DHCP_EVENT_IP_ACQUIRE) {
_cleanup_address_free_ Address *addr = NULL;
_cleanup_route_free_ Route *rt = NULL;
+ struct in_addr **nameservers;
log_struct_link(LOG_INFO, link,
"MESSAGE=%s: DHCPv4 address %u.%u.%u.%u/%u via %u.%u.%u.%u",
@@ -420,6 +421,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");
+ }
+
link_enter_set_addresses(link);
}