← 返回命令列表

Linux command

resolvconf 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Update DNS configuration

resolvconf -u

Add interface configuration

echo "nameserver 8.8.8.8" | resolvconf -a [eth0]

Delete interface configuration

resolvconf -d [eth0]

List interfaces

resolvconf -l

Show current resolv.conf

cat /etc/resolv.conf

说明

resolvconf is a framework for dynamically managing the system's DNS resolver configuration in /etc/resolv.conf. Rather than allowing individual network tools to overwrite the file, resolvconf aggregates DNS information from multiple sources such as DHCP clients, VPN connections, and NetworkManager, then generates a unified resolv.conf based on priority ordering. Each network interface registers its DNS servers and search domains through resolvconf using the -a flag, and removes them with -d when the connection terminates. The framework determines the final configuration by combining all registered inputs, with earlier-registered interfaces taking higher priority. Static entries can be added through head and tail configuration files that are prepended or appended to the generated output. Several implementations exist, including openresolv and the Debian resolvconf package, each with slightly different features. On systemd-based systems, systemd-resolved may provide similar functionality and can coexist or conflict with resolvconf depending on configuration.

参数

-a _INTERFACE_
Add/update interface config.
-d _INTERFACE_
Delete interface config.
-u
Update resolv.conf.
-l
List interfaces.
-i _PATTERN_
Include interfaces.
-x _PATTERN_
Exclude interfaces.
-p
Mark interface resolv.conf as private.
-m _metric_
Set interface metric for priority ordering.
-f
Ignore non-existent interface.

FAQ

What is the resolvconf command used for?

resolvconf is a framework for dynamically managing the system's DNS resolver configuration in /etc/resolv.conf. Rather than allowing individual network tools to overwrite the file, resolvconf aggregates DNS information from multiple sources such as DHCP clients, VPN connections, and NetworkManager, then generates a unified resolv.conf based on priority ordering. Each network interface registers its DNS servers and search domains through resolvconf using the -a flag, and removes them with -d when the connection terminates. The framework determines the final configuration by combining all registered inputs, with earlier-registered interfaces taking higher priority. Static entries can be added through head and tail configuration files that are prepended or appended to the generated output. Several implementations exist, including openresolv and the Debian resolvconf package, each with slightly different features. On systemd-based systems, systemd-resolved may provide similar functionality and can coexist or conflict with resolvconf depending on configuration.

How do I run a basic resolvconf example?

Run `resolvconf -u` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -a _INTERFACE_ do in resolvconf?

Add/update interface config.