Skip to content

Reorder /etc/resolv.conf to prefer IPv6 nameservers

License

Notifications You must be signed in to change notification settings

DRiKE/resolvloser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

resolvloser prioritizes IPv6 in your /etc/resolv.conf

resolvloser is a tool with only one goal: reordering the nameservers in /etc/resolv.conf so IPv6 nameservers are listed first. It does not touch any other configuration. The lines with the nameserver options are reused, so the structure of the original file is preserved. A header is added so you know something might have changed, and at which date/time.

Pre-compiled binary

If you don't want to build yourself, there is a (x64) binary available on the releases page. It might not be complete up to date with HEAD.

Build

It's rust, so get your toolchain up and running with either rustup or the package manager on your OS.

Then, git clone and build from the root of the repo:

cargo build --release

Copy the binary to a place of your liking, for example

# cp ./target/release/resolvloser /usr/sbin/

Usage

resolvloser takes a filename to use as input, or defaults to /etc/resolv.conf otherwise. The reordered file will be output to stdout, or, if -i is passed, the file is modified in-place.

Automate using systemd

Check out the examples directory for example systemd path and service files. Put them in /etc/systemd/system.

The path unit monitors for changes in /etc/resolv.conf, and runs the service unit on file changes. In the service file, make sure the ExecStart points to the resolvloser binary.

# systemctl enable resolvloser.path

On my system, I need the StartLimit configuration in the service file, because some actions (toggling the WiFi radio) cause many triggers (like 6 or so). Without these specific options, systemd rate limits the service. YMMV.

Other ways

Any other place where you can create some kind of hook, you should be able to use resolvloser. Other example configurations are welcome. If you want to alter /etc/resolv.conf in place, remember that you need root permissions. To simply see what resolvloser does with your resolv.conf, run without -i.

$ resolvloser -h

resolvloser v0.1.0
Unrecognized option: 'h'
Usage: resolvloser RESOLVCONF_FILE [options]

Options:
    -i                  modify in-place (otherwise output on stdout)

Why?

I fought resolv but could not get it to do what I wanted: I was a resolvloser. I simply wanted to have IPv6 addresses listed first, but could not find an option anywhere. Given that there are many different pieces of software that alter /etc/resolv.conf, a simple tool to reorder afterwards seems more pragmatic than patching all the other moving parts. And it was another excuse to write some Rust.

About

Reorder /etc/resolv.conf to prefer IPv6 nameservers

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages