- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
背景
我们正在尝试在 docker-compose 设置中针对相当复杂的应用程序堆栈运行测试套件。到目前为止,一切都运行良好。但是,我们想确保我们没有遗漏任何外部依赖项或不小心戳到任何我们不应该的东西(例如生产系统)。
这似乎是什么internal
网络选项基本上是为。
问题
使用时 internal: true
在 compose 网络上,容器无法按预期访问任何外部主机。到现在为止还挺好。问题是尝试解析组合网络中不存在的主机名需要很长时间才能超时。 A gethostbyname()
调用最多可能需要 40 秒才能失败,这会以各种方式破坏应用程序堆栈。
我希望能够在网络中配置 DNS 设置,以便直接给我一个 NXDOMAIN
对于不是网络中容器的任何名称,但到目前为止我还没有发现任何迹象表明这是可能的。这似乎是一个明显的用例,我很难相信我是第一个遇到这个问题的人......
我在谷歌上搜索了高低并浏览了我能找到的任何文档,但到目前为止,没有运气。
最少的测试设置
给定一个 docker-compose.yml
:
version: '3'
networks:
default:
internal: true
services:
foo:
image: debian:latest
command: /bin/sleep 1000000000
bar:
build:
context: ./bar
command: /bin/true
bar/Dockerfile
:
FROM debian:latest
RUN apt-get update && apt-get install -y dnsutils bind9-host netcat-openbsd
$ docker-compose up -d
Creating network "foo_default" with the default driver
Creating foo_bar_1 ... done
Creating foo_foo_1 ... done
$ docker-compose run bar bash
root@f7f6bf6b65d4:/# time nslookup foo
Server: 127.0.0.11
Address: 127.0.0.11#53
Non-authoritative answer:
Name: foo
Address: 192.168.96.3
real 0m0.010s
user 0m0.004s
sys 0m0.000s
root@f7f6bf6b65d4:/#
root@f7f6bf6b65d4:/# time nslookup foo.example.com 127.0.0.11
;; connection timed out; no servers could be reached
real 0m15.009s
user 0m0.004s
sys 0m0.004s
root@f7f6bf6b65d4:/#
NXDOMAIN
回复。
root@f7f6bf6b65d4:/# time getent hosts foo.example.com
real 0m40.034s
user 0m0.000s
sys 0m0.000s
root@f7f6bf6b65d4:/#
/etc/resolv.conf
是:
nameserver 127.0.0.11
options ndots:0
/etc/nssswitch.conf
是:
passwd: compat
group: compat
shadow: compat
gshadow: files
hosts: files dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
最佳答案
我已经在我的 Ubuntu 18.04 LTS 上测试了这个设置,但我无法重现您的问题。
我得到:
root@cedfc68cfa30:/# time nslookup foo.example.com 127.0.0.11
Server: 127.0.0.11
Address: 127.0.0.11#53
** server can't find foo.example.com: NXDOMAIN
real 0m0.025s
user 0m0.008s
sys 0m0.016s
关于docker - 使用内部 : true on default docker-compose network leads to slow DNS timeouts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54234328/
我需要为一系列 Linux 容器运行本地 BIND DNS 服务器。假设区域是 example.com 我的基础架构中已经有一个 example.com 域,我想使用我的本地 DNS 服务器覆盖一些记
当“Google Public DNS”免费时,为什么要使用“Google Cloud DNS”? 如何设置 DNS/名称服务器以指向计算引擎: 1. 将您的域注册器(在我的情况下为 GoDaddy.
我有一些主机在 EC2 中按需出现,当它们执行启动它们的服务时,它们会在现有区域下的 Route53 中创建一条 A 记录。 A 记录的格式为:randomid.example.com。所以它不是现有
我目前拥有自己的域名和专用服务器,并且为我的客户提供不同的软件包。我希望能够做的是让他们在我的网站上注册并自动创建一个包,他们可以通过他们的用户名作为子域进行访问,例如 http://youruser
我想知道如何只为一级子域设置通配符 DNS,示例: user.example.com // valid www.user.example.com // invalid 我的 BIND 区域域配
我正在努力将我的域的名称服务器切换到新的 DNS 服务。 将新设置与现有 DNS 设置进行比较的最佳工具是什么。 我尝试使用带有和不带有 @nameserver 的 dig 来确保 DNS 记录在新旧
我是一名长期开发人员,但对 DNS 的经验并不丰富。这是我的问题: 我们的应用程序在 Amazon EC2 上为客户启动服务器。一个客户希望为每台启动的服务器使用自定义 DNS,而不是 AWS 提供的
Closed. This question is off-topic。它当前不接受答案。 想改善这个问题吗? Update the question,所以它是用于堆栈溢出的on-topic。 9年前关
我看到几个提到 DNS 名称(域名)的最大字符串长度为 253 个字符。维基百科似乎指的是这篇旧博文: https://en.wikipedia.org/wiki/Hostname http://bl
这可能是完全不可能实现的,但在我尝试之前,我想我可能会从一位极客那里得到一些建议。 Squid 也会代理 DNS 查询吗?我想转发DNS查询以通过squid并使用squid的DNS错误页面,当然是通过
在我的 Rails 应用程序中,我使用 ruby 库 resolv 进行 nslookup。如果输入像 dgdfgdfgdfg.com 这样的网站,则说明时间太长而无法解决。在某些情况下,例如 2
我正在研究一个带有每 5 秒刷新一次(轮询)的实时仪表板(Angular Web 应用程序)的场景。 API 位于 Azure 流量管理器之后,如果主要区域发生故障,它将故障转移到第二个区域。请记住,
我正在使用 fortify,它显示了攻击者可以在我尝试在 java 应用程序中获取主机名时进行 DNS 欺骗的漏洞。我有一个解决方案,通过匹配正向 DNS 和反向 DNS 条目可以避免这种情况。但它有
我正在尝试使用 cert-manager 为我的 istio-ingress-gateway 订购证书。为此,我在 AKS 上的 kubernetes 集群 (1.13.7) 上安装了 istio (
我正在尝试创建一个家庭自动化系统,它可以在我工作的白天照看我的狗。我在这个项目中的目标是学习一些关于 DNS、文件服务和 RaspberryPi 的知识。 我的硬件设置是这样的: 1 个 Raspbe
我想在一台服务器上创建一个 Web 界面,以管理另一台服务器上的几个 dns 服务器。 如何以编程方式远程管理绑定(bind) dns 服务器? 我想添加/编辑/删除区域。 我看到有 rndc,但它只
我对 TTL 和传播时间的概念有点困惑,我想澄清一些我没有设法在网上找到具体答案的事情。 AFAIK,TTL(生存时间)表示世界各地的服务器更新特定 DNS 的缓存值所需的(最高)时间。 所以...
我正在尝试学习 kubernetes,并且我已成功在裸机上设置集群(1 节点)、部署服务并通过入口公开它。 我尝试实现 traefik,以获取 Lets 加密证书,但我无法使其工作,并且在调试时我注意
我想以编程方式自动更新我的 DNS 多个域。我在 GoDaddy 上运行 BIND 服务器(在 FreeBSD 上)以及主机域和 DNS。我找不到供 GoDaddy 访问和更新他们托管的 DNS 的
我正在尝试记录 DNS“泄漏”,换句话说,我网站的访问者使用的 DNS 服务器。 如何确定网络请求来自哪个 DNS 服务器到我的服务器(即获取 DNS 泄漏)。本站 dnsleaktest.com是吗
我是一名优秀的程序员,十分优秀!