LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   I was always afraid to ask this question (https://www.linuxquestions.org/questions/linux-general-1/i-was-always-afraid-to-ask-this-question-4175592447/)

snowmagician 10-28-2016 07:32 PM

I was always afraid to ask this question
 
There are many millions of websites and also many millions of users, but each user gets his own unique IP address

How is it possible to let everyone have a different IP address?

256 x 256 x 256 x 256 = I think the result here is not enough to let everyone have a different unique IP address and websites to have a different ip address.

273 10-28-2016 07:41 PM

Not everyone has a unique IP address thanks to NAT, and things like CIDR are used to attempt to make the best of the addresses that there are.
However, we are on the cusp of IP version 4 exhaustion which is why IP version 6 is slowly creeping upon us.

frankbell 10-28-2016 07:41 PM

That's why ipv6 is a thing.

Also, there's this: say you have a little home network or even a larger business network. The network is behind a router. The router has one public ip address, say, 68.xxx.xxx.xxx.

Inside the network, each computer has its own ip address in the subnet. For a home network, that's usually something like 192.168.xxx.xxx. Each computer does not have a public ip address because it's communicating via the router, not directly to the Big Wide World.

The computers in my home network no doubt have the same ip addresses as computers in many other home networks, but, as they are behind a router with a unique public ip address, that's okay. It's called "subnetting."

Here is the best tutorial I've ever seen about subnetting. Don't be put off by the web 1.0 appearance: it's solid, well-presented, and clearly explained: http://www.ralphb.net/IPSubnet/index.html

Sefyir 10-28-2016 07:42 PM

According to this post
http://stackoverflow.com/questions/2...ipv4-addresses

There are 3,706,452,992 public addresses. I also understand that is running out though.

Otherwise, using NAT allows for several computers from one ip address

michaelk 10-28-2016 08:21 PM

Most users have a dynamic IP address. An ISP assigns an address from a block using DHCP when you connect. Even though there are millions of internet capable devices many are not connected on line so DHCP provides a way to release those addresses and assign them to someone else. Although with broadband MODEMS that are always on this does not happen as much.

A home router works in a similar fashion but assigns private addresses.

jefro 10-28-2016 09:32 PM

Many sites use Host headers to direct web pages.

https://russlescai.wordpress.com/201...ers-in-apache/


Depending on the server the method to allow many FQDN's to access a single IP is usually in documents. Some very old servers and web browsers need a special directional web page.

snowmagician 10-29-2016 01:47 PM

Thanks a lot for your awesome and intelligent responses. I have looked up for more information and definitely gained some awesome information.

Two things I am wondering

I learned that gateway is used when a host ( a device on a network ) must send date to another host on another network. Is the gateway address still used when a host needs to send data to another host within the same address?

And I also learned that broadcast address is network address followed by all 1s for example this is a network address 192.168.255.255

The broadcast address is used when a host needs to send a message to ALL devices within network ( hence the name "Broadcast" ) Could you give me a real-world practical example of broadcast address being used? Thanks a lot.

273 10-29-2016 01:51 PM

The gateway IP is only used to communicate with devices outside of the same subnet -- within the same subnet devices communicate using their own IP addresses.
Broadcast messages are sent, for example, when giving a DHCP reply -- that is, an IP address assignment and other details from a server.

273 10-29-2016 03:52 PM

Just to explain my edit, I originally typed that broadcasts are sent when sending a DHCP request (that's what it says in the books) then I realised that before a DHCP request is fulfilled the sending device doesn't know the subnet mask so doesn't know what the address is to send a broadcast to the subnet. I'd never thought of that before as I'd assumed that the request was sent at a lower layer of the stack but I assume now that it's sent to 255.255.255.255 in the expectation that the network is set up in such a way that that packet will reach the nearest DHCP server (logically)?

sundialsvcs 11-02-2016 09:33 AM

Let's consider how you, and all your kids (brothers, sisters) are able to use your home network to communicate with the Internet ... all at the same time, through one outgoing wire.

The network within your home uses one of the private network-address ranges that have been set-aside for this very purpose. (Most likely, it is 192.168.x.x.) There will never be a computer "on the Internet at large" which uses any of these addresses: they are set aside for internal networks.

Your home's internet router probably has the internal address of 192.168.1.1, and, if you issue the route command (or its equivalent for your OS ...) on your computer, you will find this address listed as the default gateway.

What this means is that, in order to communicate with "LinuxQuestions.Org" at its public address of (say) 75.126.162.205, your computer sends the traffic, as it were, through the gateway to get there.

Your router is sitting on two networks at the same time: internal, and The Internet. On the Internet, it has whatever IP-address was assigned by your provider. It routes your LQ traffic to LQ. And, when LQ responds with a beautiful web-page, your router returns the traffic to you. (Not to your sister.)

It does this through a simple trick called NAT = Network Address Translation. The message that is sent to LQ comes from the (public) IP-address assigned by your provider, with a random "port number" chosen on-the-fly by your router. When LQ replies, your router invisibly uses that port-number (which it remembers) to send the traffic to you ... and not to your sister. (It strips-off the port number before sending the data to you.)

The concept of a "port number" is very much like an "extension" in a company telephone exchange that is reached through a single phone-number, but that analogy is a loose one. The port-number in this case simply "is part of the return-address portion of the message," which LQ('s router ...) will send back to your router verbatim.

IP-addresses are not necessarily fixed. Every now and then, your Internet provider might change the IP-address that's used by your router. (It can do this through good ol' DHCP.) Addresses are generally grouped by geographic area but this is only approximate.

"IPv6" replaces the 32-bit IP address with a much, much larger number. Some routers know how to use IPv6, and some internet providers are actively using those addresses right now. Therefore, when you design an Internet server-application, you should not presume that the address that you'll receive has the format w.x.y.z.

suicidaleggroll 11-02-2016 11:01 AM

Quote:

Originally Posted by snowmagician (Post 5624526)
I learned that gateway is used when a host ( a device on a network ) must send date to another host on another network. Is the gateway address still used when a host needs to send data to another host within the same address?

The netmask setting on your computer tells it which IP addresses are part of the subnet and can be accessed directly, versus which are not part of the subnet and must be accessed using the gateway. A typical netmask is 255.255.255.0, for this explanation it's a bit easier to write it in binary:
11111111.11111111.11111111.00000000

A '1' means "if my local IP has this bit set, then the IP I'm trying to access must also have this bit set in order to be considered local". A '0' means it does not need to match. So a netmask setting of 255.255.255.0 means that if the first three sets of numbers in the IP you're trying to access exactly match the machine's local IP, then it's an address on the local subnet and can be accessed directly. If any of those first three sets of numbers is different, it's not on the local subnet and the machine needs to pass the connection through the gateway.

Note that netmasks can also be set using shorthand like /24, eg: 192.168.1.1/24. The /24 means that the first 24 bits in the netmask are set, this is the same as 11111111.11111111.11111111.00000000, or 255.255.255.0.


All times are GMT -5. The time now is 07:21 PM.