0.0.0.0 is a valid IP address?

Is 0.0.0.0 a valid IP address? I want my program to be able to store it as an indication that the address is not in use, but this will not work if it really is.

+53
networking ip
Sep 07 '10 at 4:14
source share
10 answers

It is valid because it contains four octets, each of which ranges from 0 to 255 inclusive. However, it cannot be used as a real IP address.

RFC1700 (a) states that 0.0.0.0/8 ( 0.<anything>.<anything>.<anything> ) is reserved as soon as the source address. You may find yourself in a situation where it seems that you have this address, but this is normal because you do not have an address assigned (for example, DHCP).

See also Wikipedia entry on IPv4 .




(a) Although this RFC is now considered obsolete, it is still correct in terms of this behavior. Its replacement, https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml , still has the same text as using the address 0.0.0.0.

+47
Sep 07 '10 at 4:19
source share

Yes, this is an IP address , but it is reserved.

0.0.0.0/8 - Addresses in this block refer to the source hosts on the "this" network. The address 0.0.0.0/32 can be used as the source address for this host on this network; other addresses within 0.0.0.0/8 can be used to refer to specified hosts on this network

+7
Sep 07 '10 at 4:27
source share

0.0.0.0 used to bind all IPv4 interfaces. Therefore, this is a special meaning, like 127.0.0.1 .

+7
Sep 07 '10 at 4:33
source share

Let's look at the question asked here by the OP.

Is 0.0.0.0 a valid IP address?

Yes. Technically, this is a valid IP address, and other answers describe a lot of its options (I'm not going to publish Wikipedia links here ... or maybe it is).

So, I think the paxdiablo answer above is the most correct, but let's also look at the context of your question.

I want my program to be able to save it as an indication that no address is being used, but this will not work if it is really valid.

It completely depends on your use case. Given that this is a forum for programmers, let's look at this perspective.

If your software stores valid Internet addresses - server locations, visitors to your site, replication / mirroring or backup sites, web services or database servers, etc. - then it will be quite acceptable. No device on the Internet will ever be assigned this address, nor will it ever be converted to a valid connection.

On the other hand, if you are writing firmware for a firewall or router, this address takes on special significance; default route, accept any source / destination IP, block all IP source / destination, end-to-end control, etc., as indicated by all others. However, let me point out that if you are programming at this level, you should have a good enough understanding of network protocols so that you do not need to ask this question first.

Therefore, I’m going to suggest that most people looking at this question fall into the first category, and assume that this is a perfectly correct way to store a null, empty or missing IP address if there is any reason why the actual null value cannot to be used. Even if you neglect validation and your software tries to connect to this IP address, it simply cannot establish a connection.

+6
Aug 31 '15 at 23:14
source share

It is reserved as the default address .

This is usually visible with ipconfig if you are not assigned an address.

+3
07 Sep '10 at 4:22
source share

You can use it in your application to imagine that it does not have an IP address, Microsoft also uses 0.0.0.0 if the computer does not have an IP address.

The β€œvalid” scenarios mentioned above depend on the specific scenarios in which they have nothing to do with your application.

+1
Sep 07 '10 at 6:11
source share

for all purposes and goals, yes. Each of the four numbers, separated by a period, has a value from 0 to 255, so 0.0.0.0 is technically sound.

I do not think that there will be someone in the world who really has this IP address.

EDIT: OK, it is reserved for the default route, but it is still valid.

0
Sep 07 '10 at 4:18
source share

sure. it will not be valid for a single host on the network. It is in the broadcast range for the local network. read here: http://tools.ietf.org/html/rfc1700

0
May 25 '11 at 12:30 a.m.
source share

Running a Network Whois query can also produce output, which is quite useful.
Example:
http://whois.arin.net/rest/nets;q=0.0.0.0?showDetails=true

Comment: The address 0.0.0.0 can only be used as the address of an outgoing packet when the computer learns which IP address it should use. It is never used as the destination address. Addresses starting with "0." sometimes used to broadcast directly connected devices.

0
Nov 21 '14 at 9:13
source share

As already mentioned in other answers, 0.0.0.0 is a legal and valid IP address for some purposes.

If all values ​​in the range are valid values, then any flag elements you want to specify must be from somewhere else. Otherwise, you will overload the valid value with the flag value, and when using the overloaded value it will be impossible to 100% determine whether the valid value or the value of the flag was intended. This will lead to errors that need to be fixed with a coefficient that can be costly.

Valid values ​​are constantly overloaded, IP addresses and MAC addresses (yes, 00: 00: 00: 00: 00: 00 are allowed and allocated) are some of the most common victims.

Coincidentally, I am currently working on a system (not based on Ethernet / IP) where the frame length is limited to about 40 bytes. Since a byte can represent lengths from 0 to 255 bytes, and the maximum length is 40 bytes, I can use some of the unused, in other words, invalid values ​​(from 252 to 255) to represent the elements of the flag. These in-band flags are ok because there is no overload.

0
Jun 07 '19 at 16:28
source share



All Articles