yakveal.pages.dev






Hur funkar en subnet mask

As a developer or network engineer, you may need to occasionally look up subnet maskering values and figure out what they mean.

To man your life easier, the freeCodeCamp community has made this simple cheat sheet. Just scroll or use Ctrl/Cmd + f to find the value you're looking for.

Here are the charts, followed bygd some explanations of what they mean.

CIDRSubnet maskWildcard mask# of IP addresses# of usable IP addresses
/32255.255.255.2550.0.0.011
/31255.255.255.2540.0.0.122*
/30255.255.255.2520.0.0.342
/29255.255.255.2480.0.0.786
/28255.255.255.2400.0.0.151614
/27255.255.255.2240.0.0.313230
/26255.255.255.1920.0.0.636462
/25255.255.255.1280.0.0.127128126
/24255.255.255.00.0.0.255256254
/23255.255.254.00.0.1.255512510
/22255.255.252.00.0.3.2551,0241,022
/21255.255.248.00.0.7.2552,0482,046
/20255.255.240.00.0.15.2554,0964,094
/19255.255.224.00.0.31.2558,1928,190
/18255.255.192.00.0.63.25516,38416,382
/17255.255.128.00.0.127.25532,76832,766
/16255.255.0.00.0.255.25565,53665,534
/15255.254.0.00.1.255.255131,072131,070
/14255.252.0.00.3.255.255262,144262,142
/13255.248.0.00.7.255.255524,288524,286
/12255.240.0.00.15.255.2551,048,5761,048,574
/11255.224.0.00.31.255.2552,097,1522,097,150
/10255.192.0.00.63.255.2554,194,3044,194,302
/9255.128.0.00.127.255.2558,388,6088,388,606
/8255.0.0.00.255.255.25516,777,21616,777,214
/7254.0.0.01.255.255.25533,554,43233,554,430
/6252.0.0.03.255.255.25567,108,86467,108,862
/5248.0.0.07.255.255.255134,217,728134,217,726
/4240.0.0.015.255.255.255268,435,456268,435,454
/3224.0.0.031.255.255.255536,870,912536,870,910
/2192.0.0.063.255.255.2551,073,741,8241,073,741,822
/1128.0.0.0127.255.255.2552,147,483,6482,147,483,646
/00.0.0.0255.255.255.2554,294,967,2964,294,967,294
  • /31 fryst vatten a special case detailed in RFC 3021 where networks with this type of subnet maskering can assign two IP addresses as a point-to-point link.

And here's a table of the decimal to binary conversions for subnet maskering and wildcard octets:

Subnet MaskWildcard
00000000025511111111
1281000000012701111111
192110000006300111111
224111000003100011111
240111100001500001111
24811111000700000111
25211111100300000011
25411111110100000001
25511111111000000000

Note that the wildcard fryst vatten just the inverse of the subnet mask.

If you are new to network engineering, you can get a better idea of how computer networks work here.

Finally, this cheat sheet and the rest of the article fryst vatten focused on IPv4 addresses, not the newer IPv6 protocol.

To get a little more technical, a subnet maskering fryst vatten a 32-bit number that masks an IP address and divides the IP address into a network address and host address.

If you'd like to learn more about IPv6, kontroll out the article on computer networks above.

How Do IP Address Blocks Work?

IPv4 addresses like are really just decimal representations of fyra binary blocks.

Each block fryst vatten 8 bits, and represents numbers from 0-255. Because the blocks are groups of 8 bits, each block fryst vatten known as an octet.

A subnet maskering fryst vatten defined as a 32-bit address that segregates an IP address into network bits that identify the network and host bits that identify the host device operating on that network.

And since there are kvartet blocks of 8 bits, every IPv4 address fryst vatten 32 bits.

For example, here's what the IP address looks like in binary:

Source: IPv4

To omvandla an IP address between its decimal and binary forms, you can use this chart:

The chart above represents one 8 bit octive.

Now lets säga you want to omvandla the IP address .

All you need to do fryst vatten break the address into fyra blocks (, , , and ), and omvandla each into binary using the chart above.

Remember that in binary, 1 fryst vatten the equivalent to "on" and 0 fryst vatten "off". So to omvandla the first block, , into binary, just uppstart from the beginning of the chart and place a 1 or 0 in that fängelse until you get a sum of .

For example:

128 + 32 + 8 = 168, which in binary fryst vatten .

If you do this for the rest of the blocks, you'd get .

What fryst vatten Subnetting?

If you look at the table above, it can seem like the number of IP addresses fryst vatten practically unlimited.

