Anda di halaman 1dari 7

About

Contact us
Forums
Home
Linux How-to & Tutorials
Shell Scripts
RSS/Feed

nixCraft

Linux Calculating Subnets with ipcalc and sipcalc Utilities


by nixCraft on November 19, 2007 6 comments LAST UPDATED March 8, 2008
in CentOS, Debian Linux, FreeBSD
If you need to calculate subnet under Linux use an IP Netmask/broadcast calculator called ipcal. You can calculate
IPv4 or IPv6 address. Supported features:
=> Multiple address and netmask input formats.
=> Retrieving of address information from interfaces.
=> Classfull and CIDR output.
=> Multiple address and netmask output formats (dotted quad, hex, number of bits).
=> Output of broadcast address, network class, Cisco wildcard, hosts/range, network range.
=> Output of multiple types of bitmaps.
=> Output of a user-defined number of extra networks.
=> Multiple networks input from commandline.
=> DNS resolutions of hostnames.
=> Compressed and expanded input addresses.
=> Compressed and expanded output.
=> Standard IPv6 network output.
=> v4 in v6 output.
=> Reverse dns address generation.
=> The ability to "split" a network based on a smaller netmask, also with recursive runs on the generated subnets.
[a] ipcalc : ipcalc takes an IP address and netmask and calculates the resulting broadcast, network, Cisco wildcard mask, and host range. By
giving a second netmask, you can design sub- and supernetworks. It is also intended to be a teaching tool and presents the results as easy to
understand binary values.
[b] sipcalc : Sipcalc is also an ip subnet calculator consisting of two parts. A plain text based console version, and web (cgi) based
counterpart. Sipcalc, in its simplest form takes an ip-address and a subnet mask on the commandline and outputs information about the
subnet. Sipcalc has support for both IPv4 and IPv6 addresses.

Install sipcalc and ipcalc


Use apt-get command:
$ sudo apt-get install sipcalc ipcalc

Please note that ipcalc is installed by default under RHEL / CentOS / Fedora Linux using initscripts package.

Examples
Let us see how to calculate subnets for 192.168.0.1/24:
$ ipcalc 192.168.0.1/24

Output:
Address:
Netmask:
Wildcard:
=>
Network:
HostMin:

192.168.0.1
255.255.255.0 = 24
0.0.0.255

11000000.10101000.00000000. 00000001
11111111.11111111.11111111. 00000000
00000000.00000000.00000000. 11111111

192.168.0.0/24
192.168.0.1

11000000.10101000.00000000. 00000000
11000000.10101000.00000000. 00000001

HostMax:
192.168.0.254
Broadcast: 192.168.0.255
Hosts/Net: 254

11000000.10101000.00000000. 11111110
11000000.10101000.00000000. 11111111
Class C, Private Internet

You can also try sipcalc:


$ sipcalc 192.168.0.1/24

Output:
-[ipv4 : 192.168.0.1/24] - 0
[CIDR]
Host address
- 192.168.0.1
Host address (decimal) - 3232235521
Host address (hex)
- C0A80001
Network address
- 192.168.0.0
Network mask
- 255.255.255.0
Network mask (bits)
- 24
Network mask (hex)
- FFFFFF00
Broadcast address
- 192.168.0.255
Cisco wildcard
- 0.0.0.255
Addresses in network
- 256
Network range
- 192.168.0.0 - 192.168.0.255
Usable range
- 192.168.0.1 - 192.168.0.254

More examples:
$ sipcalc 192.168.0.1 255.255.128.0 255.255.192.0

Output:
-[ipv4 : 192.168.0.1 255.255.128.0] - 0
[CIDR]
Host address
- 192.168.0.1
Host address (decimal) - 3232235521
Host address (hex)
- C0A80001
Network address
- 192.168.0.0
Network mask
- 255.255.128.0
Network mask (bits)
- 17
Network mask (hex)
- FFFF8000
Broadcast address
- 192.168.127.255
Cisco wildcard
- 0.0.127.255
Addresses in network
- 32768
Network range
- 192.168.0.0 - 192.168.127.255
Usable range
- 192.168.0.1 - 192.168.127.254
-[ipv4 : 255.255.192.0] - 0
[CIDR]
Host address
- 255.255.192.0
Host address (decimal) - 4294950912
Host address (hex)
- FFFFC000
Network address
- 255.255.192.0
Network mask
- 255.255.255.255
Network mask (bits)
- 32
Network mask (hex)
- FFFFFFFF
Broadcast address
- 255.255.192.0
Cisco wildcard
- 0.0.0.0
Addresses in network
- 1
Network range
- 255.255.192.0 - 255.255.192.0

Display results as HTML


$ ipcalc -h 192.168.0.1/255.255.128.0

For more options, please refer to man page:


$ man ipcalc
$ man sipcalc

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!


Featured Articles:
30 Cool Open Source Software I Discovered in 2013
30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
Top 30 Nmap Command Examples For Sys/Network Admins
25 PHP Security Best Practices For Sys Admins
20 Linux System Monitoring Tools Every SysAdmin Should Know
20 Linux Server Hardening Security Tips
Linux: 20 Iptables Examples For New SysAdmins
Top 20 OpenSSH Server Best Security Practices
Top 20 Nginx WebServer Best Security Practices
20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors

