Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How does tools like ping, or any other tool that uses the tcp/ip protocol know that for example or is a local ip address while or are public? are 192.168.x.x and 10.0.x.x hardcoded to be preserved for local use?

share|improve this question
They do not know it and they do not care. Do you have a specific problem ? – BatchyX Aug 10 '13 at 14:28
@BatchyX I am just trying to understand how things work. And some program somewhere have to care if the adress is a part of the LAN or WAN. – totokaka Aug 10 '13 at 15:09
Why should they care ? – BatchyX Aug 10 '13 at 18:57
up vote 8 down vote accepted

Well, they are reserved by RFC 1918 for use in private networks.

But that doesn't actually matter much. You can obtain a block of "public" IP addresses from RIPE or whatever, and use it for your private network, and everything will still work. The reservation is needed only for political reasons, to allow admins to set up their own private networks without any trouble.

Tools like ping do not care whether an address is "private" or "local" or "public". They simply send a packet to the given address, and your OS looks at the routing table to decide where to send it next.

For example, when you configure an Ethernet card on Windows with IP address (in netmask format: and gateway, it adds the following entries to the routing table:

  • (netmask to interface Loopback

    (Your own addresses are always routed through the loopback interface, they never go to the network.)

  • (netmask to interface Local Area Connection

    (Addresses in your own subnet are, by definition, local.)

  • (netmask to gateway

    (Everything else is not local.)

In other words, you told the OS that all addresses within the range are local, and the OS takes care of everything.

To view the routing table:

  • on Linux, ip route (IPv4) and ip -6 route (IPv6)
  • on Windows, route print (IPv4 on ≤XP, both v4/v6 on ≥Vista)
  • on Windows XP, netsh interface ipv6 show route (IPv6)
  • on Windows, Linux, BSD, and other Unix-likes, netstat -r -n (IPv4)
  • on Linux and some Unix-likes, netstat -r -n -6 (IPv6)

Editing the routing table can be done with the same tools. For example, to mark all of as local, you can use ip route add dev eth0 on Linux.

share|improve this answer
Aha, this explains much. I'll accept the answer tomorrow if no better answer has come. Thank you! – totokaka Aug 10 '13 at 15:07
It might be worth mentioning that you can also manually edit the routing table. It isn't often needed, but can be very useful sometimes. – Michael Kjörling Aug 10 '13 at 15:48
What can you get out of changing the routing table? – totokaka Aug 10 '13 at 16:04
@totokaka: It's really not as useful on hosts as it is on routers (or on PCs working as routers), but it still has some use – for example, if you have multiple Internet connections, or are connected to a VPN, you could tell the OS that you only want to access a few corporate servers over the VPN but not everything else – instead of all-or-nothing. – grawity Aug 10 '13 at 16:25

Public and private IP addresses are defined in RFC. These are private IP addresses:

Also these IP addresses are loopback:

Others are public.

Most of tools does not need to know public or private IP addresses.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .