大网数据广告活动
服务器运维问答

How to I make a domain resolve to different IP's when resolved from internal network and external network?

· 52CE 我爱测

So I looked through BIND and Dnsmasq and unable to figure this out. I have a few of servers on DigitalOcean, and they are on the same datacenter. I want to be able to use internal IPs to get better intra network pings and (obviou…

问题原文

原帖链接 · Arnav Gupta · CC BY-SA 3.0

So I looked through BIND and Dnsmasq and unable to figure this out.

I have a few of servers on DigitalOcean, and they are on the same datacenter. I want to be able to use internal IPs to get better intra network pings and (obviously, free private network traffic). Given the following two servers:

Name   Public IP          Private IP
srv1   192.0.2.1          10.10.10.1
srv2   198.51.100.2       10.10.10.2

When digging from external network (say my laptop), I want something like this

account.codingblocks.com. 79    IN  CNAME   srv2.cb.lk.
srv2.cb.lk.               85844 IN  A       198.51.100.2

When digging from inside srv1, I want this instead

account.codingblocks.com. 79    IN  CNAME   srv2.cb.lk.
srv2.cb.lk.               85844 IN  A       10.10.10.2

Is this possible ? If yes, how.

已采纳解答

原帖链接 · telcoM · CC BY-SA 3.0

In BIND 9, you can define multiple "views": in effect, BIND shows one version of a DNS zone to specified clients and another version to others. This seems to be exactly what you'll need.

Here is a nice introduction to using views in BIND 9: https://kb.isc.org/article/AA-00851/0/Understanding-views-in-BIND-9-by-example.html

In your case, though, the external view would say:

match-clients { any; };

rather than specifying any network segments.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-12-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。