06-01-2016
Just wanted to understand this, is it safe to say that the second subnet starts after the broadcast address:
192.168.0.0 /22
255.255.252.0
192.168.0.0 – 192.168.(3).255(Broadcast address)
192.168.(4).0 – 192.168.(7).255(Broadcast address), then next subnet
192.168.(8).0 – 192.168.(11).255(Broadcast address), then next subnet
192.168.(12).0 – 192.168.(15).255(Broadcast address)
And so on...
Similarly for the below IP:
IP Address – 172.59.0.0
Custom Subnet Mask – 255.255.252.0
Broadcast Address – 172.59.3.255
172.59.0.0 - 172.59.3.255
172.59.4.0 - 172.59.7.255
172.59.8.0 - 172.59.11.255
172.59.12.0 - 172.59.15.255
And so on....
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Before I even attempt this, is it possible to grep for a pattern, maybe a partial sentence like "go to page 3", assign that to a variable and then use awk or something to pull out the 3 and assign it to a variable? So first I would have
Gotopg = "go to page 3"
then
page = 3 (9 Replies)
Discussion started by: k@ssidy
9 Replies
2. Shell Programming and Scripting
Hi
In my shell script, I'm trying to find the line count of a file and assign it to a variable.
LINE_COUNT=$(wc -l $FILE_NAME)
But when i display LINE_COUNT, i'm getting the linecount concatenated with the file name. I want only the number. How can i get the line count alone ? Someone... (2 Replies)
Discussion started by: janemary.a
2 Replies
3. HP-UX
hi all,
i want to know where i can add and IP address so when i do a "w", i can see what IP is assigned to which tty? i know in tru64 you just added an entry to /etc/hosts. this does not seem to be the case with hpux.
thanks (12 Replies)
Discussion started by: macgre_r
12 Replies
4. Shell Programming and Scripting
hi all,
in ksh, how do i assign the output of a find command to a variable, e.g
am trying something like this :
totalNoFiles=$(print find ./ -name "SystemOut*.log");
but when i echo $totalNoFiles it displays
find ./ -name "SystemOut*.log"
instead of the total number of... (2 Replies)
Discussion started by: cesarNZ
2 Replies
5. Shell Programming and Scripting
can we make a global variable and store character values and add other values to that variable ?? for example
a="hello, John"
and can we add value ". How are you? so
a can have
"hello, John. How are you?"
can someone help me?? (2 Replies)
Discussion started by: bonosungho
2 Replies
6. Shell Programming and Scripting
I want to print between the range two patterns if a particular pattern is present in between the two patterns. I am new to Unix. Any help would be greatly appreciated.
e.g.
Pattern1
Bombay
Calcutta
Delhi
Pattern2
Pattern1
Patna
Madras
Gwalior
Delhi
Pattern2
Pattern1... (2 Replies)
Discussion started by: joyan321
2 Replies
7. AIX
Hi admins
i want to assign new ip adress to my aix 5.3 machine which is in LPAR
ent3 Available Virtual I/O Ethernet Adapter (l-lan)
ent0 Available 05-08 2-Port 10/100/1000 Base-TX PCI-X Adapter (14108902)
ent1 Available 05-09 2-Port 10/100/1000 Base-TX PCI-X Adapter (14108902)
ent2... (0 Replies)
Discussion started by: newaix
0 Replies
8. Shell Programming and Scripting
Unable to get the value to a variable.
set -x
cd $HOME
echo "Enter the server name"
read a
echo $a
i=4
j=1
k = ps -ef | awk '/server1/{ print $4 }' | tail -$i | head -$j`
echo $k
When I do the same in command line it works, however the same does not work when I provide that in the... (1 Reply)
Discussion started by: venkidhadha
1 Replies
9. IP Networking
Hi All,
I'm a bit confused about assigning IP address from IP Ranges.
I am using this scenario below to understand.
Scenario
Adatum.com an international IT solutions company, is launching 12 new branches in a new country where they currently have no existing branches. The sWin CIO has asked... (3 Replies)
Discussion started by: TryllZ
3 Replies
10. Shell Programming and Scripting
Hi,
I couldn't find any thing on google about it and have been trying to figure this out but am not getting anywhere. I want to know if its possible through a script. I have a file with columns start time and end time separated by a comma, basically there are some other columns which I need to... (30 Replies)
Discussion started by: dsid
30 Replies
LEARN ABOUT DEBIAN
net::ipv4addr
IPv4Addr(3pm) User Contributed Perl Documentation IPv4Addr(3pm)
NAME
Net::IPv4Addr - Perl extension for manipulating IPv4 addresses.
SYNOPSIS
use Net::IPv4Addr qw( :all );
my ($ip,$cidr) = ipv4_parse( "127.0.0.1/24" );
my ($ip,$cidr) = ipv4_parse( "192.168.100.10 / 255.255.255.0" );
my ($net,$msk) = ipv4_network( "192.168.100.30" );
my $broadcast = ipv4_broadcast( "192.168.100.30/26" );
if ( ipv4_in_network( "192.168.100.0", $her_ip ) ) {
print "Welcome !";
}
etc.
DESCRIPTION
Net::IPv4Addr provides functions for parsing IPv4 addresses both in traditional address/netmask format and in the new CIDR format. There
are also methods for calculating the network and broadcast address and also to check if a given address is in a specific network.
ADDRESSES
All of Net::IPv4Addr functions accept addresses in many formats. The parsing is very liberal.
All these addresses would be accepted:
127.0.0.1
192.168.001.010/24
192.168.10.10/255.255.255.0
192.168.30.10 / 21
10.0.0.0 / 255.0.0.0
255.255.0.0
Those wouldn't though:
272.135.234.0
192.168/16
Most functions accepts the address and netmask or masklength in the same scalar value or as separate values. That is either
my($ip,$masklength) = ipv4_parse($cidr_str);
my($ip,$masklength) = ipv4_parse($ip_str,$msk_str);
USING
No functions are exported by default. Either use the ":all" tag to import them all or explicitly import those you need.
FUNCTIONS
ipv4_parse
my ($ip,$msklen) = ipv4_parse($cidr_str);
my $cidr = ipv4_parse($ip_str,$msk_str);
my ($ip) = ipv4_parse($ip_str,$msk_str);
Parse an IPv4 address and return in scalar context the address in CIDR format, in an array context the address and the mask length.
If the parameters doesn't contains a netmask or a mask length, in scalar context only the IPv4 address is returned and in an array
context the mask length is undefined.
If the function cannot parse its input, it croaks. Trap it using "eval" if you don't like that.
ipv4_broadcast
my ($broadcast) = ipv4_broadcast($ip_str);
my $broadcast = ipv4_broadcast($ip_str,$msk_str);
This function returns the broadcast address. If the input doesn't contain a netmask or mask length, the default netmask is assumed.
This function croaks if the input is invalid.
ipv4_network
my $cidr = ipv4_network($ip_str);
my $cidr = ipv4_network($cidr_str);
my ($net,$msk) = ipv4_network( $net_str, $msk_str);
In scalar context, this function returns the network in CIDR format in which the address is. In array context, it returns the network
address and its mask length as a two elements array. If the input is a host without a netmask or mask length, the default netmask is
assumed.
Again, the function croaks if the input is invalid.
ipv4_in_network
print "Yes" if ipv4_in_network( $cidr_str1, $cidr_str2);
print "Yes" if ipv4_in_network( $ip_str1, $mask_str1, $cidr_str2 );
print "Yes" if ipv4_in_network( $ip1, $mask1, $ip2, $msk2 );
This function checks if the second network is contained in the first one and it implements the following semantics :
If net1 or net2 is a magic address (0.0.0.0 or 255.255.255.255)
then this function returns true.
If net1 is a host, net2 will be in the same net only if
it is the same host.
If net2 is a host, it will be contained in net1 only if
it is part of net1.
net2 is only part of net1 if it is entirely contained in
net1.
Trap bad input with "eval" or else.
ipv4_chkip
if ($ip = ipv4_chkip($str) ) {
# Do something
}
Return the IPv4 address in the string or undef if the input doesn't contain a valid IPv4 address.
ipv4_cidr2msk
my $netmask = ipv4_cidr2msk( $cidr );
Returns the netmask corresponding to the mask length given in the input. As usual, croaks if it doesn't like your input (in this case
a number between 0 and 32).
ipv4_msk2cidr
my $masklen = ipv4_msk2cidr( $msk );
Returns the mask length of the netmask in the input. As usual, croaks if it doesn't like your input.
AUTHOR
Francis J. Lacoste <francis.lacoste@iNsu.COM>
COPYRIGHT
Copyright (c) 1999, 2000 iNsu Innovations Inc. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms as perl itself.
SEE ALSO
perl(1) ipv4calc(1).
perl v5.10.1 2010-07-26 IPv4Addr(3pm)