连接 0.0.0.0/32 发生了什么

简介: 根据RFC 3330, 1700 的描述, 0.0.0.0/32 可以用作当前网络的源地址。 0.0.0.0/8 - Addresses in this block refer to source hosts on "this" network. Address 0.0.0.0/32

根据RFC 3330, 1700 的描述, 0.0.0.0/32 可以用作当前网络的源地址。

0.0.0.0/8 - Addresses in this block refer to source hosts on "this" network.  
Address 0.0.0.0/32 may be used as a source address for this host on this network; 
other addresses within 0.0.0.0/8 may be used to refer to specified hosts on this network.
[RFC1700, page 4].

0.0.0.0/32 作为目标地址使用时,与127.0.0.1含义一样。
但是0.0.0.0还有更多的含义,如下

IP address numbers in Internet Protocol (IP) version 4 (IPv4) range from 0.0.0.0 up to 255.255.255.255. The IP address 0.0.0.0 has several special meanings on computer networks. It cannot be used as a general-purpose device address, however.

IPv6 networks have a similar concept of an all-zeros network address.

0.0.0.0 on Clients

PCs and other client devices normally show an address of 0.0.0.0 when they are not connected to a TCP/IP network. A device may give itself this address by default whenever they are offline. It may also be automatically assigned by DHCP in case of address assignment failures.  When set with this address, a device cannot communicate with any other devices on that network over IP.

0.0.0.0 can also theoretically set as a device's network (subnet) mask rather than its IP address. However, a subnet mask with this value has no practical purpose. Both the IP address and network maskare typically assigned as 0.0.0.0 on a client together.  

Software Application and Server Uses of 0.0.0.0
Some devices, particularly network servers, possess more than one IP network interface. TCP/IP software applications use 0.0.0.0 as a programming technique to monitor network traffic across all of the IP addresses currently assigned to the interfaces on that multi-homed device.

While connected computers do not use this address, messages carried over IP sometimes include 0.0.0.0 inside the protocol header when the source of the message is unknown.

The Use of 0.0.0.0 vs. 127.0.0.1 on Local Networks

Students of computer networks sometimes confuse the usages of 0.0.0.0 and 127.0.0.1 on IP networks. Whereas 0.0.0.0 has several defined uses as described above, 127.0.0.1 has the one very specific purpose of allowing a device to send messages to itself.

Troubleshooting IP Address Problems with 0.0.0.0

If a computer is properly configured for TCP/IP networking yet still shows 0.0.0.0 for an address, try the following to troubleshoot this problem and obtain a valid address:

On networks with dynamic address asssignment support, release and renew the computer's IP address. Failures with DHCP assignment can be intermittent or persistent. If the failures persist, troubleshoot the DHCP server configuration: Common causes of failure include having no available addresses in the DHCP pool.
For networks that require static IP addressing, configure a valid IP address on the computer.

0.0.0.0/32 可以用来表示当前网络,与0.0.0.0建立连接,实际上是与回环地址建立连接。

如下

# ping 0.0.0.0
PING 0.0.0.0 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.018 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.033 ms

如果把回环地址shutdown,连接0.0.0.0会不行.

# ifdown lo

$ psql -h 0.0.0.0
psql: could not connect to server: Connection timed out
        Is the server running on host "0.0.0.0" and accepting
        TCP/IP connections on port 1921?

# ping 0.0.0.0
PING 0.0.0.0 (127.0.0.1) 56(84) bytes of data.
^C
--- 0.0.0.0 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 1999ms

所以连接0.0.0.0匹配的PostgreSQL服务端的pg_hba.conf条目是127.0.0.1/32。而不是0.0.0.0/0 。

pg_hba.conf
host all all 127.0.0.1/32  trust

参考
https://www.rfc-editor.org/rfc/rfc1700.txt
https://www.rfc-editor.org/rfc/rfc3330.txt
http://compnetworking.about.com/od/workingwithipaddresses/g/0_0_0_0_ip-address.htm

目录
相关文章
Python使用ffmpeg下载m3u8拼接为视频
Python使用ffmpeg下载m3u8拼接为视频
|
5月前
|
缓存 并行计算 搜索推荐
快速排序还有哪些优化手段
快速排序性能依赖基准选择与分区策略,常见优化包括随机基准、三数取中、小规模插入排序、尾递归优化、三路快排、并行化、混合排序等,提升效率与稳定性,适用于不同场景,使快排成为高效排序算法之一。
224 0
|
存储 测试技术 Linux
【Docker项目实战】使用Docker部署Radicale日历和联系人应用
【10月更文挑战第4天】使用Docker部署Radicale日历和联系人应用
773 2
【Docker项目实战】使用Docker部署Radicale日历和联系人应用
|
缓存 算法 网络协议
一文详细理解计算机网络 - 数据链路层(考试和面试必备)
这篇文章详细介绍了计算机网络中数据链路层的概念、基本问题、点对点信道和广播信道的数据链路协议(如PPP和CSMA/CD),以及局域网和以太网的相关知识。
3036 0
一文详细理解计算机网络 - 数据链路层(考试和面试必备)
|
安全 Unix Linux
Linux 下的 10 个 PDF 软件
Linux 下的 10 个 PDF 软件
|
存储 Prometheus 监控
当 OpenTelemetry 遇上阿里云 Prometheus
本文以构建系统可观测为切入点,对比 OpenTelemetry 与 Prometheus 的相同与差异,重点介绍如何将应用的 OpenTelemetry 指标接入 Prometheus 及背后原理以及介绍阿里云可观测监控 Prometheus 版拥抱 OpenTelemetry及相关落地实践案例。
93905 95
|
缓存
计算机网络——数据链路层-可靠传输的实现机制:选择重传协议SR(介绍、工作原理、窗口尺寸、题目练习)
计算机网络——数据链路层-可靠传输的实现机制:选择重传协议SR(介绍、工作原理、窗口尺寸、题目练习)
1327 1
|
安全 网络安全 数据安全/隐私保护
|
设计模式 消息中间件 Java
Java 设计模式:探索发布-订阅模式的原理与应用
【4月更文挑战第27天】发布-订阅模式是一种消息传递范式,被广泛用于构建松散耦合的系统。在 Java 中,这种模式允许多个对象监听和响应感兴趣的事件。
745 2
|
文字识别 API 开发工具
文字识别OCR常见问题之本地化部署如何解决
文字识别OCR(Optical Character Recognition)技术能够将图片或者扫描件中的文字转换为电子文本。以下是阿里云OCR技术使用中的一些常见问题以及相应的解答。
649 2