我有以下不起作用的行:
ssh -o StrictHostKeyChecking=no -o BatchMode=yes -o ConnectTimeout=5 root@$serverip "echo 'nameserver 1.1.1.1' > /etc/resolv.conf && sudo systemctl restart resolvconf.service"
我想,我需要以某种方式将名称服务器 1.1.1.1 放在其他类型的引用中。smb 可以帮忙吗?
答案1
赶紧跑cat /etc/resolv.conf
。
$ 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
您的命令有效。但是您的调用systemctl restart resolvconf
会再次覆盖您的更改。您需要正确配置 resolvconf,而不是写入/etc/resolv.conf
。