The Subnet Calculator is a networking/subnetting API implemented using Python.
The application provides the following endpoints:
Returns the following details for the network specified in the request body:
The request body is in text/json format can be supplied in one of two forms, depending on the format in which the IP address is specified:
{
"ip_address": "172.16.35.123",
"subnet_mask": "255.255.240.0"
}
or:
{
"ip_address": "172.16.35.123/20"
}
Requests are sent using the POST verb.
A typical response is:
[
{
"broadcast": [172, 16, 47, 255],
"broadcast_binary": ["10101100", "00010000", "00101111", "11111111"],
"first": [172, 16, 32, 1],
"first_binary": ["10101100", "00010000", "00100000", "00000001"],
"last": [172, 16, 47, 254],
"last_binary": ["10101100", "00010000", "00101111", "11111110"],
"network": [172, 16, 32, 0],
"network_binary": ["10101100", "00010000", "00100000", "00000000"],
"network_bits": 20,
"subnet": [255, 255, 240, 0],
"subnet_binary": ["11111111", "11111111", "11110000", "00000000"]
}
]
Given an IP address and a subnet mask (or number of network bits) and a number of hosts or networks, calculate the subnet details for subnetting the supplied IP into one of:
The request body is in text/json format and can be supplied in several forms, depending on the format in which the IP address is specified:
{
"ip_address": "10.1.1.0",
"subnet_mask": "255.255.255.0",
"hosts": 14
}
or:
{
"ip_address": "10.1.1.0/24",
"hosts": 14
}
Requests are sent using the POST verb.
The request body is in text/json format and can be supplied in several forms, depending on the format in which the IP address is specified:
{
"ip_address": "10.128.192.0",
"subnet_mask": "255.255.192.0",
"networks": 30
}
or:
{
"ip_address": "10.128.192.0/18",
"networks": 30
}
Requests are sent using the POST verb.
The request body is in text/json format and can be supplied in several forms, depending on the format in which the IP address is specified:
{
"ip_address": "192.168.1.96",
"subnet_mask": "255.255.255.240",
"network_bits": 30
}
or:
{
"ip_address": "192.168.1.96/28",
"network_bits": 30
}
Requests are sent using the POST verb.
A typical response is as follows:
[
{
"network_bits": 23,
"networks": [
{
"broadcast": [10, 128, 193, 255],
"broadcast_binary": ["00001010", "10000000", "11000001", "11111111"],
"first": [10, 128, 192, 1],
"first_binary": ["00001010", "10000000", "11000000", "00000001"],
"last": [10, 128, 193, 254],
"last_binary": ["00001010", "10000000", "11000001", "11111110"],
"network": [10, 128, 192, 0],
"network_binary": ["00001010", "10000000", "11000000", "00000000"]
},
:
:
]
}
]
The "networks" element of the response is a list of network details for each of the calculated subnets.
Determines whether or not two IP addresses are on the same subnet. The request body is in text/json format and can be supplied in several forms, depending on the format in which the IP address is specified:
{
"ip_address_1": "10.1.255.1",
"ip_address_2": "10.1.128.2",
"subnet_mask": "255.255.128.0"
}
or:
{
"ip_address_1": "10.1.255.1/17",
"ip_address_2": "10.1.128.2/17"
}
Requests are sent using the POST verb.
A typical response is as follows:
{
"same_subnet": true
}
In order to run this image you'll need docker installed.
The following "docker run" parameters are recommended when running the naturerecorderpy image:
| Parameter | Value | Purpose |
|---|---|---|
| -d | - | Run as a background process |
| -p | 80:5000 | Expose the container's port 5000 as port 80 on the host |
| --rm | - | Remove the container automatically when it stops |
For example:
docker run -d -p 80:5000 --rm davewalker5/subnetcalculator:latest
To run the image, enter the following commands:
docker run -d --rm davewalker5/subnetcalculator:latest
Once the container is running, browse to the following, requests can be sent to it as described above using Postman or an equivalent application.
The subnetcalculator image was been built with the following:
| Aspect | Version |
|---|---|
| Python | 3.10.0 |
| Docker Desktop | 4.21.1 (114176) |
Other dependencies and their versions are listed in the project's requirements.txt file
For the versions available, see the tags on this repository.
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE file for details.
Content type
Image
Digest
sha256:c2d515e6a…
Size
63.1 MB
Last updated
about 1 month ago
docker pull davewalker5/subnetcalculator