Debian 系统 IP 和 DNS 配置, 解决 resolv.conf 文件导致的问题
IP 配置
/etc/network/interfaces
auto eth0
iface eth0 inet static
address x.x.x.x
netmask 255.255.255.0
gateway x.x.x.x
#dns-nameservers 没有用
DNS配置
修改文件/etc/systemd/resolved.conf
DNS=8.8.8.8 8.8.4.4
重启 systemd-resolved
systemctl restart systemd-resolved
resolvectl status
systemctl enable systemd-resolved.service
如果 /etc/resolv.conf 不存在
ln -f -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
测试
# ping mirrors.tuna.tsinghua.edu.cn
PING bfdmirrors.s.tuna.tsinghua.edu.cn (101.6.15.130) 56(84) bytes of data.
64 bytes from 101.6.15.130 (101.6.15.130): icmp_seq=1 ttl=42 time=3.31 ms
64 bytes from 101.6.15.130 (101.6.15.130): icmp_seq=2 ttl=42 time=3.10 ms
================# 水平有限 欢迎指正 #=================