Skip to content

Generate Random IP Address

Generate up to 1,000 random IPv4 or IPv6 addresses: public addresses that avoid every special-purpose range, private RFC 1918 or IPv6 unique local addresses, documentation addresses that are safe to publish, or hosts inside a subnet you choose. Each address is labelled with its type.

Ranges from the IANA special-purpose address registries

The IPv4 Ranges a "Public" Address Must Avoid

About 14% of the 4.3 billion IPv4 addresses are set aside for special purposes and never appear on the public internet. The public option skips all of them; the Type column names the range for any address that falls inside one.

IPv4 special-purpose address blocks
BlockPurposeDefined in
0.0.0.0/8"This network"; 0.0.0.0 means "any address" to softwareRFC 791
10.0.0.0/8Private networksRFC 1918
100.64.0.0/10Carrier-grade NAT between an ISP and its customersRFC 6598
127.0.0.0/8Loopback (this device)RFC 1122
169.254.0.0/16Link-local; what you get when DHCP failsRFC 3927
172.16.0.0/12Private networks (172.16 to 172.31)RFC 1918
192.0.0.0/24IETF protocol assignmentsRFC 6890
192.0.2.0/24Documentation (TEST-NET-1)RFC 5737
192.168.0.0/16Private networksRFC 1918
198.18.0.0/15Network benchmarkingRFC 2544
198.51.100.0/24Documentation (TEST-NET-2)RFC 5737
203.0.113.0/24Documentation (TEST-NET-3)RFC 5737
224.0.0.0/4MulticastRFC 5771
240.0.0.0/4Reserved, including 255.255.255.255 broadcastRFC 1112

"Public" here means outside those ranges, not that the address is in use. Most public IPv4 addresses are allocated to someone, so a random one can belong to a real home, company or server.

Worked Example: A Random Host in 10.20.0.0/22

A test lab uses the subnet 10.20.0.0/22 and needs 50 fake device addresses for a firewall rule test. Which addresses can be used?

Step 1: Host bits

/22 leaves 32 − 22 = 10 host bits → 2¹⁰ = 1,024 addresses · mask 255.255.252.0

Step 2: First and last address

Network 10.20.0.0 · broadcast 10.20.3.255 (the third octet runs 0 to 3)

Step 3: Usable hosts

10.20.0.1 to 10.20.3.254 = 1,022 hosts

Choose "Inside my subnet", enter 10.20.0.0/22 and ask for 50 with No repeats. The panel shows the same network, mask and range, and every address is a valid host. Note that 10.20.1.0 and 10.20.2.255 are ordinary hosts here: only the very first and last addresses of the whole /22 are reserved. A /31 keeps both of its addresses for point-to-point links (RFC 3021), and a /32 is a single host.

The Three Private IPv4 Blocks

RFC 1918 private IPv4 address blocks
BlockAddressesWhere you usually see it
10.0.0.0/816,777,216Company networks, cloud VPCs
172.16.0.0/121,048,576Docker's default bridge (172.17.0.0/16), some corporate networks
192.168.0.0/1665,536Home routers: 192.168.0.x and 192.168.1.x

The 10.x block is 256 times bigger than 192.168.x, so drawing uniformly from all private addresses would almost never produce a familiar 192.168 address. The Mix setting picks the block first, each with a one-in-three chance, then an address inside it, which gives realistic-looking test data. Pick a single block for something more specific.

Private addresses are reused by millions of networks and can't be reached from the internet directly; traffic leaves through NAT. Carrier-grade NAT space, 100.64.0.0/10, looks private but belongs to your ISP; don't use it for your own LAN.

What the Start of an IPv6 Address Tells You

Truly random 128-bit values are mostly in space that hasn't been allocated for anything. Real internet addresses come from 2000::/3, so they start with 2 or 3. That's why the global option keeps the first three bits fixed.

Common IPv6 address types by prefix
Starts withPrefixType
2 or 32000::/3Global unicast: real internet addresses
2001:db8: or 3fff:2001:db8::/32, 3fff::/20Documentation; never routed
fdfc00::/7 (fd00::/8 in use)Unique local: the IPv6 counterpart of private addresses
fe80:fe80::/10Link-local: every interface has one
ffff00::/8Multicast
::1::1/128Loopback
::ffff:::ffff:0:0/96An IPv4 address inside IPv6, e.g. ::ffff:192.0.2.1

3fff::/20 was added as a second documentation prefix in 2024 (RFC 9637) because 2001:db8::/32 is too small to show realistic large networks.

Writing IPv6 the Standard Way

The same IPv6 address can be written many ways, which breaks text comparisons in logs and spreadsheets. RFC 5952 fixes one canonical form, used by this page when Compress is ticked:

  • Lowercase letters, and no leading zeros in a group: 0db8 becomes db8.
  • Replace the longest run of two or more all-zero groups with ::. If two runs tie, shorten the first.
  • Never use :: for a single zero group.
Full and RFC 5952 forms of IPv6 addresses
Full formCanonical form
2001:0db8:0000:0000:0000:ff00:0042:83292001:db8::ff00:42:8329
2001:0db8:0000:0000:0001:0000:0000:00012001:db8::1:0:0:1
2001:0db8:0000:0001:0001:0001:0001:00012001:db8:0:1:1:1:1:1
0000:0000:0000:0000:0000:0000:0000:0001::1

Why Unique Local Addresses Are Random

IPv4 private networks all reuse the same few blocks, so when two companies merge, their 192.168.1.x networks collide and need renumbering. IPv6 unique local addresses avoid that: each site chooses a random 40-bit Global ID once, giving it its own fdxx:xxxx:xxxx::/48 with 65,536 subnets.

With 2⁴⁰ possible IDs, RFC 4193 puts the chance of a clash when 10 such networks are joined at about 4.5 × 10⁻¹¹. With One site ticked, every address in the list shares one random /48, as it would on a real network; untick it to give each address its own site.

Random Addresses in Python

import ipaddress, random

# a usable host in a subnet
net = ipaddress.ip_network('10.20.0.0/22')
host = net[random.randrange(1, net.num_addresses - 1)]   # 10.20.x.y

# a random IPv4 address, then check what kind it is
addr = ipaddress.IPv4Address(random.getrandbits(32))
addr.is_private, addr.is_global, addr.is_multicast

# canonical IPv6 text
str(ipaddress.ip_address('2001:0db8:0000:0000:0000:ff00:0042:8329'))
# '2001:db8::ff00:42:8329'

Python's ipaddress module knows the same special-purpose registries, so is_global is a good cross-check for addresses from this page. Its string output already follows RFC 5952.

Frequently asked questions

Is a random public IP address someone’s real address?

Quite possibly. Most public IPv4 space is allocated, so a random public address may belong to a real network. Use the documentation option for anything you publish, and don’t scan or probe random addresses.

Which IP addresses are safe to use in examples?

For IPv4, 192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24 (RFC 5737). For IPv6, 2001:db8::/32 and 3fff::/20. They are never routed on the internet.

Can I generate an IP address for a particular country?

No. Addresses are allocated to networks by regional registries and change hands over time, so a range doesn’t reliably mean a country. Use documentation addresses for examples instead.

Why do I lose two addresses in an IPv4 subnet?

The first is the network address and the last is the broadcast address. A /24 has 256 addresses and 254 usable hosts. /31 point-to-point links and /32 single hosts are exceptions.

Sources