root@debian2:~# vi /etc/network/interfaces
auto ens32
iface ens32 inet static
address 10.10.70.3
netmask 255.255.255.0
gateway 10.10.70.254
dns-nameserver 10.10.70.2
安装resolvconf软件包
root@debian2:~# apt install resolvconf
重启网卡
root@debian2:~# systemctl restart networking
查看dns自动添加到配置文件里 了
root@debian2:~# cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "resolvectl status" to see details about the actual nameservers.
nameserver 10.10.70.2
search skills.com localdomain