首页 > 系统相关 >Ubuntu虚拟机不能ping提示Temporary failure in name resolution

Ubuntu虚拟机不能ping提示Temporary failure in name resolution

时间:2022-09-28 21:33:36浏览次数:43  
标签:Temporary name 虚拟机 sudo ping sh example

Ubuntu虚拟机不能ping提示Temporary failure in name resolution

问题原因

系统每次重启之后/etc/resolv.conf文件被删除

解决办法

  1. 执行命令sudo systemctl restart systemd-resolved.service
  2. 发现网络已经好了

后续解决

为了减少麻烦,避免每次重启系统都要执行上述命令,我们将此命令加入开机启动脚本中

方法如下:

  1. 首先到/etc/init.d 目录(该目录为启动目录)下,创建example.sh

    cd /etc/init.d
    sudo vim example.sh
    
  2. example.sh中写入以下内容

    #! /bin/bash
    sudo systemctl restart systemd-resolved.service
    exit 0
    
  3. 接着将改shell脚本加入到启动计划中,执行命令sudo update-rc.d example.sh defaults 90,其中90表示优先级,数字越大表示优先级越低,执行的时间越晚。

  4. 如果想要移除这个脚本,执行命令sudo update-rc.d -f example.sh remove

标签:Temporary,name,虚拟机,sudo,ping,sh,example
From: https://www.cnblogs.com/Weber-security/p/16739653.html

相关文章