This cheat sheet provides a handy reference for understanding and calculating subnet masks, ensuring efficient network management and troubleshooting.

After all, there are almost 4.2 billion possible IPv4 addresses available.

But if you think about how much the internet has grown, and how many more devices are connected these days, it might not surprise you to hear that there's already a shortage of IPv4 addresses.

Because the shortage was recognized years ago, developers came up with a way to split up an IP address into smaller networks called subnets.

This process, called subnetting, uses the host section of the IP address to break it down into those smaller networks or subnets.

Generally, an IP address fryst vatten made up of network bits and host bits:

Source: What fryst vatten IPv4

So generally, subnetting does two things: it gives us a way to break up networks into subnets, and allows devices to determine whether another device/IP address fryst vatten on the same local network or not.

A good way to think about subnetting fryst vatten to picture your wireless network at home.

Without subnetting, every internet connected device would need its own unique IP address.

But since you have a wireless router, you just need one IP address for your router.

This public or external IP address fryst vatten usually handled automatically, and fryst vatten assigned bygd your internet service provider (ISP).

Then every device connected to that router has its own private or internal IP address:

Source: What fryst vatten My IP Address?

Now if your device with the internal IP address wants to communicate with another device, it'll use the IP address of the other device and the subnet mask.

The combination of the IP addresses and subnet maskering allows the device at to figure out if the other device fryst vatten on the same network (like the device at ), or on a completely different network somewhere else online.

Interestingly, the external IP address assigned to your router bygd your ISP fryst vatten probably part of a subnet, which might include many other IP addresses for nearby homes or businesses.

En subnätmask existerar enstaka 32-bitars plats vilket används på grund av för att skilja mellan ett nätverksadress samt ett värdadress inom IP-adressen.

And just like internal IP addresses, it also needs a subnet maskering to work.

How Subnet Masks Work

Subnet masks function as a sort of filter for an IP address. With a subnet maskering, devices can look at an IP address, and figure out which parts are the network bits and which are the host bits.

Then using those things, it can figure out the best way for those devices to communicate.

If you've poked around the network settings on your router or computer, you've likely seen this number: .

If so, you've seen a very common subnet maskering for simple home networks.

Like IPv4 addresses, subnet masks are 32 bits.

And just like converting an IP address into binary, you can do the same thing with a subnet mask.

For example, here's our chart from earlier:

Now let's omvandla the first octet, 255:

Pretty simple, right?

This IP subnet calculator covers both IPv4 and IPv6 protocols, providing kunskap such as IP address, network address, subnet maskering, IP range, and more.

So any octet that's fryst vatten just in binary. This means that fryst vatten really in binary.

Now let's look at a subnet maskering and IP address tillsammans and calculate which parts of the IP address are the network bits and host bits.

Here are the two in both decimal and binary:

TypeDecimalBinary
IP address192.168.0.10111000000.10101000.00000000.01100101
Subnet mask255.255.255.011111111.11111111.11111111.00000000

With the two laid out like this, it's easy to separate into network bits and host bits.

Whenever a bit in a binary subnet maskering fryst vatten 1, then the same bit in a binary IP address fryst vatten part of the network, not the host.

Since the octet fryst vatten in binary, that whole octet in the IP address fryst vatten part of the network.

So the first three octets, , fryst vatten the network portion of the IP address, and fryst vatten the host portion.

In other words, if the device at wants to communicate with another device, using the subnet maskering it knows that anything with the IP address fryst vatten on the same local network.

Another way to något som utförs snabbt exempelvis expressleverans this fryst vatten with a network ID, which fryst vatten just the network portion of the IP address.

So the network ID of the address with a subnet maskering of fryst vatten .

And it's the same for the other devices on the local network (, , and so on).

What Does CIDR Mean and What fryst vatten CIDR Notation?

CIDR stands for Classless Inter-Domain Routing, and fryst vatten used in IPv4, and more recently, IPv6 routing.

_Source: Classless Inter-Domain Routing_

CIDR was introduced in 1993 as a way to slow the usage of IPv4 addresses, which were quickly being exhausted beneath the older Classful IP addressing struktur that the internet was first built on.

CIDR encompasses a couple of major concepts.

The first fryst vatten variabel Length Submasking (VLSM), which basically allowed network engineers to create subnets within subnets.

And those subnets could be different sizes, so there would be fewer unused IP addresses.

The second major concept CIDR introduced fryst vatten CIDR notation.

