I've searched for options to list out all ip's in a given range, up to a class B. The best option I found was here on unix.com.
The input file has two entries, the beginning and ending ip. It works ok, except when trying to print out something like a /25. 10.1.1.0/25 will print all 255 ip's instead of 10.1.1.0 to 10.1.1.128.
---------- Post updated 06-02-10 at 10:09 AM ---------- Previous update was 06-01-10 at 05:49 PM ----------
Does any AWK guru's have any suggestions for me? Maybe if this is thought of as a number with four fields and each field can be a number from 0 to 255. I am only concerned with fields 3 and 4, for each 3rd field increase, 4th field will run though 1 to 255.
Input example, the first line is the starting address and the second line is the ending.
Output I would like is the list from beginning to end. The first and second fields can be different on each input but will never increment. Only fields 3 and 4 will increment from 0 to 255.
If you write a pair of functions which can convert ip addresses to-from quad-dotted string and integer representations (akin to inet_aton and inet_ntoa), then the task is just a for loop that runs so long as the current ip is less than or equal to the upper bound of the range. And, if you don't mind printing out the network address (which your example skips, e.g. 192.168.54.0), then you don't even have to bother with masks.
Regards,
Alister
---------- Post updated at 09:05 PM ---------- Previous update was at 08:59 PM ----------
Nevermind. I just noticed ...
Quote:
Originally Posted by numele
Does any AWK guru's have any suggestions for me? Maybe if this is thought of as a number with four fields and each field can be a number from 0 to 255. I am only concerned with fields 3 and 4, for each 3rd field increase, 4th field will run though 1 to 255.
You don't need anything so general as to require inet_aton/inet_ntoa functionality.
I ought to learn to look before I leap.
---------- Post updated at 09:44 PM ---------- Previous update was at 09:05 PM ----------
Perhaps this AWK may be of use to you:
Or this sh:
If you aren't using a BSD-ish system, then you may not have jot. In that case, should you wish to use the sh solution, check for the availability of seq (and adjust the commands accordingly).
Hi,
I have the following input in a file & need output as mentioned below(need counter of every occurance of field which is to be increased by 1).
Input:
919143110065
919143110065
919143110052
918648846132
919143110012
918648873782
919143110152
919143110152
919143110152... (2 Replies)
Hi,
My input files is like this
axis1 0 1 10
axis2 0 1 5
axis1 1 2 -4
axis2 2 3 -3
axis1 3 4 5
axis2 3 4 -1
axis1 4 5 -6
axis2 4 5 1
Now, these are my following tasks
1. Print a first column for every two rows that has the same value followed by a string.
2. Match on the... (3 Replies)
awk '{print "awk '{sub(/pdb_00/,"pdb_"$0"_00"); print}' pdb_"$0"_00.namd > tempo"; print "mv tempo pdb_"$0"_00.namd"}' datA2.dat > copy_script2.bash
This works when trying to print 'sed etc. etc' but if I switch to using AWK to print a set of AWK commands it doesn't work...
e.g. this... (3 Replies)
Hi. my english is not so good. sorry.
i have some problem. My isp give me second ip from subnet. One network is working, but secong don't.
fxp0 - my network
dc0 - network isp (that working)
re0 - network isp (don't working)
i try use ng_one2many, but it's don't working
ngctl mkpeer... (0 Replies)
What would be a realistic number of hosts in a 100BaseT network, before you have to start thinking on subnetting further?
Or in another words. How many hosts would you keep in the same broadcast domain?
In a 100BaseT network, with subnet 10.20.20.0/24, I could have 254 hosts as part of the same... (3 Replies)
Actually I got a list of file end with *.txt
I want to use the same command apply to all the *.txt
Thus I try to find out the fastest way to write those same command in a script and then want to let them run automatics.
For example:
I got the file below:
file1.txt
file2.txt
file3.txt... (4 Replies)
Hi,
My project needs to migrate the existing Subnet (255.255.255.0) to a new subnet and change the ipaddresses (currently C class). How can I do that. I need some information.
John (0 Replies)
The line is simple, use " '{ print $1"]"$2"\"$3THE " NEEDS TO GO HERE$4 }'
I've tried \", "\, ^" and '"" but none of it works. What am I missing? Putting in the [ between $1 and $2 works fine, I just need to do the same with a ".
Thanks. (2 Replies)
Hi,
I have about 30 computers for users with subnet mask x.x.x.0, and 25 computers for workers with s.m. x.x.x.128. My server has a s.m. x.x.x.128 so with workers computers I can see my server and all the computers in that s.m., but I can't see the server from the users computers and I need to see... (7 Replies)