Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to revert the changes of dns agent? #12

Closed
hinogi opened this issue Jul 16, 2024 · 2 comments
Closed

How to revert the changes of dns agent? #12

hinogi opened this issue Jul 16, 2024 · 2 comments

Comments

@hinogi
Copy link

hinogi commented Jul 16, 2024

How can I let WSL2 generate the resolv.conf again?

@jacob-pro
Copy link
Owner

Hi @hinogi

The main change is this option: generateResolvConf in /etc/wsl.conf, you need to revert this to true.

https://learn.microsoft.com/en-us/windows/wsl/wsl-config#network-settings

For reference this is the changes this tool makes:

if needs_update {
log::warn!("Updating {} for {}", WSL_CONF, distribution.name);
config.set("network", "generateResolvConf", Some("false".to_string()));
let new_conf = config.writes().replace("\r\n", "\n");
distribution.write_file(WSL_CONF, &new_conf)?;
// Distribution needs to be restarted to take effect
distribution.terminate()?;
}
}
// Replace the /etc/resolv.conf file
// Removing read only is expected to fail if the file doesn't exist
// Read only needs to be set because of bug:
// https://github.com/microsoft/WSL/issues/6977
distribution.set_read_only(RESOLV_CONF, false).ok();
distribution.write_file(RESOLV_CONF, resolv)?;
distribution.set_read_only(RESOLV_CONF, true)?;

@hinogi
Copy link
Author

hinogi commented Jul 22, 2024

thx

@jacob-pro jacob-pro pinned this issue Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants