从resolv.conf中删除EC2的条目

Tak*_*ama 8 debian amazon-ec2 resolve

我有私人的DNS服务器,我想给他们写信给resolv.confresolvconf在Debian上AWS/EC2.名称服务器条目的顺序存在问题.在我看来resolv.conf,EC2的默认名称服务器总是写在第一行,如下所示:

# 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 172.16.0.23
nameserver 10.0.1.185
nameserver 10.100.0.130
search ap-northeast-1.compute.internal
Run Code Online (Sandbox Code Playgroud)

172.16.0.23 是EC2的默认名称服务器,其他是我的.

如何删除EC2条目?或者,如何将EC2进入第三名?

这里我有一个接口文件:

% ls -l /etc/resolvconf/run/interface/
-rw-r--r-- 1 root root  62 Jun  7 23:35 eth0
Run Code Online (Sandbox Code Playgroud)

似乎该文件eth0是由dhcp自动生成的,因此无法永久删除它.

% cat /etc/resolvconf/run/interface/eth0
search ap-northeast-1.compute.internal
nameserver 172.16.0.23
Run Code Online (Sandbox Code Playgroud)

我的私人DNS条目在这里:

% cat /etc/resolvconf/resolv.conf.d/base
nameserver 10.0.1.185
nameserver 10.100.0.130
Run Code Online (Sandbox Code Playgroud)

请帮忙.

xol*_*lox 9

我想我刚解决了一个非常类似的问题.我被Amazon EC2糟糕的内部DNS服务器所困扰,所以我想运行一个本地缓存dnsmasq守护进程并使用它/etc/resolv.conf.起初我刚刚做了,echo nameserver 127.0.0.1 > /etc/resolv.conf但后来我意识到在重新启动或DHCP租约刷新后,我的更改最终会被DHCP客户端覆盖.

我现在所做的是编辑/etc/dhcp3/dhclient.conf和取消注释该行prepend domain-name-servers 127.0.0.1;.您应该能够以prepend非常类似的方式使用该指令.

更新:这些说明基于Ubuntu Linux,但我认为一般概念也适用于其他系统,即使其他DHCP客户端也必须具有类似的配置选项.


jor*_*fus 5

我正在从另一个方向接近这个问题(想要内部名称服务器),我学到的很多内容可能都很有趣.

有几个选项可以控制VPC管理控制台中的名称解析.

VPC -> DHCP option sets -> Create dhcp option set
Run Code Online (Sandbox Code Playgroud)

您可以在那里指定自己的名称服务器. http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_DHCP_Options.html 请务必将此dhcp选项集附加到您的VPC以使其生效.

或者(我错误地发现了这一点)如果在VPC设置中禁用了以下设置,则不会设置本地DNS服务器:

DnsHostnames
Run Code Online (Sandbox Code Playgroud)

DnsSupport
Run Code Online (Sandbox Code Playgroud)

http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-dns.html

也可以在本地覆盖设置(如果在vpcs之间移动实例,您会注意到这一点). /etc/dhcp/dhclient.conf

以下行可能会引起关注:

prepend domain-name-servers
Run Code Online (Sandbox Code Playgroud)

当然,更改会对dhclient启动生效.


mon*_*mon 5

如何将静态 DNS 服务器分配给运行 Ubuntu、RHEL 或 Amazon Linux 的私有 Amazon EC2 实例?

\n\n

简短的介绍

\n\n
\n

与 Virtual Private Cloud (VPC) 关联的 EC2 实例的默认行为是在启动时使用动态主机配置协议 (DHCP) 请求 DNS 服务器地址。VPC 使用内部 DNS 服务器的地址响应 DHCP 请求。DHCP 响应中返回的 DNS 服务器地址将写入本地 /etc/resolv.conf 文件并用于 DNS 名称解析请求。当实例重新启动时,对 resolv.conf 文件的任何手动修改都会被覆盖。

\n
\n\n

解决

\n\n
\n

要将运行 Linux 的 EC2 实例配置为使用静态 DNS 服务器条目,请使用文本编辑器(例如 vim)编辑文件 /etc/dhcp/dhclient.conf 并将以下行添加到文件末尾:

\n
\n\n

\nsupersede domain-name-servers xxx.xxx.xxx.xxx, xxx.xxx.xxx.xxx;\n

\n\n

Ubuntu -\xc2\xa0dhclient.conf - DHCP 客户端配置文件\xc2\xa0

\n\n
The supersede statement\n\nsupersede [ option declaration ] ;\n\nIf for some option the client should always  use  a  locally-configured  value  or  values\nrather  than  whatever  is  supplied  by  the  server,  these values can be defined in the\nsupersede statement.\n\nThe prepend statement\n\nprepend [ option declaration ] ;\n\nIf for some set of options the client should use a value you  supply,  and  then  use  the\nvalues  supplied  by  the  server,  if  any,  these  values  can be defined in the prepend\nstatement.  The prepend statement can only be used for options which allow more  than  one\nvalue  to  be  given.   This restriction is not enforced - if you ignore it, the behaviour\nwill be unpredictable.\n\nThe append statement\n\nappend [ option declaration ] ;\n\nIf for some set of options the client should first use the values supplied by the  server,\nif  any,  and  then  use  values  you  supply,  these  values can be defined in the append\nstatement.  The append statement can only be used for options which allow  more  than  one\nvalue  to  be  given.   This restriction is not enforced - if you ignore it, the behaviour\nwill be unpredictable.\n
Run Code Online (Sandbox Code Playgroud)\n