15 Greatest Open Source Terminal Applications Of 2012


My 10 UNIX Command Line Mistakes
Top 10 Open Source Web-Based Project Management Software
Top 5 Email Client For Linux, Mac OS X, and Windows Users
The Novice Guide To Buying A Linux Laptop
{ 6 comments read them below or add one }
1 Sk Shahin Rahman December 13, 2007 at 6:27 am
i am very much help full by this program but in i need another option for IP Range calculate
Reply
2 debug March 8, 2008 at 5:39 am
Woa Sk Shahin Rahman, this article is helpful. Guess what, you work with subnets you really should know how to do binary to
decimal and calculate all different type of subnets without these tools if needed, right? They are just for convenience and speed,
besides you can use these to calculate ranges.
Reply
3 debug March 8, 2008 at 5:42 am
Actually I just realized that you dont even need this tool to get range easily. You just look at how many host bits and then your
ranges are there counting with however many host bits there are.
Reply
4 Teststation June 29, 2008 at 2:33 pm
I LIKE-IT .
Reply
5 svar August 24, 2009 at 7:33 am
Any tutorials for calculating subnets? and to learn the casics of ip classification?
Reply
6 williamson johanson December 17, 2014 at 8:38 pm
The ipcalc that comes with red-hat and derivatives sucks.
The ipcalc for Linux Mint (the one in this article) is fantastic. They are not the same sadly.
How can I replace the one in red-hat/centos with this one?
Reply
Leave a Comment
Name *
E-mail *
Website

Notify me of followup comments via e-mail.


Submit

Tagged as: binary values, broadcast address, broadcast network, counterpart, dns resolutions, fedora linux, hex number, host range, input
formats, ip address, ip netmask, ip subnet calculator, ipcalc, ipcalc command, ipv6 addresses, multiple networks, netmask, simplest form,
sipcalc command, standard ipv6, subnet mask, teaching tool, web cgi, wildcard mask
Previous post: Does Ubuntu Linux kill / shorten hard disk life?
Next post: How to: Setup Asterisk PBX Easily with AsteriskNOW in 30 minutes

To search, type and hit enter


nixCraft
Seguir
+ 127.195

+1

nixCraft
Me gusta

A 68 046 personas les gusta nixCraft.

Plug-in social de Facebook

Related Posts

Security Through Obscurity: MAC Address Filtering ( Layer 2 Filtering )

Linux How to bind Qmail to specific IP address

HowTo: Recovering Linux Grub Boot Loader Password

Configure Static Routes In Debian or Red Hat Enterprise Linux

Lighttpd: Enable IPv6 Support

Linux Configure Netconsole To Log Messages Over UDP Network

Top 20 OpenSSH Server Best Security Practices

Linux wget: Your Ultimate Command Line Downloader

No Route to Host error and solution

SSH Public Key Based Authentication Howto

Latest Linux/Unix Q & A


FreeBSD Unix Show Mounted File Systems
Bash: Reissue And Repeat A Long Command Without Retyping It on a Linux, OS X & Unix
Apple OS X: Install X Window System XQuartz For SSH X11 Forwarding On a Mavericks or Yosemite
FreeBSD Force DHCP Client (dhclient) to Renew IP Address To Get A New Lease
How To Stress Test CPU and Memory (VM) On a Linux and Unix With Stress-ng
Glibc: GHOST Vulnerability Test To See If a Linux Sever Is Secure
How To Patch and Protect Linux Server Against the Glibc GHOST Vulnerability # CVE-2015-0235
How To Add Swap on FreeBSD Unix Systems
How To PFSense Configure Network Interface As A Bridge / Network Switch
How To Change Timezone on a CentOS 6 and 7
How to Run and Execute Command When I Log Out Of Linux Session?
Unix / Linux: Initialize Dot Files Without Restarting The Current Shell Session
How To Install MariaDB Databases on a FreeBSD v10 Unix Server
How To Extract a Tar Files To a Different Directory on a Linux/Unix-like Systems
How To Install Apache, MySQL, PHP stack on FreeBSD Unix Server
Check The Number Of MySQL Open Database Connections on Linux Or Unix-like Server
HowTo: Use ps, kill, nice, and killall To Manage processes in FreeBSD and OS X Unix Operating System
Install LEMP (Linux, Nginx, MySQL and PHP) Stack on Ubuntu Linux 14.04 LTS
How To Add, Delete, and Grant Sudo Privileges to Users on a FreeBSD Server
Set Up SSH Tunneling on a Linux / Unix / BSD Server To Bypass NAT

Subscribe to nixCraft
Learn something new about Linux/Unix by email
Enter your email address:

Subscribe
2004-2015 nixCraft. All rights reserved. Privacy Policy - Terms of Service - Questions or Comments - We are proudly powered by Linux

+ Nginx + WordPress.
The content is copyrighted to nixCraft and may not be reproduced on other websites.

Anda mungkin juga menyukai