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

Accessing servers with public IP from private networks without NAT

· 52CE 我爱测

Is it possible, from a private network, to access to a public server (i.e., a server with a public IP address) without a NAT? In other word, can an Intranet provide public services, if I give public addresses to server and privat…

问题原文

原帖链接 · mgiordi · CC BY-SA 4.0

Is it possible, from a private network, to access to a public server (i.e., a server with a public IP address) without a NAT? In other word, can an Intranet provide public services, if I give public addresses to server and private addresses to hosts in the Intranet?

已采纳解答

原帖链接 · Ruscal · CC BY-SA 4.0

No.

The private network will most likely be able to send a packet out to the public IP addresses (assuming the private network has a properly configured router with an interface both on the public internet and the private internal network). But the server on the public internet will not be able to send a reply back to the not-NAT-ed private network, quite simply because the server will have no idea where to send that response data.

For computers to speak IP to one another on a network they have to know the IP address of the other person they're talking to, and what the next step is for getting to that IP address. If the IP address is in the same subnet, then your computer will just ask "who has IP address w.x.y.z" on the local subnet and then will talk directly to the computer that responds. If the IP isn't on the same subnet, then the computer will follow the instructions in its routing table (normally, send the packet to the local router listed as the "default gateway" in the IP configurations).

Each inter-networking node (normally a routers at this point) that receives the packet will look at the destination IP address and make a similar determination of who is the next hop in the chain that will deliver this packet to the final destination. On and on, until it finally arrives where it is supposed to.

But that all relies upon the destination being listed in the packet header (as is required in the IP protocol) and that the gateways & routers know how to send data to the network that IP belongs to. If you have a non-NAT-ed private IP address, then those routers won't know how to deliver the packet, and they'll discard it. It becomes the electronic equivalent of a "dead letter" that just disappears forever.

What a NAT does is use a public IP address (or addresses) as a front-man to broker the communications for your private network. When it sees outbound traffic, it alters the "reply to me at this address" portion of the headers to use its own public IP; and the NAT device keeps a lookup table of who it is relaying communications for so that when the responses come in he can forward them on to the proper IP on the private network. Without that address translation function, a computer on a private network cannot talk TCP/IP with a computer on the public internet.

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

资料来源与适用范围

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

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

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