Network security

How to Find Subnet Mask From IP Address on Windows, Mac & Linux

Your subnet mask is stored on your device, not hidden inside your IP address. Here is how to read it on every system, and how to convert it to CIDR.

Cysoro Security TeamPublished · 8 min read
NETWORK SECURITYSubnetmaskFind it on any device, fast.ipconfigIPv4: 192.168.1.20Mask: 255.255.255.0Gateway: 192.168.1.1/24
Quick answer

You cannot work out a subnet mask from an IP address alone, because the same address can use different masks. Instead, read the mask your network assigned to your device: run ipconfig on Windows, open Network settings on a Mac, or run ip address on Linux. On most home networks it is 255.255.255.0, written as /24.

Key takeaways

  • An IP address alone does not reveal its subnet mask; the mask is assigned by your network, usually by DHCP.
  • On Windows run ipconfig, on macOS check Network settings, and on Linux run ip address to read the mask or CIDR prefix.
  • On most home networks the mask is 255.255.255.0 (/24), which allows 254 usable host addresses.

You have an IP address such as 192.168.1.20 and you need its subnet mask — for a static IP setup, a firewall rule, or a networking class. The catch is that the mask is not hidden inside the address. It is a separate setting your network gave your device, and you have to read it where it lives.

Can you find a subnet mask from an IP address alone?

No. The same IPv4 address can be paired with different subnet masks, so an address alone does not prove which mask is in use. Modern networks use CIDR, not the old address classes, so you must check the device, the router, or the network administrator.

This surprises many people because the old class system once made it look predictable: addresses starting with 192.168 were assumed to be /24. That assumption no longer holds. A home router might use /24, a business network might split the same range into smaller subnets such as /25 or /26, and a cloud network might use something entirely different.

The practical rule is simple: if you know the IP but not the mask, look it up on the device that holds the address, or on the router that assigned it. The rest of this guide shows exactly where to look on every common system.

What is a subnet mask?

A subnet mask is a 32-bit number, written like an IP address, that tells a device which part of an address identifies the network and which part identifies the host. A device compares its own address with a destination address using the mask to decide whether the destination is local or needs the router.

Take 192.168.1.20 with mask 255.255.255.0. The mask's first 24 bits are ones, so the first three octets (192.168.1) are the network and the last octet (20) is the host. Any address starting 192.168.1. is on the same local network; anything else goes through the default gateway, usually your router.

The mask works by a bitwise AND operation, as IPGeolocation explains: the device keeps each address bit where the mask has a 1 and clears it to 0 where the mask has a 0. The result is the network address. You do not need to do this math by hand to find your mask, but it explains why the mask matters for routing, firewalls, and static IP configuration.

How do I find my subnet mask on Windows?

Open Command Prompt, run ipconfig, and read the Subnet Mask line under your connected Wi-Fi or Ethernet adapter. It takes about ten seconds and shows the mask exactly as Windows received it from your network.

  1. Press the Windows key, type Command Prompt, and open it.
  2. Type ipconfig and press Enter.
  3. Find the adapter that is connected, usually Wireless LAN adapter Wi-Fi or Ethernet.
  4. Read the line labeled Subnet Mask, next to the IPv4 Address and Default Gateway lines.

Typical output looks like this:

Wireless LAN adapter Wi-Fi:
   IPv4 Address. . . . . . . . . . . : 192.168.1.20
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.1.1

Run ipconfig /all for full details on every adapter, including DNS servers and the DHCP server. If you prefer the graphical route, open Settings, then Network and internet, select Wi-Fi or Ethernet, open your connection, and read the subnet mask in the IP assignment section. If several adapters are listed, use the one carrying your traffic — a VPN or virtual adapter will show a different mask.

How do I find my subnet mask on macOS?

Open System Settings, click Network, select Wi-Fi or Ethernet, click Details, then open the TCP/IP tab. The subnet mask is shown next to your IPv4 address in that panel.

  1. Click the Apple menu and open System Settings.
  2. Click Network in the sidebar.
  3. Select the connection you are using, usually Wi-Fi or Ethernet.
  4. Click Details, then open the TCP/IP tab.
  5. Read the Subnet mask field.