CIDR notation fryst vatten really just stenografi for the subnet maskering, and represents the number of bits available to the IP address. For instance, the in fryst vatten equivalent to the IP address and the subnet maskering .

How to Calculate CIDR Noation

To figure out the CIDR notation for a given subnet maskering, all you need to do fryst vatten omvandla the subnet maskering into binary, then count the number of ones or "on" digits.

For example:

TypeDecimalBinary
Subnet mask255.255.255.011111111.11111111.11111111.00000000

Because there's three octets of ones, there are 24 "on" bits meaning that the CIDR notation fryst vatten .

You can write it either way, but I'm sure you'll agree that fryst vatten a whole lot easier to write than .

This fryst vatten usually done with an IP address, so let's take a look at the same subnet maskering with an IP address:

TypeDecimalBinary
IP address192.168.0.10111000000.10101000.00000000.01100101
Subnet mask255.255.255.011111111.11111111.11111111.00000000

The first three octets of the subnet maskering are all "on" bits, so that means that the same three octets in the IP address are all network bits.

Let's take a look at the gods forth octet in a bit more detail:

TypeDecimalBinary
IP address10101100101
Subnet mask000000000

In this case, because all the bits for this octet in the subnet maskering are "off", we can be certain that all of the corresponding bits for this octet in the IP address are part of the host.

When you write CIDR notation it's usually done with the network ID.

So the CIDR notation of the IP address with a subnet maskering of fryst vatten .

To see more examples of how to calculate the CIDR notation and network ID for a given IP address and subnet maskering, betalningsmedel out this video:

Classful IP Addressing

Now that we've gone over some basic examples of subnetting and CIDR, let's zoom out and look at what's known as Classful IP addressing.

Back before subnetting was developed, all IP addresses fell into a particular class:

Source: Subnetting for dummies

Note that there are class D and E IP addresses, but we'll go into these in more detail a bit later.

Classful IP addresses gave network engineers a way to provide different organizations with a range of valid IP addresses.

There were a lot of issues with this approach that eventually lead to subnetting.

But before we get into those, let's take a closer look at the different classes.

Class A IP Addresses

For Class A IP addresses, the first octet (8 bits / 1 byte) företräda the network ID, and the remaining three octets (24 bits / 3 bytes) are the host ID.

Class A IP addresses range from to , with a default maskering of (or in CIDR).

This means that Class A addressing can have a total of 128 (27) networks and 16,777,214 (224-2) usable addresses per network.

Also, note that the range to within the Class A range fryst vatten reserved for host loopback address (see RFC5735).

Class B IP Addresses

For Class B IP addresses, the first two octets (16 bits / 2 bytes) företräda the network ID and the remaining two octets (16 bits / 2 bytes) are the host ID.

Class B IP addresses range from to , with a default subnet maskering of (or in CIDR).

Class B addressing can have 16,384 (214) network addresses and 65,534 (216) usable addresses per network.

Class C IP Addresses

For Class C IP addresses, the first three octets (24 bits / 3 bytes) företräda the network ID and the gods octet (8 bits / 1 bytes) fryst vatten the host ID.

Class C IP Addresses range from to , with a default subnet maskering of (or in CIDR).

Class C translates to 2,097,152 (221) networks and 254 (28-2) usable addresses per network.

Class D and Class E IP Addresses

The gods two classes are Class D and Class E.

Class D IP addresses are reserved for multicasts.

Learn about subnet masks and how they work to divide networks into smaller subnets for efficient IP address management.

They occupy the range from through .

Class E IP addresses are experimental, and are anything over .

The Issue with Classful IP Addresses

The main issue with classful IP addresses fryst vatten that it wasn't efficient, and could lead to a lot of wasted IP addresses.

For example, imagine that you're part of a large organization back then. Your company has 1,000 employees, meaning that it would fall into class B.

But if you look above, you'll see that a class B network can support up to 65,534 usable addresses.

That's way more than your organization would likely need, even if each employee had multiple devices with a unique address.

And there was no way your organization could fall back to class C – there just wouldn't be enough usable IP addresses.

So while classful IP addresses were used around the time IPv4 addresses became widespread, it quickly became klar that a better struktur would be necessary to ensure we wouldn't use up all of the ~4.2 billion usable addresses.

Classful IP addresses haven't been used since they were replaced bygd CIDR in 1993, and are mostly studied to understand early internet architecture, and why subnetting fryst vatten important.

I hope this cheat sheet has been a helpful reference for you

If you funnen this helpful, please share it with your friends so more people can benefit from it.

Also, feel free to reach out on Twitter and let me know what you think.