Working 172.16.254.1 out by hand
Hex is base 16. One digit covers 0 to 15, with A to F standing for 10 to 15. Two digits cover 0 to 255, the full range of one octet. So every IPv4 octet turns into exactly two hex digits, and the whole address into eight.
Divide each octet by 16. The quotient is the first digit, the remainder the second.
| Octet | ÷ 16 | First digit | Second digit | Hex |
|---|---|---|---|---|
| 172 | 10 remainder 12 | 10 → A | 12 → C | AC |
| 16 | 1 remainder 0 | 1 | 0 | 10 |
| 254 | 15 remainder 14 | 15 → F | 14 → E | FE |
| 1 | 0 remainder 1 | 0 | 1 | 01 |
Join the pairs and you get AC10FE01. Keep the zero in 01. Drop it and the value has seven digits. Any parser pads a short value on the left, so AC10FE1 reads back as 10.193.15.225, a different host on a different network.
10 = A11 = B12 = C13 = D14 = E15 = F
Which format does the destination want?
The eight digits never change. The wrapping around them depends on the program reading them. The converter prints every form below from one input, so this list is about picking the right card.
- PXELINUX boot configs
-
PXELINUX looks for a config file named after the client address in uppercase hex,
pxelinux.cfg/C0A8010Afor 192.168.1.10. With no such file, the loader drops the last digit and retries:C0A8010,C0A801, down toC, thendefault. One file namedC0A801therefore covers every client in 192.168.1.0/24. - tcpdump byte offsets
-
tcpdump 'ip[12:4] = 0xc0a8010a'matches packets from 192.168.1.10. Offset 12 in the IPv4 header holds the source address, offset 16 the destination. For a single host,src host 192.168.1.10is shorter. The byte form pays off with a mask, such asip[12:4] & 0xffffff00 = 0xc0a80100for a whole /24. - Snort and Suricata rules
-
content:"|C0 A8 01 0A|";matches the four bytes anywhere in the payload. Use this when an address sits inside application data, such as a SOCKS4 connect request or a hardcoded beacon address, instead of the IP header. - Wireshark
-
frame contains c0:a8:01:0afinds the bytes at any layer of the capture. For the header fields alone,ip.addr == 192.168.1.10is the cleaner filter. - C and firmware
-
uint8_t ip[4] = { 0xC0, 0xA8, 0x01, 0x0A };stores bytes in the order you wrote them. Auint32_tset to0xC0A8010Aholds the right number, but on a little-endian chip the bytes sit in memory as0A 01 A8 C0. Pass the integer throughhtonl()before it goes into asockaddr_in. - Browser address bar
-
http://0xC0A8010A/opens 192.168.1.10. The WHATWG URL standard parses hex, octal, and single-number IPv4 hosts. Allowlists matching the string "192.168." miss this form, which is why SSRF test lists include it.
Netmasks in hex, the way macOS prints them
Run ifconfig en0 on macOS or FreeBSD and the mask shows as netmask 0xffffff00, not 255.255.255.0. Type an address with a prefix, such as 10.20.30.40/22, and the converter returns the mask, the network address, and the last address in hex.
Read a hex mask one digit at a time. Each F is four network bits. FFFFFC00 has five Fs, 20 bits, plus C, which is 1100 in binary, two more. That makes /22.
| Prefix | Dotted mask | Hex mask | Addresses |
|---|---|---|---|
| /8 | 255.0.0.0 | FF000000 | 16,777,216 |
| /16 | 255.255.0.0 | FFFF0000 | 65,536 |
| /20 | 255.255.240.0 | FFFFF000 | 4,096 |
| /22 | 255.255.252.0 | FFFFFC00 | 1,024 |
| /24 | 255.255.255.0 | FFFFFF00 | 256 |
| /26 | 255.255.255.192 | FFFFFFC0 | 64 |
| /28 | 255.255.255.240 | FFFFFFF0 | 16 |
| /30 | 255.255.255.252 | FFFFFFFC | 4 |
| /32 | 255.255.255.255 | FFFFFFFF | 1 |
IPv6 is hex already. What changes?
An IPv6 address is 32 hex digits with runs of zeros trimmed for reading. 2001:db8::1 hides 23 zeros. The converter puts them back and gives 20010DB8000000000000000000000001, the form MySQL returns from HEX(INET6_ATON('2001:db8::1')) and the form a packet capture shows.
Reverse DNS wants the same digits backwards, one per label. The PTR record for 2001:db8::1 lives at:
1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.
Count the labels before you paste a name like this into a zone file. One missing zero shifts every digit after it, and the record answers for a different address. The ip6.arpa card prints all 32 labels for you.
IPv4-mapped addresses such as ::ffff:192.168.0.1 come out as 00000000000000000000FFFFC0A80001. The last eight digits are the IPv4 address in hex, and the converter shows them on a separate card.
The same conversion in code
Every line below returns network byte order, the order the converter shows first.
# Python
import ipaddress
ipaddress.ip_address('192.168.1.10').packed.hex() # 'c0a8010a'
// PHP
bin2hex(inet_pton('192.168.1.10')); // c0a8010a
-- MySQL
SELECT HEX(INET_ATON('192.168.1.10')); -- C0A8010A
// JavaScript
'192.168.1.10'.split('.').map(n => (+n).toString(16).padStart(2, '0')).join('')
# Bash
printf '%02X' 192 168 1 10; echo # C0A8010A
None of these accept a /prefix. Strip the prefix first, or let the converter handle the mask.
Where this page stops
- Dotted IPv4 only. A bare integer such as 3232235786 gets refused. Decode one with Decimal to IP first.
- No leading zeros. 192.168.010.1 means 192.168.8.1 to
inet_aton()and 192.168.10.1 to most other parsers. Type the address without the zero so there is one answer. - No hostnames. Resolve toolexe.com with Website to IP, then convert the address.
- One direction. To turn C0A8010A or a reversed /proc/net/tcp value back into an address, use Hex to IP.
- One prefix, no subnet planning. Mask, network, and last address come out. Host counts per split and VLSM layouts belong in a subnet calculator.