From Terminal, you can get the same value with one command: ipconfig getoption en0 subnet_mask, where en0 is usually Wi-Fi. Running ifconfig also works, but it shows the mask in hexadecimal form on some versions, which is harder to read. Note that IPv6 connections show a prefix length instead of a dotted-decimal mask.

How do I find my subnet mask on Linux?

Open a terminal and run ip address. Look for a line such as inet 192.168.1.20/24: the number after the slash is the CIDR prefix, and /24 means the mask is 255.255.255.0.

Linux generally displays prefixes in CIDR form rather than dotted-decimal masks. The older ifconfig command shows the dotted form, but it may not be installed on modern distributions. Use the conversion table below to translate any prefix you see.

To see only the default route and gateway as well, run ip route | grep default. That tells you the router address, which is the address you type into a browser to open your router admin page and check the network-wide mask.

How do I find my subnet mask on iPhone and Android?

On an iPhone, open Settings, then Wi-Fi, tap the connected network, and read the subnet mask in the IPv4 details. On Android, open Settings, then Network and internet, tap Wi-Fi, tap the connected network, and look for the subnet mask or prefix in the network details.

Menu names vary by Android maker and version. Some Android phones show the mask as a CIDR prefix, such as /24, rather than 255.255.255.0. If your phone only shows the IP address, install no extra app: the router admin page shows the same mask for the whole network, and the steps in the next section cover that.

Remember that a "what is my IP" website shows your public address as the internet sees it. It cannot reliably reveal the subnet mask configured on your phone or laptop, because that mask belongs to your local network, not to your public connection. You can check your public address with our free what-is-my-IP tool, but use the device steps above for the mask.

How do I find the subnet mask on my router?

Log in to your router admin page and open the LAN or DHCP settings. The subnet mask shown there is the mask for the whole local network, and it is the value every device on that network normally receives.

  1. Find your router address: on Windows run ipconfig and read the Default Gateway line; on a Mac it is the Router field in the TCP/IP tab.
  2. Type that address, often 192.168.1.1 or 192.168.0.1, into a browser.
  3. Sign in with the router admin password, usually printed on a label on the router.
  4. Open the LAN, DHCP, or network settings page and read the subnet mask.

If you change the mask here, you change it for the whole network, so do not edit it unless you know what you are doing. A wrong mask can cut devices off from each other or from the internet. Our guide to securing your Wi-Fi covers the router settings worth changing — and the ones to leave alone.

How do I convert a subnet mask to CIDR?

Convert a mask to CIDR by counting the one bits: 255.255.255.0 has 24 one bits, so it is /24. The table below covers the prefixes you are most likely to meet, with the number of usable host addresses for each.

CIDR prefixSubnet maskUsable hostsTypical use
/32255.255.255.2551A single host route
/30255.255.255.2522Point-to-point links
/29255.255.255.2486Small office subnet
/28255.255.255.24014Small subnet
/27255.255.255.22430Department subnet
/26255.255.255.19262Medium subnet
/25255.255.255.128126Large subnet
/24255.255.255.0254Home and small office networks
/23255.255.254.0510Larger office network
/16255.255.0.065,534Large private network
/8255.0.0.016,777,214Very large private network
How 192.168.1.20 / 255.255.255.0 splits apartIP address: 192 . 168 . 1 . 20Subnet mask: 255 . 255 . 255 . 0Network part: 192.168.1Host: 20The mask keeps the first 24 bits as the network and leaves 8 bits for hosts: /24.
How a /24 mask splits an IP address into its network and host parts. Illustration by Cysoro.

Two addresses in every subnet are reserved: the network address itself (all host bits zero, such as 192.168.1.0) and the broadcast address (all host bits one, such as 192.168.1.255). That is why a /24 has 254 usable hosts, not 256.

How do I calculate a subnet from an IP and a mask?

Once you know both the IP and the mask, you can work out the network address, broadcast address, and usable range. Apply the mask to the address with a bitwise AND to get the network address, then set all host bits to one for the broadcast address.

