遇到如下无法解析域名的情况的时候,需要设置DNS:
sudo nano /etc/systemd/resolved.conf
例如修改DNS为192.168.18.48与192.168.18.49
执行一下命令使上述修改生效:
sudo systemctl restart systemd-resolved
sudo systemctl enable systemd-resolved
sudo mv /etc/resolv.conf /etc/resolv.conf.bak
sudo ln -s /run/systemd/resolve/resolv.conf /etc/
查看/etc/resolv.conf文件,可以发现刚才的修改已经生效
再次执行命令:
nslookup www.baidu.com
可以发现,已经能成功解析百度: