192.168.0.0
netmask address: 255.255.255.0
192.168.0.255
count: 256
0.0.168.192.in-addr.arpa
0.0-255.0-255.0-255
10.0-255.0-255.0-255
100.64-127.0-255.0-255
127.0-255.0-255.0-255
169.254.0-255.0-255
172.16-31.0-255.0-255
192.0.0.0-255
192.0.0.0-7
192.0.2.0-255
198.18-19.0-255.0-255
198.51.100.0-255
192.88.99.0-255
192.168.0-255.0-255
203.0.113.0-255
224-239.0-255.0-255.0-255
240-255.0-255.0-255.0-255
240-255.0-255.0-255.0-255
inet_aton(string)
inet_ntoa(number)
inet_mask(h)
inet_ntoa_reverse(number)
string
- IPv4 address stringnumber
- IPv4 address numberh
- shift-left count
inet_aton
returns 32-bit integer value of IPv4 address.inet_ntoa
returns string of IPv4 address.inet_mask
returns 32-bit integer value of IPv4 netmask address.inet_ntoa_reverse
returns domain name of IPv4 address for reverse lookup.
inet_aton("0.0.255.255"); // 65535
inet_ntoa(65535); // "0.0.255.255"
inet_mask(8); // -256 == 0xffffff00
inet_ntoa_reverse(65535); // "255.255.0.0.in-addr.arpa"
To get the network address 192.168.0.0
and the broadcast address 192.168.0.255
from 192.168.0.1/24
, the 32-bit interger \(w\) such as
\[
\begin{aligned}
w &= \text{255.255.255.255}\\
&= \underbrace{\underbrace{\text{11111111}_{(2)}}_{8\text{-bit}}.\underbrace{\text{11111111}_{(2)}}_{8\text{-bit}}.\underbrace{\text{11111111}_{(2)}}_{8\text{-bit}}.\underbrace{\text{11111111}_{(2)}}_{8\text{-bit}}}_{32\text{-bit}}\\
&= \lnot 0 \land (\text{ffffffff})_{16}.
\end{aligned}
\]
The network address \(n\) and the broadcast address \(b\) are obtained as follows:
\[
\begin{aligned}
n &= a \land (w \ll (32 - l) \land w) = \text{192.168.0.0},\\
b &= a \lor \lnot(w \ll (32 - l) \land w) = \text{192.168.0.255},
\end{aligned}
\]
where \(\ll\) means logical shift left, \(a = \text{192.168.0.1}\), \(l = 24\) and \(w\ll (32 - l) = \text{255.255.255.0} \land w\) means the netmask address such as
\[
\begin{aligned}
h &= 32 - l,\\
w \ll h \land w &= \underbrace{\underbrace{\text{11111111}_{(2)}.\text{11111111}_{(2)}.\text{11111111}_{(2)}}_{l(24)\text{-bit}}.\underbrace{\text{00000000}_{(2)}}_{h(8)\text{-bit}}}_{32\text{-bit}}\\
&= \text{255.255.255.0}.
\end{aligned}
\]
The address \(a\) is represented by the network part and the host part as follows:
\[
\begin{aligned}
a &= \text{192.168.0.1}/24,\\
&= \underbrace{\text{11000000}_{(2)}.\text{10101000}_{(2)}.\text{00000000}_{(2)}}_{l(24)\text{-bit network part}}.\underbrace{\text{00000001}_{(2)}}_{h(8)\text{-bit host part}}\\
\end{aligned}
\]
The number of addresses \(N\) is clearly \[ \begin{aligned} N &= 2^{32 - l} = 2^h\\ &= 2^8 = 256. \end{aligned} \]
Reverse lookup .in-addr.arpa
domain name is a 32-bit address with 8 bits each in reverse order and join them with a period in decimal such as
\[
\begin{aligned}
&\text{``1.0.168.192.in-addr.arpa''}.
\end{aligned}
\]