Skip to content

Commit 573ffce

Browse files
hatamiarash7gitbook-bot
authored andcommitted
GITBOOK-10: No subject
1 parent 1bc77ba commit 573ffce

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

docs/.gitbook/assets/ipcalc-sc.png

39.2 KB
Loading

docs/SUMMARY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
* [Get Tranco Rank](functions/tranco/get-tranco-rank.md)
2222
* [Download / Update Tranco](functions/tranco/download-update-tranco.md)
2323

24+
***
25+
26+
* [IP Address](ip-address/README.md)
27+
* [IP Calculator](ip-address/ip-calculator.md)
28+
2429
## Collaboration
2530

2631
* [Roadmap](collaboration/roadmap.md)

docs/ip-address/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
layout:
3+
title:
4+
visible: true
5+
description:
6+
visible: false
7+
tableOfContents:
8+
visible: true
9+
outline:
10+
visible: true
11+
pagination:
12+
visible: true
13+
---
14+
15+
# IP Address
16+
17+
This extension provides various functions for manipulating and analyzing IP addresses, including calculating networks, hosts, and subnet masks.

docs/ip-address/ip-calculator.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
layout:
3+
title:
4+
visible: true
5+
description:
6+
visible: false
7+
tableOfContents:
8+
visible: true
9+
outline:
10+
visible: true
11+
pagination:
12+
visible: true
13+
---
14+
15+
# IP Calculator
16+
17+
The `ipcalc` function takes an IP address and netmask and calculates the resulting broadcast, network, wildcard mask, and host range.
18+
19+
<figure><img src="../.gitbook/assets/ipcalc-sc.png" alt=""><figcaption><p>The result of <code>ipcalc</code>function</p></figcaption></figure>
20+
21+
It's a table function that provides various details about IP addresses including:
22+
23+
* Address
24+
* Netmask
25+
* Wildcard
26+
* Network / Hostroute
27+
* HostMin
28+
* HostMax
29+
* Broadcast
30+
* Hosts count
31+
32+
You can use this table function with your data easily:
33+
34+
```sql
35+
D CREATE OR REPLACE TABLE ips AS SELECT '127.0.0.1' AS ip UNION ALL SELECT '192.168.1.0/22';
36+
37+
D SELECT i.IP,
38+
(
39+
SELECT hostsPerNet
40+
FROM ipcalc(i.IP)
41+
) AS hosts
42+
FROM ips AS i;
43+
┌────────────────┬───────┐
44+
│ ip │ hosts │
45+
varchar │ int64 │
46+
├────────────────┼───────┤
47+
127.0.0.1254
48+
192.168.1.0/221022
49+
└────────────────┴───────┘
50+
```

0 commit comments

Comments
 (0)