[轉]resolv.conf 配置資訊重啟後丟失解決方案

來源:互聯網
上載者:User

標籤:http   ar   for   sp   檔案   on   art   問題   bs   

我要配置DNS,修改/etc/resolv.conf,修改後重啟服務 service network restart ,修改/etc/resolv.conf的資訊丟失,請大家看看。

修改前的配置
# No nameservers found; try putting DNS servers into your
# ifcfg files in /etc/sysconfig/network-scripts like so:
#
# DNS1=xxx.xxx.xxx.xxx
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.com

 

解決方案在ifcfg-eth0 直接加入DNS1=xxx.xxx.xxx.xxx,再service network restart 

DEVICE=”eth0″
BOOTPROTO=”static”
HWADDR=”00:0C:29:B5:E4:65″
NM_CONTROLLED=”yes”
ONBOOT=”yes”
IPADDR=192.168.128.133
NETMASK=255.255.255.0
GATEWAY=192.168.128.1
DNS1=222.46.120.6

 

再來查看resolv.conf 多了一行 namerserver xxx.xxx.xxx.xx
# Generated by NetworkManager
nameserver 222.46.120.6

還有方法二:

終於找到一篇文章解決了我的問題:http://tech.techweb.com.cn/archiver/tid-380658.html
文章內容:
vim /etc/resolvconf/resolv.conf.d/head 檔案
顯示與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)
在最後鍵入nameserver 202.102.152.3
儲存退出,
resolvconf -u
此時就可以正常上網了,重啟後不用在重新設定DNS了。

[轉]resolv.conf 配置資訊重啟後丟失解決方案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.