Archive for July, 2006

Netmask Table

255.255.255.255       11111111.11111111.11111111.11111111    /32          Host (single address)
	
255.255.255.254       11111111.11111111.11111111.11111110    /31          Unusable
255.255.255.252       11111111.11111111.11111111.11111100    /30            4 IPs with   2 Usable
255.255.255.248       11111111.11111111.11111111.11111000    /29            8 IPs with   6 Usable
255.255.255.240       11111111.11111111.11111111.11110000    /28           16 IPs with  14 Usable
255.255.255.224       11111111.11111111.11111111.11100000    /27           32 IPs with  30 Usable
255.255.255.192       11111111.11111111.11111111.11000000    /26           64 IPs with  62 Usable
255.255.255.128       11111111.11111111.11111111.10000000    /25          128 IPs with 126 Usable
255.255.255.0         11111111.11111111.11111111.00000000    /24         256 IPs with  254 Usable 
                                                                                *”Class C”*
	
255.255.254.0         11111111.11111111.11111110.00000000    /23         
255.255.252.0         11111111.11111111.11111100.00000000    /22         
255.255.248.0         11111111.11111111.11111000.00000000    /21         
255.255.240.0         11111111.11111111.11110000.00000000    /20         
255.255.224.0         11111111.11111111.11100000.00000000    /19         
255.255.192.0         11111111.11111111.11000000.00000000    /18         
255.255.128.0         11111111.11111111.10000000.00000000    /17         
255.255.0.0           11111111.11111111.00000000.00000000    /16         
                                                                                *”Class B”*            
	
255.254.0.0           11111111.11111110.00000000.00000000    /15         
255.252.0.0           11111111.11111100.00000000.00000000    /14         
255.248.0.0           11111111.11111000.00000000.00000000    /13         
255.240.0.0           11111111.11110000.00000000.00000000    /12         
255.224.0.0           11111111.11100000.00000000.00000000    /11         
255.192.0.0           11111111.11000000.00000000.00000000    /10         
255.128.0.0           11111111.10000000.00000000.00000000    /9          
255.0.0.0             11111111.00000000.00000000.00000000    /8       
                                                                                *”Class A”*    
	
254.0.0.0             11111110.00000000.00000000.00000000    /7         
252.0.0.0             11111100.00000000.00000000.00000000    /6         
248.0.0.0             11111000.00000000.00000000.00000000    /5         
240.0.0.0             11110000.00000000.00000000.00000000    /4         
224.0.0.0             11100000.00000000.00000000.00000000    /3         
192.0.0.0             11000000.00000000.00000000.00000000    /2         
128.0.0.0             10000000.00000000.00000000.00000000    /1         
0.0.0.0               00000000.00000000.00000000.00000000    /0    
                                                                                *IP space*
	
*Note:* The first and last IP of a series are *NOT* usable and the first  
usable IP is normally set up for the router.
The 1st IP is the network address. The last IP is the broadcast address.
=====================================================================

Comments

Simple overwriting of files in current working directory

When I do server configurations for large numbers of domain names, I like keeping files organized specifically by their domain name, and then I have a sample file that I build off of.

Often times I want to create new configuration files from an existing directory of all of those domain names (for example, if I needed zone records for each one)

for x in `ls`; do cat /directory1/filename >> /directory2/new/$x; done

what it does is for every line in ls (of the current directory) it outputs a file into /directory2/new/(every line in LS)

It’s a great timesaver… and can be used in a bunch of different ways

for x in `ls`; do touch $x; done
update every file in the directory to current time, great for organizing your config directories when you have a known working config

for x in `cat list`; do rm -rf $x; done
cat a file and delete each file in list

the list goes on…

Comments

find modified files within last 24 hours, minutes, etc

This is a simple one that I tend to forget when I need it most… finding files in a current directory that have been modified within the last 24 hours… while I realize my standard ls -lgat gives me a list of all files, it sucks when your doing a directory of thousands of files..

so in comes find :)
——
find -mtime x [where x is how many days]
or
find -mmin x [where x is how many minutes]
——
Lets see this in action on my home directory.
$ find -mmin 1
[ no files found modified within 1 minute ]
$ find -mtime 5
[ no files found modified within 5 days ]
lets create one

$ touch test
$ find -mmin 1
.
./test
Bingo.
$

This can be expanded a bit, modified files are different then the last accessed, etc.

Just a useful one.

Comments