Explained: How is My IP Assigned / Determined (IPv4)?

Dennis Faas's picture

Infopackets Reader Izzy M. writes:

" Dear Dennis,

I am trying to figure out how IP addresses are assigned using IPv4 (IP addressing version 4), but can't seem to find a straight answer online. My question: is there a certain number that my IP address has to be? Is there any correlation between my IP address, subnet mask and default gateway? How is my IP address assigned or determined? Thank you in advance! "

My response:

I think the reason you can't find an answer to this question is because this is an extremely broad question. To put this as simple as possible: the answer to your question depends on your network class (A, B, C, D). The network class then determines whether you are referring to a public IP address which is assigned to your modem by your Internet provider, or a private IP address which is typically assigned by your router on a home network.

Related: How Do I Change my IP Address (IP Banned)?

Explained: How is My IP Assigned / Determined (IPv4)?

Your IP address (with respect to IPv4) is derived from three main things:

1. Your network class (A, B, C, D) - this defines whether you're using a public IP address (from your Internet provider) or a private IP address (typically assigned by your router, on your home network). For the record you can review a list of public IPs (IPv4) here.

2. The subnet, which defines how many IPs are assigned to the network class range

3. Whether the IP is leased or permanent (static or dynamic)

How an IP is Assigned on a Home Network (IPv4)

Let's look at a typical example for a home user.

Internet access is provided by an Internet Service Provider (ISP); data travels from the Internet to a modem inside your home (usually). A router connects to the modem and allows your home network to communicate to the outside world (to the Internet).

The router usually has DHCP (dynamic host control protocol) enabled by default. The purpose of DHCP is to automatically assign any device on your network an IPv4 address. This allows you to share the Internet across multiple devices in your home (or office), and even communicate with other devices across your entire private network.

Here's where things get a bit more technical.

The subnet mask is used to define a subnet range on the network. As a typical example, most routers are assigned a class C range. Class C is defined as having IPs 192.168.0.0 to 192.168.255.255, which yields a total of 2,097,150 usable IP addresses. This is far too large for most home networks; as such, a subnet mask is applied to yield a smaller range of usable IPs on the network.

Thus, a typical network class C range (for use at home) would be 192.168.0.1 to 192.168.2.254 with a subnet mask of 255.255.255.0, yielding 254 usable IP addresses. There is a mathematical way to derive how IPs are subnetted, which I will not get into - but you read read up on, if you want.

Of that IP range, certain IPs are reserved for special cases. For example:

  • 192.168.0.1 is usually the default gateway (also used for the router administration page)
  • 192.168.0.2 - 192.168.0.100 are usually reserved for dynamic addresses, controlled by DHCP; these IPs are leased and expire over time, thus DHCP IPs are not always the same
  • 129.168.0.101 - 192.168.0.254 are usually reserved for static IPs
  • 192.168.0.255 is the broadcast IP

Assigning an IPv4 Address: Using DHCP or Static IPs

On a typical home network, an IPv4 address is assigned depending on how the router and your machine are configured.

By default, DHCP (dynamic host control protocol) is enabled on the router. This means that the router will automatically assign an IP address to any device on the network automatically according to the DHCP IP range. The DHCP range is defined in the router administration page. Using the example above, the range would be 192.168.0.2 to 192.168.0.100.

If you prefer to set a static IP rather than one through DHCP, this would be done by adjusting your network adapter settings in the operating system. For example, if you have a 'server' or 'media pc' machine in the home and you want to use the same IP address for that device all the time (instead of a random IP address), then a static IP address makes more sense.

I hope this answers your question.

Keep in mind that this is an extremely broad question with many variables involved. That said, in the case of 'home networking' this answer should fit. In the case of how an IP is assigned using an Internet Provider: the same ideas apply, except DHCP is controlled by the Internet Provider and IPs are leased for a certain duration of time (especially if your modem or router loses power).

Related: How Do I Change my IP Address (IP Banned)?

Got a Computer Question or Problem? Ask Dennis!

I need more computer questions. If you have a computer question - or even a computer problem that needs fixing - please email me with your question so that I can write more articles like this one. I can't promise I'll respond to all the messages I receive (depending on the volume), but I'll do my best.

About the author: Dennis Faas is the owner and operator of Infopackets.com. With over 30 years of computing experience, Dennis' areas of expertise are a broad range and include PC hardware, Microsoft Windows, Linux, network administration, and virtualization. Dennis holds a Bachelors degree in Computer Science (1999) and has authored 6 books on the topics of MS Windows and PC Security. If you like the advice you received on this page, please up-vote / Like this page and share it with friends. For technical support inquiries, Dennis can be reached via Live chat online this site using the Zopim Chat service (currently located at the bottom left of the screen); optionally, you can contact Dennis through the website contact form.

Rate this article: 
Average: 5 (7 votes)

Comments

pctyson's picture

DHCP (dynamic host control protocol)

I know you will get some more comments on this so I am giving you a heads up. DHCP is most commonly referred to as Dynamic Host Configuration Protocol (DHCP). It appears that it can be called Dynamic Host Control Protocol as referenced on the below noted Cisco page but its technical name is Dynamic Host Configuration Protocol. The header in the Cisco page uses the word control but the rest of the page references it as configuration. It may be a country related variation that I am not aware of and if so ignore my post please.

(https://www.cisco.com/c/en/us/products/ios-nx-os-software/dynamic-host-control-protocol-dhcp-domain-name-system-dns/index.html)

Dennis Faas's picture

Dynamic Host Control Protocol and Dynamic Host Configuration Protocol are used interchangeably but refer to the exact same thing. Thanks for pointing it out. Old school users like myself refer to it as Dynamic Host Control Protocol.

BigZ1981's picture

It would be good to point out that every IPv4 address has 4 numerical values separated by a period. Each of these values range between 0-255. Every ISP has a range of public IPs they assign to their customers. These IPs are given to your home gateway or router. This allows your router to communicate with your ISP's system. All residential/consumer accounts have a dynamic IP assignment, which means that the IP changes every so often. The normal standard is 7 days, and does not always change when the router reboots. However this is normally something you would not see within your home network.

Like Dennis said, most home routers will have a config/gateway IP address of 192.168.x.x. Those x's are either 0's or 1's, depending on what the manufacturer sets. With router DHCP configurations, some default to start IP assignments in the 192.168.x.100 range. If you decide that you want to set static IP assignments for your devices within your home network, note that they all have to match the first 3 fields in the IP address and cannot be the same as the gateway IP. (Unless you change your subnet mask, which then complicates things.) So if your router is configured with a gateway IP of 192.168.1.0, then your devices can have any IP address that falls within the range of 192.168.1.(1-255).

DHCP normally assigns IP addresses in sequential order starting with the first device it connects with. So if the gateway is 192.168.1.0 and it's set to start from the 100 range, the first device will be assigned 192.168.1.100, the next will be 192.168.1.101, and so forth.

For your public IP assigned to you by your ISP they have bigger routers that essentially do the same thing, for your neighborhood, only they can be confogured with a wider range of IP addresses.

I hope this digs a bit deeper, but doesn't get confusing for those who are wanting to learn a bit more. The IP classes & subnet masks are more for high-level corporate networks where they need to separate networks or merge location networks for purposes of maintaining an intranet or VPN connection, which then goes beyond the scope of my own knowledge.