script for netmask check


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script for netmask check
# 1  
Old 08-16-2005
script for netmask check

I want develop a script which should also check validity of netmask.
e.g.
/etc/netmasks
10.15.20.30 255.255.255.224

How can I check which IP adresses are valid for this netmask?
I think the best is use logical operations.
224 is 1 1 1 0 0 0 0 0

so is valid from 10.15.20.31 until 60
How is possible to check this with Solaris script ?

Best regards
Dieter
# 2  
Old 08-16-2005
You could do that, but you could also take the individual fields of the netmask, subtract them from 255 and add to your network address:

ie something like:
Code:
echo 10.15.20.30 255.255.255.224 | nawk -F'[    .]' '{print "ADDRESS RANGE:  " $1"."$2"."$3"."$4" - "255-$5+$1"."255-$6+$2"."255-$7+$3"."255-$8+$4}'

# 3  
Old 08-17-2005
netmasks

Hallo Reborg,

Very good, thank You for Your help.

Best regards
Dieter
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 change ip addressing format from CIDR notation to netmask and vice versa?

Hi all, I would appreciate if someone could share how to convert CIDR notation to netmask and vice versa. The value below is just an example. it could be different numbers/ip addresses. Initial Output, let say file1.txt Final Output, let say file2.txt (3 Replies)
Discussion started by: type8code0
3 Replies

2. Solaris

Netmask settings in Solaris 11

I have net0 as my primary network interface in Solaris 11. # ifconfig net0 net0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2 inet 10.53.77.154 netmask ffffff00 broadcast 10.53.77.255 ether 0:10:e0:3a:c4:d8 Its netmask should be fffffc00, but whenever I... (8 Replies)
Discussion started by: solaris_1977
8 Replies

3. Shell Programming and Scripting

script to check if another script is running and if so, then sleep for sometime and check again

Hi, I am a unix newbie. I need to write a script to check wheteher another script is still running. If it is, then sleep for 30m and then check again if the script is running. If the script has stopped running then, I need to come out of the loop. I am using RHEL 5.2 (2 Replies)
Discussion started by: mathews
2 Replies

4. Shell Programming and Scripting

how to calculate netwrk from IP address and netmask using Bitwise AND in shell script

Hi, I am having two variables IP="10.150.12.1" netmask="255.255.255.0" To get network number, I know that a bitwise & will help. networkno=IP & netmask My code is #!/usr/bin/ksh ip="10.150.12.1" netmask="255.255.255.0" networkno="$ip" & "$netmask" echo $networkno I am... (7 Replies)
Discussion started by: chaitanyapn
7 Replies

5. Solaris

ifconfig - making netmask & broadcast address permanent?

hi, I am trying to configure one of my interfaces, but after reboot - i lose the changes to the netmask & broadcast address. I have added an entry in /etc/netmasks, but it doesnt pick up the new settings. any ideas - much appreciated. before reboot: eri0:... (3 Replies)
Discussion started by: badoshi
3 Replies

6. IP Networking

Netmask change online

Hi, I have a system which has been setup with a netmask of 255.255.252.0 . The customer says this netmask is wrong as is causing them some problems. They want me to change it too 255.255.254.0 So what would the command be for my bge0 port. Can I do this whilst its running the software ?... (1 Reply)
Discussion started by: Maillot Jaune
1 Replies

7. UNIX for Advanced & Expert Users

nfs exports and netmask option

Setting up nfs on a redhat ES 4 gives me following issue that i can't explain. My nfs was working perfect whith following /etc/exports on the server /home/test/nfstest 198.9.200.227(rw,sync,no_root_squash) But after a powerloss and restart of the server it only works with the... (0 Replies)
Discussion started by: progressdll
0 Replies

8. UNIX for Dummies Questions & Answers

Script to check for a file, check for 2hrs. then quit

I wish to seach a Dir for a specific file, once the file is found i will perform additional logic. If the file is not found within two hours, i would like to exit. Logically, I'm looking for the best way to approach this Thanks for any assistance in advance. Note: I'm using a C shell and... (2 Replies)
Discussion started by: mmarsh
2 Replies

9. IP Networking

Netmask

Hi, On our new Solaris machine I have set up a network card with an IP of 10.44.12.102 , netmask of 255.255.252.0 and broadcast 19.44.15.255. These are to match current configuration on the other servers (running an older Solaris). However , after the machine is rebooted the ifconfig -a displays... (2 Replies)
Discussion started by: markdr011
2 Replies

10. Linux

Change IP, Netmask, Default GW on linux

How can I permenantly change the IP, netmask and default GW for Linux server on Apatchi. (2 Replies)
Discussion started by: salhoub
2 Replies
Login or Register to Ask a Question