---
title: "防止DHCP获取的DNS修改/etc/resolv.conf文件"
author: "kabike"
date: "2018-05-20T11:28:56Z"
tags: []
categories: ["开源软件"]
slug: "dhcp-dns-etc-resolv-conf"
draft: false
lastmod: "2018-05-20T11:28:56Z"
id: 2423147
url: "https://kabike.iteye.com/blog/2423147"
---

想在centos系统中使用DHCP分配IP,但是使用自定义的DNS服务器,这时重启时会将DHCP获得的DNS服务器写到/etc/resolv.conf文件中,优先使用DHCP的DNS
想使用自定义的DNS服务器,可以修改/etc/sysconfig/network-scripts中的配置文件,设置PEERDNS=no,将需要的DNS用DNS1和DNS2设置
官方文档
<https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/s1-networkscripts-interfaces>