Sponsored Content
Top Forums Shell Programming and Scripting Perl script to allocate next available IP from a range Post 302964208 by hcclnoodles on Tuesday 12th of January 2016 07:20:03 AM
Old 01-12-2016
Perl script to allocate next available IP from a range

Hi

I am looking to automate the process in PERL of allocating IP addresses from a set range of addresses (for example a /22 network 10.10.224.1 - 10.10.227.254)

I am able to query the IP addresses that are already in use in the above range, which will produce me a list like this for example

Code:
10.10.224.1
10.10.224.2
10.10.224.3
10.10.225.23
10.10.225.35
10.10.227.67
...
...

What I am trying to do is find a way of taking that list and determining the next available IP address for use within the boundaries of the netmask (so for example between 10.10.224.1 and 10.10.227.254) Naturally if this was just a standard list of numbers then it would be straightforward, but given they are IP addresses, its a bit more complex


does anyone know a good starting point for this or have any experience of setting up something similar?

Cheers
 

10 More Discussions You Might Find Interesting

1. AIX

allocate memory for shell script at runtime during execution--urgent critical help!!

How to allocate memory for a shell script on aix box at the time of execution i.e at runtime Are there any commands for AIX in specific Thanks in Advance (1 Reply)
Discussion started by: aixjadoo
1 Replies

2. UNIX for Dummies Questions & Answers

allocate memory for a shell script at runtime--urgent critical help!!!

How to allocate memory for a shell script on aix box at the time of execution i.e at runtime Are there any commands for AIX in specific Thanks in Advance (3 Replies)
Discussion started by: aixjadoo
3 Replies

3. UNIX for Advanced & Expert Users

Allocate memory for a shell script in Aix at runtime-urgent critical

How to allocate memory for a shell script on aix box at the time of execution i.e at runtime Are there any commands for AIX in specific Thanks in Advance (1 Reply)
Discussion started by: aixjadoo
1 Replies

4. Shell Programming and Scripting

Perl search and replace in range using variable

Hi. I have a file with asterisk field separators and backslash line terminators. The first field in each line names the line type. I am trying to process each range separately. Here's what the data looks like: BA*DATA\ LS*DATA1*DATA2*00020*\ TA*DATA1*DATA2*DATA3*\ TA*DATA1*DATA2*DATA3*\... (1 Reply)
Discussion started by: yoi2hot4ya
1 Replies

5. Shell Programming and Scripting

allocate user quota using perl script

Hi I'm a student who is studying system administration. I need to write a perl script to allocate disk quota to users. I'm using ubuntu and When I try to run edquota command in command line it says that Can't find file system with quota. pls help me. I tried to edit fstab. but didn't work. ... (1 Reply)
Discussion started by: piumali
1 Replies

6. Shell Programming and Scripting

time stamp perl script error out of range 1..31

Hi, while running the perl script i am getting this error message , Day '' out of range 1..31 at rsty.sh line 44 what do iam missing in the script, any suggestion #!/usr/bin/perl use Time::Local; my $wday = $ARGV; my $month = $ARGV; # convert the month shortname into 0-11 number if... (4 Replies)
Discussion started by: saha
4 Replies

7. Programming

Mod Perl 2 with byte range help

I am writing a mod perl 2 download module and I am facing the same issue as this guy. mp2 / Apache byterange filter | ModPerl | ModPerl If I remove the check for EOS in byterange_filter.c and recompile Apache2, the byte range filter is executed and the result is correct but I am not sure that... (0 Replies)
Discussion started by: metalbone
0 Replies

8. Programming

Perl : Numeric Range Pattern Matching

hi Experts just wondering if you can help me check a number between a specific range if i have an ip address , how can i say the valid number for ip between 1 to 254 something like this if ($ip ) =~ /.../ { } what the pattern i need to type thanks (3 Replies)
Discussion started by: doubando
3 Replies

9. Shell Programming and Scripting

Perl - quick inverse of a number range

Hello, I'm trying to find an nice solution for the following: 1) I have ranges of numbers (begin-end): 10-15, 20-30, 45-50 2) I have begin limit=0 and end limit=60. 3) I need to find out number ranges between begin limit and end limit that do not overlap with the ranges in item1. In this... (6 Replies)
Discussion started by: pn8830
6 Replies

10. Shell Programming and Scripting

How to put date range from a perl & sql script

Hi Guys, Can someone please help me on adding/inserting a variable date to an sql scipt? Basically I want to assign a 7 days date range. As shown below.. #!/usr/bin/perl use strict; use Env qw(ORACLE_HOME); my $SQLPLUS='/opt/oracle/product/10.1.0/db_1/bin/sqlplus -S... (1 Reply)
Discussion started by: pinpe
1 Replies
NETMASK(1)							   Debian Linux 							NETMASK(1)

NAME
netmask - a netmask generation and conversion program SYNOPSIS
netmask [ options ] spec [ spec ... ] DESCRIPTION
This program accepts and produces a variety of common network address and netmask formats. Not only can it convert address and netmask notations, but it will optimize the masks to generate the smallest list of rules. This is very handy if you've ever configured a firewall or router and some nasty network administrator before you decided that base 10 numbers were good places to start and end groups of machines. OPTIONS
-h, --help Print a summary of the options -v, --version Print the version number -d, --debug Print status/progress information -s, --standard Output address/netmask pairs -c, --cidr Output CIDR format address lists -i, --cisco Output Cisco style address lists -r, --range Output ip address ranges -x, --hex Output address/netmask pairs in hex -o, --octal Output address/netmask pairs in octal -b, --binary Output address/netmask pairs in binary -n, --nodns Disable DNS lookups for addresses DEFINITIONS
A spec is an address specification, it can look like: address One address. address1:address2 All addresses from address1 to address2. address1:+address2 All addresses from address1 to address1+address2. address/mask A group starting at address spanning mask. An address is an internet network address, it can look like: ftp.gnu.org An internet hostname. 209.81.8.252 A standard dotted quad internet address notation. 100 A decimal number (100 in this case). 0100 An octal number preceded by "0" (64 in this case). 0x100 A hexadecimal number preceded by "0x" (256 in this case). A mask is a network mask, it can look like: 255.255.224.0 A dotted quad netmask (netmask will complain if it is not a valid netmask). 0.0.31.255 A Cisco style inverse netmask (with the same checks). 8 The number of bits set to one from the left (CIDR notation). 010 The number of bits set to one from the left in octal. 0x10 The number of bits set to one from the left in hexadecimal. AUTHOR
netmask was written by Robert Stone. Some algorithm design and optimization was provided by Tom Lear. This manual page was written by Robert Stone. BUGS
Let me know if you find any. This man page is a bit more simplistic than I'd like, but I've forgotten most of the groff I once knew. SEE ALSO
ipchains(1), ipfwadm(8), netstat(8), route(8), routed(8), gated(8), tcpd(8) Debian Project 15 May 1999 NETMASK(1)
All times are GMT -4. The time now is 03:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy