/etc/resolv.conf重启失效的问题

# 问题:
    echo -e "nameserver 223.5.5.5\nnameserver 8.8.8.8\nnameserver 114.114.114.114" > /etc/resolv.conf
    添加了nameserver,重启服务器发现添加的nameserver配置丢失
# 原因:所有网卡配置未设置PEERDNS=no
    cd /etc/sysconfig/network-scripts
    # 显示未匹配到的
    grep -L "PEERDNS" ifcfg-eth*
    # 显示匹配到的
    grep -l "PEERDNS" ifcfg-eth*
# 解决办法:
    grep -L "PEERDNS" ifcfg-eth* | xargs sed -i '$a\PEERDNS=no'
    grep -l "PEERDNS" ifcfg-eth* | xargs sed -i '/PEERDNS/c\PEERDNS=no'

You may also like...

发表评论