100 likes | 235 Views
Another Script Exercise…. Compiling Source Code. First step we need to get the software From the shell prompt type: scp <yourid@192.168.211.54:/home/whatmask.tgz . ^
E N D
Compiling Source Code • First step we need to get the software • From the shell prompt type: scp <yourid@192.168.211.54:/home/whatmask.tgz . ^ (a space) While you are at it get this file too: scp <yourid@192.168.211.54:/home/ips.txt .
Compiling Source Code • Now you should have in your $HOME directory two files. One called: whatmask.tgz and one called: ips.txt • Remember a simple ls command will confirm this. • Remember to download this files are your normal user ID and not as root.
Compiling Source Code • Now we need to unzip the file so from the shell prompt type: tar –xzvf whatmask-1.2.tar.gz • Then change into the directory cd whatmask-1.2/
Compiling Source Code • The first thing you want to do is get a directory listing so you know what you’re dealing with • Files to make note of are: • README, INSTALL, Makefile, configure, etc. • In this case we need to run the configure script ./configure
Compiling Source Code • Once the configure script runs with no errors then we need to compile the program • To just compile type: make • It is best to run make as a normal user because you didn’t personally verify all the source code and config files did you? • To install type: make install
Compiling Source Code • Now test your program by typing the following: whatmask 192.168.0.0/24 • Everyone knows what CIDR means – right? • Classless Inter-Domain Routing • It’s the /24 which is a 24-bit subnet mask or 255.255.255.0 so try it again… whatmask 192.168.0.0/255.255.255.0
Now the Scenario… Your boss gives you a list of networks that the evildevelopers want opened up on Premise Sidewinder (UNIX) Firewall that you are responsible for. After looking over the list you come to the conclusion that it would expose your network to a very large number of IP addresses. You realize that in order to prove this to your boss you need to come up with the total number of IP addresses. So you decide to write a shell script get the answer.
Tools you will need…. • Your trusty Linux server • A shell prompt • The worlds most powerful editor (vi) • The whatmask program you recently installed • The list of networks and subnet masks your boss gave you (ips.txt) • And the secret incantation that will add up all the totals y=$(($y+$x))
And the answer is…… 8,568,800