-
Notifications
You must be signed in to change notification settings - Fork 51
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
Does not work when server pushes multiple dhcp-options #10
Comments
This is my workaround for now. #!/usr/bin/env -S npx zx --experimental
// Switch to the .openvpn folder
await $`mkdir -p ~/.openvpn`;
cd(`${process.env.HOME}/.openvpn`);
// Touch file to make sure this user can read it
await $`touch openvpn.log`;
// If we are running as root, we do not need to use sudo
let sudo_cmd = "";
if (process.getuid() !== 0) {
sudo_cmd = "sudo";
}
// Start openvpn
await $`${sudo_cmd} openvpn --config ~/.openvpn/client.ovpn --log ~/.openvpn/openvpn.log --daemon`;
const checkAuthSucceeded = () =>
$`timeout 60s grep -q 'Initialization Sequence Completed' <(tail -f ~/.openvpn/openvpn.log)`;
// Wait for the VPN to come up
await spinner("Waiting for the VPN to come up...", checkAuthSucceeded);
// openvpn in codespaces does not update /etc/resolv.conf correctly with multiple DNS servers
const manuallyPatchDnsServers = async () => {
const log =
await $`timeout 60s grep 'PUSH: Received control message:' <(cat ~/.openvpn/openvpn.log)`;
const dnsServers = log.stdout
.toString()
.match(/dhcp-option DNS ([0-9.]+).([0-9.]+).([0-9.]+).([0-9.]+)/g)
.map((dnsServer) => dnsServer.replace("dhcp-option DNS ", ""))
.filter((dnsServer) => dnsServer !== "")
.map((dnsServer) => `nameserver ${dnsServer}`);
if (!dnsServers) {
throw new Error("No DNS servers found");
}
// Write the DNS servers to /etc/resolv.conf
for (const dns of dnsServers) {
await $`printf '%s\n%s\n' ${dns} "$(cat /etc/resolv.conf)" | sudo tee /etc/resolv.conf`;
}
return dnsServers;
}
await spinner("Patching resolv.conf manually...", manuallyPatchDnsServers); |
Hello, My team and I were having issues with openvpn not updating the resolv.conf. When trying to edit We were able to solve it just by adding
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Setup my codespace using
Added to my client.ovpn
Confirmed that the script was being called correctly and passed the multiple dhcp-options.
Expected my /etc/resolv.conf to be updated with all of the pushed dhcp-options among other things.
However, my resolv.conf is not updated correctly with multiple
The text was updated successfully, but these errors were encountered: