If my machine has a public ip address, then any one from any corner of the world can access this ip address. How does this happen? I mean where is my ip address updated or where does the requester see if my ip address is a valid one or not?
2 Answers
IP Addresses are like telephone numbers, and the Internet routers like telephone exchanges.
Let's assume my phone number is 333-1234. The "333" part is the exchange ID. If I dial 333-4567, the exchange knows that I am trying to reach another phone on the same exchange. It will do a lookup of all subscriber numbers listed in its database, and connect me (assuming the destination number is listed and not busy).
If say I dial 444-2378, my local exchange knows that the number is listed in a different exchange. Depending on the routing table of the local exchange, it will either route the call directly to exchange 444, or employ the help of a 'tandem exchange'.
Let's say my complete phone number is +62-21-333-1234, and I am dialling +1-412-678-4466. My local exchange sees that the destination number is located on a different country. It doesn't have to have a routing table to the USA, but it knows by default it must route the call to the tandem exchange. The tandem exchange also doesn't have a routing table for the USA, so it will route the call to the International exchange. The International exchange does know how to route the call to "+1", but that's it. So, the International exchange sends the call to the 'nearest' International exchange in the USA. The International exchange in the USA has a routing table containing the area codes, and routes the call to the tandem exchange serving the area code. The tandem exchange looks up the route for the local exchange having the ID of 678, and transfers the call there. Finally, the '678' exchange checks for the existence of subscriber number 4466, and attempts to connect the call.
The Internet is similar : your default gateway doesn't have to know how to reach the whole Internet. If it happens upon an address that it doesn't recognize, it will send the packet to a higher-tier router. At the highest tier -- the so-called 'backbone' -- the routers know how to route to all the Internet, but only the leftmost octet of the IP address ("the zone"). Upon entering a zone, the packet gets handled by a router in the zone that knows the route to a part of the zone, and so on, hop by hop the packet gets transferred to a router with smaller 'coverage', but more detailed knowledge, similar to how telephone exchanges work.

- 5,038
- 4
- 47
- 72
Public IP addresses are like phone numbers. With IPv4 addresses like aa.bb.cc.dd, anyone can start to try to knock on the door of each of these and see what services might be available. They can start at 1.1.1.1 go to 1.1.1.2 and so on. Like phone numbers, they can be dialed at anytime and like phone numbers you can determine approximately where in the world the IP address is.
However, if you have a specific IP address for your system and you don't make that IP address known, then if someone who knew you and they wanted to try to find your machine, they'd have to go through all the IP addresses that are out there and have to be able to identify your machine by some service it might be running. A difficult task to say the least. They can shorten the list by know who your ISP provider is, but they still would not be able to easily determine what public IP address is assigned to your computer.
Typically you protect yourself behind a firewall using NAT and this in turn can provide a first layer of protection from direct probing and is usually the standard method used to connect systems to the internet.
Regarding your question about how anyone in the world can get to your IP address, that is the work of routers and your IP address. If we go back to the first example where IP addresses are in the format of aa.bb.cc.dd, I can give this a try to simplfy the explanation, steering clear of the nitty gritty details.
- First there is a layer of routers at "aa". Think of each router as assigned to a network number, being 1-254. So there are 254 of these routers at the top level and these routers only care about the first number.
- When the first router for network "aa" is found, the process repeats at step 1 for "bb", and "cc". "dd" is now only a network of 254 nodes/hosts/computers so that is how a computer in Hong Kong can get to a computer directly in the US.
It can become more complicated than this with lots of nuts and bolts, but it seemed easiest to try to explain it like this.
Hope that helps.

- 881
- 2
- 10
- 15
-
thank you for answering:) When I give the destination ip address as aa.bb.cc.dd, then where does this request go first(I am using a net card i.e connected to the internet through a usb kind of device. So there is no default gateway also) or how does it know where to go? – Ashwin May 13 '12 at 03:01
-
There is always a default gateway or otherwise you'd never be able to communicate beyond your subnet. – EEAA May 13 '12 at 03:42
-
@ErikA : but when I do ipconfig, only the ipv4 address is displayed and the default gateway section is 0.0.0.0 . – Ashwin May 13 '12 at 04:42
-
@Ashwin Your computer is not giving you useful information. You can do a traceroute to see what the next hop is. (The command is `tracert` on Windows.) – David Schwartz May 13 '12 at 05:46
-
2The number of networks in any given class has nothing to do with a particular number of routers. Routers can advertise that they are handling any number of networks. Please edit. – Rapzid May 13 '12 at 06:12
-
1I agree with Rapzid. The last part of the answer is needlessly complicated and generally incorrect. A simpler explanation is this: Routers close to you have routes "up" towards routers with more information about the Internet (a typical home user, for example, gets the packet 'up' to their provider). At some point, you reach a router that knows a route towards the destination's network (core routers exchange this information with each other). The packet eventually reaches a router close to the destination that has a route "down" to the destination. – David Schwartz May 13 '12 at 07:48
-
@DavidSchwartz : yes I did the tracert. what can I infer from that/ – Ashwin May 13 '12 at 11:06
-
You can see the path the packet took, specifically where it went immediately after it left your machine. If you traced the route to a "random" external IP, then the next hop should be your default route. (Assuming your machine doesn't have a full Internet routing table, which it almost certainly doesn't.) – David Schwartz May 13 '12 at 11:10
-
@DavidSchwartz : then why doesn't ipconfig show the default gateway. there is nothing wrong with my machine. I have tried it on other machines and tgey all show the default gateway to be 0.0.0.0 . can it be that the default gateway is hard coded in the internet card(usb). – Ashwin May 13 '12 at 13:37
-
@Ashwin: There are two possible reasons: 1) You may be looking in the wrong place in the `ipconfig` output. There's a separate block for each interface. 2) You may have a default route that's not an interface route, which `ipconfig` won't show. (The `route print` command will show it. It'll be the route with both a destination and netmask of `0.0.0.0`.) – David Schwartz May 13 '12 at 19:10