How to write bash script to subdivide a given subnet into a pre-defined number of smaller subnets?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to write bash script to subdivide a given subnet into a pre-defined number of smaller subnets?
# 1  
Old 10-23-2015
Linux How to write bash script to subdivide a given subnet into a pre-defined number of smaller subnets?

Bash script to subdivide a given subnet into a pre-defined number of smaller subnets. Show network/broadcast address, number of hosts and assign gateway.
For example:
Input:
./subnetter.sh 192.168.0.0/24 3 Output:
192.168.0.0/128 subnet 192.168.0.0 broadcast 192.168.0.127 gateway 192.168.0.100 hosts 125 192.168.0.128/192 subnet 192.168.0.128 broadcast 192.168.0.191 gateway 192.168.0.150 hosts 61 192.168.0.192/192 subnet 192.168.0.192 broadcast 192.168.0.255 gateway 192.168.0.200 hosts 61
# 2  
Old 10-23-2015
Moderator's Comments:
Mod Comment This appears to be a duplicate of the thread How to write bash script to subdivide a given subnet into a pre-defined number of smaller subnets?

This thread is closed. Please continue any discussion on this topic in that thread.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to write bash script to subdivide a given subnet into a pre-defined number of smaller subnets?

Bash script to subdivide a given subnet into a pre-defined number of smaller subnets. Show network/broadcast address, number of hosts and assign gateway. For example: Input: ./subnetter.sh 192.168.0.0/24 3 Output: 192.168.0.0/128 subnet 192.168.0.0 broadcast 192.168.0.127 gateway... (1 Reply)
Discussion started by: mail2rias
1 Replies

2. Shell Programming and Scripting

Comparing floating number and replace the smaller one with awk?

Hi guys, I tried to write a script for replacing some number in a bunch of files. However, I failed because my limited bash scripting knowledge. Here I will explain the expected function: I have many data files need to be processed. Here shows one part of a file as an example: a list with... (7 Replies)
Discussion started by: liuzhencc
7 Replies

3. Shell Programming and Scripting

Need an automated pre-defined file pickup method

Hi Gurus, I need to develop a script which picks the files in a pre-defined order. The files from monday-friday will be named as abc_01_20130923 as monday's file and abc_02_20130924 as tuesday's..so..so forth till friday's which will be named as abc_05_20130927.It repeats over for the... (3 Replies)
Discussion started by: vikramgk9
3 Replies

4. Shell Programming and Scripting

Breaking out ip subnet to smaller subnets

I have a script and it works fine, but I am sure this can be shrunk down to something much better. I would appreciate someone taking a crack at it for me. What it does is take the ip block submitted and breaks it out down to /24's. #!/bin/ksh ipadd=${1} octet1=`echo $ipadd | nawk -F.... (3 Replies)
Discussion started by: numele
3 Replies

5. Shell Programming and Scripting

Preventing script from being replicated on a defined number of hosts

ok. i have an extensive program written predominantly in borne shell. i have to give an "evaluation" copy of this program to a user so she can test it out and see if she wants it. problem is, i dont have an evaluation copy. and even if i did, im worried the evaluation copy can be edited to... (8 Replies)
Discussion started by: SkySmart
8 Replies

6. Shell Programming and Scripting

Number of lines smaller than specified value

Hi All, I have a problem to find number of lines per column smaller than the values given in a different file. In example, compare the 1st column of file1 with the 1st line of the file2, 2nd column of file1 with the 2nd line of the file2, etc cat file1 0.2 0.9 0.8 0.5 ... 0.6 0.5... (9 Replies)
Discussion started by: senayasma
9 Replies

7. Shell Programming and Scripting

Bash script for ping in your own subnet

I have a question for one who wants to help me. I want to create a bash script to ping IP-adresses. It must first ask me the beginnen IP, then the ending IP like: 192.168.100.1 - 192.168.100.255. When nothing is filled in, then it must find my subnet and ping that, like when my ip is... (14 Replies)
Discussion started by: ugurgazi
14 Replies

8. Homework & Coursework Questions

How to write script in bash.

I am very new to Linux/Unix. Kindly assist the following: I wish to write a bash shell script called how_many_to_go that calculates and prints the number of days, hours, minutes and/or seconds until the end of the current month (based on the output of the date command). Do ... (2 Replies)
Discussion started by: alobi
2 Replies

9. Shell Programming and Scripting

Can anybody write this bash script ?

hi, first congratulations on the nice forum! Can anybody write script, which can make copy of some or all files of the current directory in new directory (called "backups", which must be made in the current directory, if it's not already exist). And bring out a massage (report) with the count... (7 Replies)
Discussion started by: Cecko
7 Replies

10. Programming

pre defined variables

Hi First I want to explain the scenerio : In my project I want to control the printing of some messages. Thats why I use #ifdef MESSAGE ------------print message-------------- #endif And when I compile the program with -DMESSAGE option, it shows all message and without -DMESSAGE option... (7 Replies)
Discussion started by: sumsin
7 Replies
Login or Register to Ask a Question