Skip to content

Commit

Permalink
Ensure that dnsmasq uses /etc/resolv.conf.
Browse files Browse the repository at this point in the history
Older configs use /tmp/resolv.conf.d/resolv.conf.auto which is blank for a mesh router.
  • Loading branch information
thosmos committed Oct 5, 2023
1 parent f799b81 commit ebe8c94
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions rita_client/src/rita_loop/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,9 @@ pub fn update_dns_conf() {
(Err(e), _) => error!("Failed to get dns server list? {:?}", e),
(_, Err(e)) => error!("Failed to get router internal ip {:?}", e),
}

// check to make sure DHCP is using the correct resolv.conf file
ensure_dhcp_resolvfile();
}
}

Expand All @@ -409,6 +412,34 @@ fn overwrite_dns_server_and_restart_dhcp(key: &str, ips: Vec<IpAddr>) {
}
}

/// Ensures that DHCP is using the correct resolv.conf file
fn ensure_dhcp_resolvfile() {
const DHCP_RESOLV_FILE_KEY: &str = "dhcp.@dnsmasq[0].resolvfile";
const DHCP_RESOLV_FILE_VALUE: &str = "/etc/resolv.conf";

match KI.get_uci_var(DHCP_RESOLV_FILE_KEY) {
Ok(resolv_file) => {
if resolv_file != DHCP_RESOLV_FILE_VALUE {
let res = KI.set_uci_var(DHCP_RESOLV_FILE_KEY, DHCP_RESOLV_FILE_VALUE);
if let Err(e) = res {
error!("Failed to set dhcp resolvfile {:?}", e);
return;
}
let res = KI.uci_commit(DHCP_RESOLV_FILE_KEY);
if let Err(e) = res {
error!("Failed to set dhcp resolvfile {:?}", e);
return;
}
let res = KI.openwrt_reset_dnsmasq();
if let Err(e) = res {
error!("Failed to restart dhcp config with {:?}", e);
}
}
}
Err(e) => error!("Failed to get dhcp resolvfile {:?}", e),
}
}

fn parse_list_to_ip(
input: Result<String, KernelInterfaceError>,
) -> Result<Vec<IpAddr>, KernelInterfaceError> {
Expand Down

0 comments on commit ebe8c94

Please sign in to comment.