For 172.16.5.130/27, the mask is 255.255.255.224. The network address is 172.16.5.128, the broadcast address is 172.16.5.159, and usable hosts run from 172.16.5.129 to 172.16.5.158 — 30 addresses. Doing this by hand is useful for exams and interviews, but for real work a subnet calculator is faster and less error-prone.

Common mistakes include forgetting the two reserved addresses and assuming a mask from the first octet of the IP. TP-Link has a clear guide to how subnet masks work if you want a second worked example. If you are setting a static IP, copy the mask, gateway, and DNS servers exactly as your router or administrator gives them; guessing any of them is the fastest way to lose connectivity.

Where to find your subnet mask1. Your deviceipconfig, Networksettings, ip address2. Your routerLAN or DHCP settingsat the gateway address3. Ask the adminwork or schoolnetworks onlyAn IP address alone is never enough — the mask is a separate setting.Private ranges you will see most: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.
Three places to find a subnet mask: the device, the router, or the network administrator. Illustration by Cysoro.

What are the common private IP ranges and masks?

The private ranges most home and office networks use are 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. A private range is not itself a subnet mask: 192.168.1.25/24 contains the private address 192.168.1.25 and the separate mask /24.

Home routers usually hand out addresses in 192.168.0.0 or 192.168.1.0 with a /24 mask. Larger offices often use 10.0.0.0/8 as the overall range, then split it into smaller subnets for departments, floors, or device types. If you see an address such as 10.20.30.40, do not assume its mask — check the device, as described above.

The bottom line

You cannot find a subnet mask from an IP address alone, but you can find it in seconds on the device that holds the address. Run ipconfig on Windows, open the TCP/IP tab on a Mac, or run ip address on Linux, and read the mask or CIDR prefix it shows.

Once you have the mask, the CIDR table above lets you work out how many devices the subnet holds and which addresses belong to it. If you are troubleshooting a home network, check the router too — and confirm your public address with the free DNS lookup tool while you are there.

Frequently asked questions

Can you find the subnet mask from an IP address alone?

No, not reliably. The same IPv4 address can be paired with different subnet masks, so an address starting with 192.168 does not prove the mask is 255.255.255.0. You need to check the device or router settings, or ask the network administrator.

What is the most common subnet mask for a home network?

Most home networks use 255.255.255.0, written as /24. It covers 256 addresses, of which 254 are usable for devices, with one address for the network itself and one for broadcast.

What does /24 mean in an IP address?

The /24 is CIDR notation for the prefix length: the first 24 bits of the address identify the network, and the remaining 8 bits identify hosts. A /24 is the same as the dotted-decimal mask 255.255.255.0.

How do I find my subnet mask on Windows 11?

Open Command Prompt and run ipconfig, then look for Subnet Mask under your Wi-Fi or Ethernet adapter. You can also open Settings, then Network and internet, then your connection, and read the subnet mask in the IP assignment details.

How do I find my subnet mask on a Mac?

Open System Settings, click Network, select Wi-Fi or Ethernet, click Details, then open the TCP/IP tab. The subnet mask is shown next to your IPv4 address. In Terminal, ipconfig getoption en0 subnet_mask prints the same value.

How do I find my subnet mask on Linux?

Open a terminal and run ip address. Look for a line such as inet 192.168.1.20/24. The number after the slash is the CIDR prefix, so /24 means the mask is 255.255.255.0.

Where is the subnet mask on my router?

Log in to your router admin page, usually at 192.168.1.1 or 192.168.0.1, and open the LAN or DHCP settings. The subnet mask shown there applies to the whole local network.

Does IPv6 have a subnet mask?

IPv6 does not use dotted-decimal subnet masks. It uses a prefix length instead, such as /64, which is shown in your network settings in place of a mask.

Sources

  1. MacMyths — What Is My Subnet Mask? Find It on Windows, Mac, Linux, iPhone and Android
  2. IPGeolocation — What Is a Subnet Mask? How It Works, Examples, Cheat Sheet
  3. TP-Link — What Is a Subnet Mask and How Does It Work?
  4. PowerDMARC — IPv4 Subnet Calculator
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against vendor and networking guides from TP-Link, IPGeolocation and MacMyths, and the standard CIDR prefix table.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free