CIDR to netmask is straightforward if tedious -- just binary math. Shells aren't generally that good at it but modern BASH has large enough numbers to handle this.
If you have an older bash, it may generate negative values due to overflowing its 32-bit integers.
please let me know that in unix using c programming language we can do binary to string conversion and vice versa using ltoa and atol but how can we do it in c++ programming language.
thank you in advance. (3 Replies)
Hello,
can sed be used to convert all letters of a file from uppercase to lowercase and vice versa?i know tr command can be used but with sed is it possible?
i came up with this :-
sed 'y///' file1
actually the above command is also not working! Please help me. Thanks in advance :) (6 Replies)
Hi,
I have a pdf file. i want to convert it to text file and do some work on it and later want to convert it back to pdf. Can this be done via unix?
or
Is there a way unix can directly work on PDF file? (2 Replies)
Hi,
I am new to Unix and discovered this example problem online that I believe will help my learning:
Run the command's below
env >> xx
env >> xx
env >> xx
env >> xx
env >> xx
You will now have a file called XX with the env redirected into it 5 times
Create a script named... (2 Replies)
i am thinking of replacing my vista with ubuntu.
Questions:
1) what will be the advantages and disadvantages of using ubuntu instead of vista?
2) what will be the setbacks of replacing my vista?
3) how hard is it to cope up with the new OS? what must i learn to utilize ubuntu? (1 Reply)
Hi
I have a system PRIMARY where I can push or pull files to/from STANDBY using scp. I can also ssh without entering a password.
On the STANDBY system if I try and use scp or ssh it asks for a password.
I checked in ~/.ssh and there was no authorized_keys file on the PRIMARY server. After... (2 Replies)
I need to write a script that will take the input from a file and convert the number from centigrade to fahrenheit and vice versa.
This is what I have but it doesn't seem to be correct.
Also the data file has 11 numbers inside of it and the output needs to be listed as so:
Fahrenheit Temperature... (18 Replies)
Hi all,
I installed Oracle virtual box 4.1.8 on my desktop. I installed Windows 2008 server R2 as one instance and Solaris 10 as another instance. When am trying to ping from Windows to solaris and vice-versa, ping not working.
windows IP : 10.1.47.24
Solaris IP : 10.1.47.25
netstat... (2 Replies)
Hi,
In unix or linux is there any command exist to identify Host Name to IP Address or Vice Versa?
Thanks in advance (6 Replies)
Discussion started by: nag_sathi
6 Replies
LEARN ABOUT DEBIAN
paranoid::network::ipv4
Paranoid::Network::IPv4(3pm) User Contributed Perl Documentation Paranoid::Network::IPv4(3pm)NAME
Paranoid::Network::IPv4 - IPv4-related functions
VERSION
$Id: IPv4.pm,v 0.1 2012/05/29 21:37:44 acorliss Exp $
SYNOPSIS
use Paranoid::Network::IPv4;
@net = ipv4NetConvert($netAddr);
$rv = ipv4NetIntersect($net1, $net2);
or
use Paranoid::Network::IPv4 qw(:all);
print "Valid IP address
" if $netAddr =~ /^@{[ IPV4REGEX ]}$/;
@net = ipv4NetConvert($netAddr);
$broadcast = $net[IPV4BRDCST];
DESCRIPTION
This module contains a few convenience functions for working with IPv4 addresses.
By default only the subroutines themselves are imported. Requesting :all will also import the constants as well.
SUBROUTINES /METHODS
ipv4NetConvert
@net = ipv4NetConvert($netAddr);
This function takes an IPv4 network address in string format and converts it into an array containing the base network address, the
broadcast address, and the netmask, in integer format. The network address can have the netmask in either CIDR format or dotted quads.
In the case of a single IP address, the array with only have one element, that of the IP in integer format.
Passing any argument to this function that is not a string representation of an IP address (including undef values) will cause this
function to return an empty array.
ipv4NetIntersect
$rv = ipv4NetIntersect($net1, $net2);
This function tests whether an IP or subnet intersects with another IP or subnet. The return value is essentially boolean, but the true
value can vary to indicate which is a subset of the other:
-1: destination range encompasses target range
0: both ranges do not intersect at all
1: target range encompasses destination range
The function handles the same string formats as ipv4NetConvert, but will allow you to test single IPs in integer format as well.
CONSTANTS
These are only imported if explicity requested or with the :all tag.
MAXIPV4CIDR
Simply put: 32. This is the largest CIDR notation supported in IPv4.
IPV4REGEX
Regular expression: qr/(?:d{1,3}.){3}d{1,3}/sm
You can use this for validating IP addresses as such:
$ip =~ m#^@{[ IPV4REGEX ]}$#;
or to extract potential IPs from extraneous text:
(@ips) = ( $string =~ m#(@{[ IPV4REGEX ]})#gsm);
IPV4CIDRRGX
Regular expression:
qr#(@{[ IPV4REGEX ]})(?:/(d+|@{[ IPV4REGEX ]}))?#sm
By default this will extract an IP or CIDR notation network address:
($net, $mask) = ( $ip =~ m#^@{[ IPV4CIDRRGX ]}$# );
In the case of a simple IP address $mask will be undefined.
IPV4BASE
This is the ordinal index of the base network address as returned by ipv4NetConvert.
IPV4BRDCST
This is the ordinal index of the broadcast address as returned by ipv4NetConvert.
IPV4MASK
This is the ordinal index of the network mask as returned by ipv4NetConvert.
DEPENDENCIES
o Paranoid
o Paranoid::Network::Socket
BUGS AND LIMITATIONS AUTHOR
Arthur Corliss (corliss@digitalmages.com)
LICENSE AND COPYRIGHT
This software is licensed under the same terms as Perl, itself. Please see http://dev.perl.org/licenses/ for more information.
(c) 2012, Arthur Corliss (corliss@digitalmages.com)
perl v5.14.2 2012-05-29 Paranoid::Network::IPv4(3pm)