Domain-Name-System

在 NAT 後面執行名稱伺服器

  • July 3, 2017

我有一個來自我的 ISP 的靜態 IP 的網際網路連接。我確實有從它託管的郵件伺服器和網路伺服器。我想要實現的是通過從我的 ISP 獲取另一個靜態 IP 來執行幾個名稱伺服器。我已從本地 IP 地址轉發 TCP 和 UDP 埠,並且 Internet 連接由 pfsense 管理。DNS 解析器和轉發器服務已被禁用。

我嘗試通過 NAT 設置名稱伺服器並為 udp 和 tcp 流量轉發 PORT 53。但是,當我嘗試使用 dig externally 或 internal 查詢我的名稱伺服器上的區域記錄時,我收到錯誤“無法訪問任何伺服器”。是否有任何指南或資訊可以幫助我在 NAT 後面設置名稱伺服器或幫助我解決這個問題?

我的 ISP 已確認他們沒有設置塊或過濾器。我還確認沒有埠被阻止或過濾。名稱伺服器的名稱是 ns1.sitehosters.in。

NS1 上的乙太網配置

auto eth1
iface eth1 inet static
address 192.168.1.12 
netmask 255.255.255.0 
gateway 192.168.1.1(PFSENSE) 
dns-nameservers 8.8.8.8

/etc/bind/named/conf.options

options {
directory "/var/cache/bind";
dnssec-validation auto;
auth-nxdomain no;
listen-on-v6 { any; };
};

ns1 上的 Named.conf.local 文件

nano /etc/bind/named.conf.local
zone "sitehosters.in" {
type master;
allow-transfer {none;};
file"/etc/bind/pri.sitehosters.in"
};

來自下面的 Netstat 輸出:

tcp 0 0 192.168.1.36:domain . LISTEN 1156/named 
tcp 0 0 localhost:domain . LISTEN 1156/named 
tcp 0 0 localhost:953 . LISTEN 1156/named 
udp 0 0 192.168.1.36:domain . 1156/named 
udp 0 0 localhost:domain . 1156/named

PINGDOM 的 DNSCHECK

No name servers found at child.

No name servers could be found at the child. 
This usually means that the child is not configured to answer queries about the zone.

請找到我的路由器配置的一些螢幕截圖,這可能會幫助您為我指明正確的方向。我在管理所有網際網路連接和防火牆的 PC 上使用 pfsense。

在 pfsense 的 wan 埠上使用數據包擷取時,我得到

19:05:02.660753 IP xx.xx.xx.xx.13747 > 8.8.8.8.53: UDP, length 27
19:05:02.669900 IP 8.8.8.8.53 > xx.xx.xx.xx.13747: UDP, length 509
19:05:02.670409 IP xx.xx.xx.xx.63621 > 8.8.8.8.53: UDP, length 44
19:05:02.694125 IP xx.xx.xx.xx.34919 > 8.8.8.8.53: UDP, length 27
19:05:02.704487 IP 8.8.8.8.53 > xx.xx.xx.xx.34919: UDP, length 509
19:05:02.705580 IP xx.xx.xx.xx.11687 > 8.8.8.8.53: UDP, length 44
19:05:02.741893 IP 8.8.8.8.53 > xx.xx.xx.xx.11687: UDP, length 208
19:05:02.741919 IP 8.8.8.8.53 > xx.xx.xx.xx.63621: UDP, length 208

19:13:39.682095 IP 81.143.220.107.51368 > xx.xx.xx.xx.53: tcp 0
19:13:39.682355 IP xx.xx.xx.xx.53 > 81.143.220.107.51368: tcp 0
19:13:39.893583 IP 81.143.220.107.51368 > xx.xx.xx.xx: tcp 0
19:13:39.894893 IP 81.143.220.107.51368 > xx.xx.xx.xx.53: tcp 34
19:13:39.895023 IP xx.xx.xx.xx.53 > 81.143.220.107.51368: tcp 0
19:13:39.895353 IP xx.xx.xx.xx.53 > 81.143.220.107.51368: tcp 155
19:13:40.100199 IP 81.143.220.107.51368 > xx.xx.xx.xx.53: tcp 0
19:13:40.100220 IP 81.143.220.107.51368 > xx.xx.xx.xx.53: tcp 0

intodns.com 的報告說

DNS servers responded   ERROR: One or more of your nameservers did not respond:
The ones that did not respond are: xx.xx.xx.xx

我想到了。ISP 在埠 53 上有一個過濾器,即使它是打開的。必須更改 ISP,因為他們無法刪除塊。感謝大家花時間解決問題

如果您想執行作為 Internet 區域授權的名稱伺服器,則需要使用公共 IP 正確定址。

如果您必須在 NAT 後面放置名稱伺服器,則 NAT 設備必須包含適當的應用層網關 (ALG)。儘管許多 NAT 設備將包含一個適用於對客戶端 IP 地址進行 NAT 的 ALG,但我不知道它們中是否有任何一個是為 NAT SOA 記錄等而建構的。

如果您只有 /32 公共地址,那麼您可以通過外部路由器進行埠轉發,然後通過第二個 NAT 設備將其推送以恢復原始目標 IP 地址。在我的腦海中,這應該可以工作,但我沒有仔細考慮過。

我沒有詳細查看 yopu 配置,但請注意您已將 8.8.8.8 定義為名稱伺服器。除非您想將您的名稱伺服器限制為僅授權,否則您將其設置為 127.0.0.1。

在反射 NATing 兩次不應該是必要的。DNS 伺服器可能需要在其上有一個帶有公共 IP 地址的介面,您可能可以通過介面上的輔助 IP 來實現。

引用自:https://serverfault.com/questions/856446