https://www.cyberciti.biz/faq/linux-subnet-calculator-cidr/
Linux: IP Subnet (CIDR) Calculator That Will Help You With Network Settings
last updated in Linux, Networking, UNIXLinux and Unix-like systems comes with various IP subnet calculators that will help you with network settings:
[a] Sipcalc is an is an “advanced” console based ip subnet calculator.[donotprint][/donotprint] In its simplest form it takes an ip-address and a subnet mask on the CLI and outputs information about the subnet. Sipcalc IPv4 features:
- Retrieving of address information from interfaces.
- Classful and CIDR output.
- Multiple address and netmask formats (dotted quad, hex, number of bits).
- Output of broadcast address, network class, Cisco wildcard, hosts/range, network range.
- Output of a userdefined number of extra networks.
- The ability to “split” a network based on a smaller netmask, now also with recursive runs on the generated subnets.
- DNS resolution.
Sipcalc IPv6 features:
- Compressed and expanded input addresses.
- Compressed and expanded output.
- Standard IPv6 network output.
- Reverse dns address generation.
- The ability to “split” a network based on a smaller netmask, now also with recursive runs on the generated subnets.
- DNS resolution.
[b] Whatmask is another tool will help you with network settings. It displays the following information given IP address and/or netmask:
- The netmask in the following formats: CIDR, Netmask, Hex, Wildcard Bits
- The Network Address
- The Broadcast Address
- The number of Usable IP Addresses
- The First Usable IP Address
- The Last Usable IP Address
In this tutorial, I’m going to explain how to install and use these two tools.
Sipcalc installation
You can install it as follows on a Debian or Ubuntu Linux using the apt-get command:
Sample outputs:
$ sudo apt-get update
$ sudo apt-get install sipcalc
Sample outputs:
Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: sipcalc 0 upgraded, 1 newly installed, 0 to remove and 51 not upgraded. Need to get 30.6kB of archives. After this operation, 123kB of additional disk space will be used. Get:1 http://archive.ubuntu.com/ubuntu/ lucid/universe sipcalc 1.1.4-2 [30.6kB] Fetched 30.6kB in 2s (15.1kB/s) Selecting previously deselected package sipcalc. (Reading database ... 203411 files and directories currently installed.) Unpacking sipcalc (from .../sipcalc_1.1.4-2_i386.deb) ... Processing triggers for man-db ... Processing triggers for doc-base ... Processing 1 added doc-base file(s)... Registering documents with scrollkeeper... Setting up sipcalc (1.1.4-2) ...
On a CentOS/RHEL/Fedora Linux type the following yum command (first enable EPEL repo):
Sample outputs:
# yum install sipcalc
Sample outputs:
On a FreeBSD Unix operating system type the following command to install the sipcalc via port
Or add the package
# cd /usr/ports/net-mgmt/sipcalc/ && make install clean
Or add the package
# pkg install net-mgmt/sipcalc
How do I calculate subnets using sipcalc command?
Here is an example:
Sample outputs:
$ sipcalc 192.168.1.0/24
Sample outputs:
The above will provide network start & stop range, wildcard, mask and other information. You can calculate 192.168.1.0/24 subnet as follows:
Sample outputs:
$ sipcalc -a 192.168.1.0/24
Sample outputs:
Interface specific calculation example
Instead of taking address information from the shell command line arg sipcalc can obtain relevant information by looking at a specified interface on the system. In this example, get information for eth0 interface on a Linux based system:
Sample outputs:
$ sipcalc eth0
Sample outputs:
-[int-ipv4 : eth0] - 0 [CIDR] Host address - 192.168.3.254 Host address (decimal) - 3232236542 Host address (hex) - C0A803FE Network address - 192.168.3.0 Network mask - 255.255.255.0 Network mask (bits) - 24 Network mask (hex) - FFFFFF00 Broadcast address - 192.168.3.255 Cisco wildcard - 0.0.0.255 Addresses in network - 256 Network range - 192.168.3.0 - 192.168.3.255 Usable range - 192.168.3.1 - 192.168.3.254
To read more about its option type:
Sample outputs:
$ sipcalc --help
Sample outputs:
Say hello to whatmask utility
The whatmask tool can easily convert between three common subnet mask notations.
whatmask command installation
You can install it as follows on a CentOS/RHEL/Fedora Linux using yum command:
Sample outputs:
# yum install whatmask
Sample outputs:
On a FreeBSD based Unix server you can install it via the port:
Or add the package
Finally, you can download and compile the source code as follows too:
# cd /usr/ports/net-mgmt/whatmask/ && make install clean
Or add the package
# pkg install net-mgmt/whatmask
Finally, you can download and compile the source code as follows too:
$ cd /tmp
$ wget http://downloads.laffeycomputer.com/current_builds/whatmask/whatmask-1.2.tar.gz
$ tar -zxvf whatmask-1.2.tar.gz
$ cd whatmask-1.2/
$ ./configure
$ make
$ sudo make install
How do I use the whatmask tool?
You can use it as follows to find out usable ip address with /29 subnet:
Sample outputs:
$ whatmask {netmask}
$ whatmask {ip/netmask}
$ whatmask /29
Sample outputs:
--------------------------------------------- TCP/IP SUBNET MASK EQUIVALENTS --------------------------------------------- CIDR = .....................: /29 Netmask = ..................: 255.255.255.248 Netmask (hex) = ............: 0xfffffff8 Wildcard Bits = ............: 0.0.0.7 Usable IP Addresses = ......: 6
OR use ip/netmask syntax:
Sample outputs:
$ whatmask 202.54.1.2/27
Sample outputs:
------------------------------------------------ TCP/IP NETWORK INFORMATION ------------------------------------------------ IP Entered = ..................: 202.54.1.2 CIDR = ........................: /27 Netmask = .....................: 255.255.255.224 Netmask (hex) = ...............: 0xffffffe0 Wildcard Bits = ...............: 0.0.0.31 ------------------------------------------------ Network Address = .............: 202.54.1.0 Broadcast Address = ...........: 202.54.1.31 Usable IP Addresses = .........: 30 First Usable IP Address = .....: 202.54.1.1 Last Usable IP Address = ......: 202.54.1.30
A few more examples:
No comments:
Post a Comment