Linux Shortcuts and Commands

Linux Shortcuts
and Commands:

Linux Newbie
Administrator Guide

by Stan and Peter Klimas

This is a practical selection of the commands we use most often. Press
<Tab>
to see the listing of all available command (on your PATH). On my small
home system, it says there are 2595 executables on my PATH.  Many
of these “commands” can be accessed from your favourite GUI front-end (probably
KDE or Gnome) by clicking on the right menu or button. They can all be
run from the command line.  Programs that require GUI have to be run
from a terminal opened under a GUI.

Legend:

<> = single special or function key on the keyboard. For example
<Ctrl> indicates the “control” key.

italic = name of the file or variable you probably want to substitute
with your own.

fixed width = in-line Linux commands and filenames.

Notes for the UNIX Clueless:

1. LINUX IS CASE-SENSITIVE. For example: Netscape, NETSCAPE and nEtscape
are three different commands. Also my_filE, my_file, and my_FILE are three
different files. Your user login name and password are also case sensitive.
(This goes with the tradition of UNIX and the “c” programming language
being case sensitive.)

2. Filenames can be up to 256 characters long and can contain letters,
numbers, “.” (dot), “_” (underscore), “-” (dash), plus some other not recommended
characters.
3. Files with names starting with “.” are normally not shown by the
ls
(list) or dir commands. Think of these files as “hidden”. Use
ls -a
(list with the option “all”) to see these files.

4. “/” is an equivalent to DOS “\” (root directory, meaning the parent
of all other directories).

5. Under Linux, all directories appear under a single directory tree
(there are no DOS-style drive letters).

6. In a configuration file, a line starting with # is a comment.

7.1 Linux essential shortcuts and sanity commands

<Ctrl><Alt><F1>
Switch to the first text terminal. Under Linux you can have several
(6 in standard setup) terminals opened at the same time.

<Ctrl><Alt><Fn> (n=1..6)

Switch to the nth text terminal.

tty

Print the name of the terminal in which you are typing this command.

<Ctrl><Alt><F7>

Switch to the first GUI terminal (if X-windows is running on this terminal).

<Ctrl><Alt><Fn> (n=7..12)
Switch to the nth GUI terminal (if a GUI terminal is running on screen
n-1). On default, nothing is running on terminals

8 to 12, but you can run another server there.

<Tab>

(In a text terminal) Autocomplete the command  if there is only
one option, or else show all the available options.

THIS SHORTCUT IS GREAT! It even works at LILO prompt!

<ArrowUp>

Scroll and edit the command history. Press <Enter> to execute.

<Shift><PgUp>
Scroll terminal output up. Work also at the login prompt, so you can
scroll through your bootup messages.

<Shift><PgDown>

Scroll terminal output down.

<Ctrl><Alt><+>

(in X-windows) Change to the next X-server resolution (if you set up
the X-server to more than one resolution). For multiple resolutions on
my standard SVGA card/monitor, I have the following line in the file
/etc/X11/XF86Config
(the first resolution starts on default, the largest determines the size
of the “virtual screen”):

Modes "1024x768" "800x600" "640x480" "512x384" "480x300" "400x300"
"1152x864"

<Ctrl><Alt><->
(in X-windows) Change to the previous X-server resolution.

<Ctrl><Alt><BkSpc>

(in X-windows) Kill the current X-windows server. Use if the X-windows
server crushes and cannot be exited normally.

<Ctrl><Alt><Del>

Shut down the system and reboot. This is the normal shutdown command
for a user at the text-mode console. Don’t just press the “reset” button
for shutdown!

<Ctrl>c

Kill the current process (mostly in the text mode for small applications).

<Ctrl>d
Log out from the current terminal.  See also the next command.

<Ctrl>d

Send [End-of-File] to the current process. Don’t press it twice else
you also log out (see the previous command).

<Ctrl>s

Stop the transfer to the terminal.

<Ctrl>q

Resume the transfer to the terminal. Try if your terminal mysteriously
stops responding.

<Ctrl>z
Send the current process to the background.

exit

Logout. I can also use logout for the same effect.  (If
you have started a second shell, e.g., using bash the second shell
will be exited and you will be back in the first shell, not logged out.)

reset

Restore a screwed-up terminal (a terminal showing funny characters)
to default setting. Use if you tried to “cat” a binary file. You may not
be able to see the command as you type it.

<MiddleMouseButton>
Paste the text which is currently highlighted somewhere else. This
is the normal “copy-paste” operation in Linux.  (It doesn’t work with
Netscape and WordPerfect which use the MS Windows-style “copy-paste”. It
does work in the text terminal if you enabled “gpm” service using “setup”.)
Best used with a Linux-ready 3-button mouse (Logitech or similar) or else
set “3-mouse button emulation”).

~

(tilde) My home directory (normally the directory /home/my_login_name).
For example, the command cd ~/my_dir will change my working
directory to the subdirectory “my_dir” under my home directory.

Typing just “cd” alone is an equivalent of the command “cd ~”.

.

(dot) Current directory. For example, ./my_program will attempt
to execute the file “my_program” located in your current working directory.

..

(two dots) Directory parent to the current one. For example, the command
cd
..
will change my current working directory one one level up.

7.2 Common Linux commands–system info

pwd
Print working directory, i.e., display the name of my current directory
on the screen.

hostname

Print the name of the local host (the machine on which you are working).
Use netconf (as root) to change the name of the machine.

whoami

Print my login name.

id
username

Print user id (uid) and his/her group id (gid), effective id (if different
than the real id) and the supplementary groups.

date

Print or change the operating system date and time. E.g., I could change
the date and time to 2000-12-31 23:57 using this command:
date 123123572000

To set the hardware (BIOS) clock from the system (Linux) clock, use
the command (as root) setclock

time

Determine the amount of time that it takes for a process to complete
+ other info. Don’t confuse it with the date command. E.g. I can
find out how long it takes to display a directory content using:

time ls

who

Determine the users logged on the machine.

rwho -a
(=remote who) Determine all users logged on your network. The rwho
service must be enabled for this command to run. If it isn’t, run setup
as root to enable “rwho”.

finger
user_name

System info about a user. Try: finger root

last

Show listing of users last logged-in on your system.

history | more

Show the last (1000 or so) commands executed from the command line
on the current account. The “| more” causes the display to stop after each
screenful.

uptime

Show the amount of time since the last reboot.

ps
(=print status) List the processes currently run by the current user.

ps axu | more

List all the processes currently running, even those without the controlling
terminal, together with the name of the user that owns each process.

top

Keep listing the currently running processes, sorted by cpu usage (top
users first). In KDE, you can get GUI-based Ktop from “K”menu under “System”-”Task
Manager” (or by executing “ktop” in an X-terminal).

uname -a

(= Unix name with option “all”) Info on your (local) server. I can
also use guname (in X-window terminal) to display the info more
nicely.

free

Memory info (in kilobytes).

df -h
(=disk free) Print disk info about all the filesystems (in human-readable
form)

du / -bh | more

(=disk usage) Print detailed disk usage for each subdirectory starting
at the “/” (root) directory (in human legible form).

cat /proc/cpuinfo

Cpu info–it show the content of the file cpuinfo. Note that
the files in the /proc directory are not real files–they are
hooks to look at information available to the kernel.

cat /proc/interrupts

List the interrupts in use.

cat /proc/version
Linux version and other info

cat /proc/filesystems

Show the types of filesystems currently in use.

cat /etc/printcap

Show the setup of printers.

lsmod

(As root. Use /sbin/lsmod to execute this command when you
are a non-root user.) Show the kernel modules currently loaded.

set|more

Show the current user environment.

echo $PATH
Show the content of the environment variable “PATH”. This command can
be used to show other environment variables as well. Use “set” to see the
full environment.

dmesg | less

Print kernel messages (the content of the so-called kernel ring buffer).
Press “q” to quit “less”. Use less /var/log/dmesg  to see
what “dmesg” dumped into this file right after the last system bootup.

7.3 Basic operations

any_command
--help |more

Display a brief help on a command (works with most commands). “–help”
works similar to DOS “/h” switch. The “more” pipe is needed if the output
is longer than one screen.

man
topic

Display the contents of the system manual pages (help) on the topic.
Try man man first. Press “q” to quit the viewer. The command info
topic

works similar and may contain more up-to-date information. Manual pages
can be hard to read. Try any_command --help for short,
easy to digest help on a command. If more info needed, have a look to the
directory /usr/doc. To display manual page from a specific section,
I may use something like in this example:  man 3 exit (this
displays an info on the command exit from section 3 of the manual
pages).

apropos
topic

Give me the list of the commands that have something to to do with
my topic.

help command

Display brief info on a bash (shell) build-in command.

ls

List the content of the current directory. Under Linux, the command
“dir” is an alias to ls. Many users have “ls” to be an alias to “ls –color”.

ls -al |more

List the content of the current directory, all files (also those starting
with a dot), and in a long form. Pipe the output through the “more” command,
so that the display pauses after each screenful.

cd
directory

Change directory. Using “cd” without the directory name will take you
to your home directory. “cd -” will take you to your previous directory
and is a convenient way to toggle between two directories. “cd ..” will
take you one directory up.

cp
source destination

Copy files. E.g., cp /home/stan/existing_file_name .
will copy a file to my current working directory. Use the “-r” option (for
recursive) to copy the contents of whole directories, e.g. , cp -r
my_existing/dir/ ~ 
will copy a subdirectory under my current
working directory to my home directory.

mcopy
source destination

Copy a file from/to a DOS filesystem (no mounting necessary). E.g.,
mcopy
a:\autoexec.bat ~/junk
. See man mtools for related commands:
mdir, mcd, mren, mmove, mdel, mmd, mrd, mformat ….

mv source destination

Move or rename files. The same command is used for moving and renaming
files and directories.

ln
source destination

Create a hard link called destination to the file called source.
The link appears as a copy of the original files, but in reality only one
copy of the file is kept, just two (or more) directory entries point to
it. Any changes the file are automatically visible throughout. When one
directory entry is removed, the other(s) stay(s) intact. The limitation
of the hard links are: the files have to be on the same filesystem, hard
links to directories or special files are impossible.

ln -s source destination

Create a symbolic (soft) link called “destination” to the file called
“source”. The symbolic link just specifies a path where to look for the
file. In contradistinction to hard links, the source and destination don’t
not have to tbe on the same filesystem. In comparison to hard links, the
drawback of symbolic links are: if the original file is removed, the link
is “broken”, symbolic links can also create circular references (like circular
references in spreadsheets or databases, e.g., “a” points to “b” and “b”
points back to “a”).

rm files

Remove (delete) files. You must own the file in order to be able to
remove it. On many systems, you will be asked or confirmation of deleation,
if you don’t want this, use the “-f” (=force) option, e.g., rm -f *
will remove all files in my current working directory, no questions asked.

mkdir
directory

Make a new directory.

rmdir
directory

Remove an empty directory.

rm -r files
(recursive remove) Remove files, directories, and their subdirectories.
Careful with this command as root–you can easily remove all files on the
system with such a command executed on the top of your directory tree,
and there is no undelete in Linux (yet). But if you really wanted to do
it (reconsider), here is how (as root):
rm -rf /*

cat filename | more

View the content of a text file called “filename”, one page a time.
The “|” is the “pipe” symbol (on many American keyboards it shares the
key with “\”) The pipe makes the output stop after each screenful. For
long files, it is sometimes convenient to use the commands head and tail
that display just the beginning and the end of the file. If you happened
to use “cat” a binary file and your terminal displays funny characters
afterwards, you can restore it with the command “reset”.

less
filename

Scroll through a content of a text file. Press q when done. “Less”
is roughly equivalent to “more” , the command you know from DOS, although
very often “less” is more convenient than “more”.

pico
filename

Edit a text file using the simple and standard text editor called pico.

pico -w filename

Edit a text file, while disabling the long line wrap. Handy for editing
configuration files, e.g. /etc/fstab.

find / -name "filename"

Find the file called “filename” on your filesystem starting the search
from the root directory “/”. The “filename” may contain wildcards (*,?).

locate
filename

Find the file name of which contains the string “filename”. Easier
and faster than the previous command but depends on a database that normally
rebuilds at night.

./program_name
Run an executable in the current directory, which is not on your PATH.

touch
filename

Change the date/time stamp of the file filename to
the current time. Create an empty file if the file does not exist.

xinit

Start a barebone X-windows server (without a windows manager).

startx

Start an X-windows server and the default windows manager. Works like
typing “win” under DOS with Win3.1

startx -- :1

Start another X-windows session on the display 1 (the default is opened
on display 0). You can have several GUI terminals running concurrently.
Switch between them using <Ctrl><Alt><F7>, <Ctrl><Alt><F8>,
etc.

xterm

(in X terminal) Run a simple X-windows terminal.  Typing exit
will close it.  There are other, more advanced “virtual” terminals
for X-windows. I like the popular ones: konsole and kvt
(both come with kde) and gnome-terminal (comes with gnome).

If you need something really fancy-looking, try Eterm.

xboing

(in X terminal). Very nice, old-fashioned game. Many small games/programs
are probably installed on your system. I also like xboard (chess).

shutdown -h now

(as root) Shut down the system to a halt. Mostly used for a remote
shutdown. Use <Ctrl><Alt><Del> for a shutdown at the console (which
can be done by any user).

halt

reboot

(as root, two commands) Halt or reboot the machine. Used for remote
shutdown, simpler to type than the previous command.

Network apps

netscape

(in X terminal) Run netscape (requires a separate Netscape installation).
The current versions of Netscape (4.x) are known to be big and buggy. They
occasionally crash by vanishing (no other harm done). Also, when not connected
to the network , Netscape likes to refuse to do anything (looks like it
hanged)-it revives when you connect.

netscape -display host:0.0

(in X terminal) Run netscape on the current machine and direct the
output to machine named “host” display 0 screen 0. Your current machine
must have a permission to display on the machine “host” (typically given
by executing the command xhost

current_machine_name in
the xterminal of the machine host. Other X-windows program can be run remotely
the same way.

lynx
file.html

View an html file or browse the net from the text mode.

pine

A good text-mode mail reader. Another good and standard one is elm.
Your Netscape mail will read the mail from your Internet account. pine
will let you read the “local” mail, e.g. the mail your son or a cron process
sends to you from a computer on your home network. The command mail

could also be used for reading/composing mail, but it would be inconvenient–it
is meant to be used in scripts for automation.

elm

A good tex-mode mail reader. See the previous command.

mutt

A really basic but extremally useful and fast mail reader.

mail

A basic operating system tool for e-mail. Look at the previous commands
for a better e-mail reader. mail is good if you wanted to send
an e-mail from a shell script.

licq

(in X term) An icq “instant messaging” client. Another good one is
kxicq.
Older distributions don’t have an icq client installed, you have to do
download one and install it.

talk
username1

Talk to another user currently logged on your machine (or use “talk
username1@machinename

to talk to a user on a different computer) . To accept the invitation to
the conversation, type the command “talk
username2
“. If
somebody is trying to talk to you and it disrupts your work, your may use
the command “mesg n” to refuse accepting messages. You may want
to use “who” or “rwho” to determine the users who are
currently logged-in.

mc

Launch the “Midnight Commander” file manager (looks like “Norton Commander”
for Linux).

telnet
server

Connect to another machine using the TELNET protocol. Use a remote
machine name or IP address. You will be prompted for your login name and
password–you must have an account on the remote machine to login. Telnet
will connect you to another machine and let you operate on it as if you
were sitting at its keyboard (almost). Telnet is not very secure–everything
you type goes in open text, even your password!

rlogin
server

(=remote login) Connect to another machine. The login name/password
from your current session is used; if it fails you are prompted for a password.

rsh
server

(=remote shell) Yet another way to connect to a remote machine. The
login name/password from your current session is used; if it fails you
are prompted for a password.

ftp
server

Ftp another machine. (There is also ncftp which adds extra
features and gftp for GUI .) Ftp is good for copying files to/from
a remote machine. Try user “anonymous” if you don’t have an account on
the remote server. After connection, use “?” to see the list of available
ftp commands.  The essential ftp command are: ls (see the
files on the remote system), ASCII,
binary (set the file
transfer mode to either text or binary, important that you select the proper
one ), get (copy a file from the remote system to the local system),

mget
(get many files at once), put (copy a file from the local system
to the remote system), mput (put many files at once), bye
(disconnect). For automation in a script, you may want to use
ncftpput
and ncftpget, for example:
ncftpput -u my_user_name -p my_password -a remote.host.domain remote_dir
*local.html

minicom

Minicom program (looks like “Procomm for Linux”).

File (de)compression

tar -zxvf filename.tar.gz

(=tape archiver) Untar a tarred and compressed tarball (*.tar.gz or
*.tgz) that you downloaded from the Internet.

tar -xvf filename.tar

Untar a tarred but uncompressed tarball (*.tar).

gunzip

filename.gz

Decompress a zipped file (*.gz” or *.z). Use gzip (also zip
or compress) if you wanted to compress files to this file format.

bunzip2
filename.bz2

(=big unzip) Decompress a file (*.bz2) zipped with bzip2 compression
utility. Used for big files.

unzip
filename.zip

Decompress a file (*.zip) zipped with a compression utility compatible
with PKZIP for DOS.

unarj e filename.arj
Extract the content of an *.arj archive.

uudecode -o outputfile filename

Decode a file encoded with uuencode.  uu-encoded files
are typically used for transfer of non-text files in e-mail (uuencode transforms
any file into an ASCII file).

7.4 Process control

ps

(=print status) Display the list of currently running
processes with their process IDs (PID) numbers. Use ps axu to
see all processes currently running on your system (also those of other
users or without a controlling terminal), each with the name of the owner.
Use “top” to keep listing the processes currently running.

fg
PID

Bring a background or stopped process to the foreground.

bg
PID

Send the process to the background. Opposite to fg. The same can be
accomplished with <Ctrl>z.  If you have stopped jobs, you have
to type exit twice in row to log out.

any_command&
Run any command in the background (the symbol “&” means “run the
proceeding command in the background”).

batch any_command

Run any command (usually one that is going to take more time) when
the system load is low. I can logout, and the process will keep running.

at 17:00

Execute a command at a specified time.  You will be prompted for
the command(s) to run, until you press <Ctrl>d.

kill
PID

Force a process shutdown. First determine the PID of the process to
kill using ps.

killall
program_name

Kill program(s) by name.

xkill

(in an xwindow terminal) Kill a GUI-based program with mouse. (Point
with your mouse cursor at the window of the process you want to kill and
click.)

lpc

(as root) Check and control the printer(s). Type “?” to see the list
of available commands.

lpq

Show the content of the printer queue. Under KDE (X-Windows), you may
use GUI-based “Printer Queue” available from “K”menu-Utilities.

lprm
job_number

Remove a printing job “job_number” from the queue.

nice
program_name

Run
program_name adjusting its priority. Since the priority
is not specified in this example, it will be adjusted by 10 (the process
will run slower), from the default value (usually 0). The lower the number
(of “niceness” to other users on the system), the higher the priority.
The priority value may be in the range -20 to 19. Only root may specify
negative values. Use “top” to display the priorities of the running processes.

renice -1 PID

(as root) Change the priority of a running process to -1. Normal users
can only adjust processes they own, and only up from the current value
(make them run slower).

<Ctrl>c, <Ctrl>z, <Ctrl>s, and <Ctrl>q

also belong to this chapter but they were described previously.
In short they mean: stop the current command, send the current command
to the background, stop the data transfer, resume the data transfer.

7.5 Basic administration commands

printtool

(as root in X-terminal) Configuration tool for your printer(s). Settings
go to the file /etc/printcap.

setup

(as root) Configure mouse, soundcard, keyboard, X-windows, system services.
There are many distibution-specific configuration utilities, setup

is the default on RedHat. Mandrake 7.0 offers very nice DrakConf
.

linuxconfig

(as root, either in text or graphical mode). You can access and change
hundreds of setting from it. Very powerful–don’t change too many things
at the same time, and be careful with changing entries you don’t understand.

xvidtune

(in X-terminal). Adjust the settings of the graphical display for all
resolutions so as to eliminate black bands, shift the display right/left/up/down,
etc. (First use the knobs on your monitor to fit your text mode correctly
on the screen.) To make the changes permanent, display the frequencies
on the screen and transfer them to the setup file /etc/X11/XF86Config.

alias ls="ls --color=tty"

Create an alias for the command “ls” to enhance its format with color.
In this example, the alias is also called “ls” and the “color” option is
only envoke when the output is done to a terminal (not to files). Put the
alias into the file /etc/bashrc if you would like the alias to
be always accessible to all users on the system. Type “alias
alone to see the list of aliases on your system.

adduser
user_name

Create a new account (you must be root). E.g.,  adduser barbara 
Don’t forget to set up the password for the new user in the next step.
The user home directory is
/home/user_name.

useradd
user_name

The same as the command ” adduser

user_name “.

userdel
user_name

Remove an account (you must be a root). The user’s home directory and
the undelivered mail must be dealt with separately (manually because you
have to decide what to do with the files).

groupadd
group_name

Create a new group on your system. Non-essential but can be handy even
on a home machine with a small number of users.

passwd

Change the password on your current account. If you are root, you can
change the password for any user using:  passwd

user_name

chmod perm filename

(=change mode) Change the file access permission for the files you
own (unless you are root in which case you can change any file). You can
make a file accessible in three modes: read (r), write (w), execute (x)
to three classes of users: owner (u), members of the same group as the
owner (g), others on the system (o). Check the current access permissions
using:

ls -l filename

If the file is accessible to all users in all modes it will show:

rwxrwxrwx

The first triplet shows the file permission for the owner of the file,
the second for his/her group, the third for others. A “no” permission is
shown as “-”.

E.g., this command will add
the permission to read the file
“junk” to all (=user+group+others):

chmod a+r junk
This command will remove the permission to execute the file junk from
others:

chmod o-x junk

Also try here
for more info.

You can set the default file permissions for the news files that you
create using the command umask (see man umask).

chown
new_ownername filename

chgrp new_groupname filename
Change the file owner and group. You should use these two commands
after you copy a file for use by somebody else.

su

(=substitute user id) Assume the superuser (=root) identity (you will
be prompted for the password). Type “exit” to return you to your previous
login. Don’t habitually work on your machine as root. The root account
is for administration and the su command is to ease your access to the
administration account when you require it. You can also use “su” to assume
any other user identity, e.g. su barbara will make me “barbara”
(password required unless I am a superuser).

kernelcfg

(as root in X terminal). GUI to to add/remove kernel modules. You can
do the same from the command line using the command “insmod“,
but “insmode” is less “newbie-friendly”.

lsmod

List currently loaded kernel modules. A module is like a device driver–it
provides operating system kernel support for a particular piece of hardware
or feature.

modprobe -l |more

List all the modules available for your kernel. The available modules
are determined by how your Linux kernel was compliled. Every possible module/feature
can be compiled on linux as either “hard wired” (fast, non-removable),
“module” (maybe slower, but loaded/removable on demand), or “no” (no support
for this feature at all).

insmod parport

insmod ppa

(as root) Insert modules into the kernel (a module is roughly an equivalent
of a DOS device driver). This example shows how to insert the modules for
support of the external parallel port zip drive (it appears to be a problem
to get the external zip drive to work  in any other way under RH6.0
).

rmmod
module_name

(as root, not essential). Remove the module module_name from
the kernel.

setserial /dev/cua0 port 0x03f8 irq 4

(as root) Set a serial port to a non-standard setting. The example
here shows the standard setting for the first serial port (cua0 or ttyS0).
The standard PC settings for the second serial port (cua1or ttyS1) are:
address of i/o port 0x02f8, irq 3. The third serial port (cua2 or ttyS2):
0x03e8, irq 4. The forth serial port (cua3 or ttyS3): 0x02e8, irq 3. Add
your setting to /etc/rc.d/rc.local if you want it to be set at
the boot time. See man setserial for good a overview.

fdisk

(as root) Linux hard drive partitioning utility (DOS has a utility
with the same name).

cd /usr/src/linux-2.0.36

make xconfig

(as root in X terminal). Nice GUI front-end for configuration of the
kernel options in preparation for compilation of your customized kernel.
(The directory name contains the version of your Linux kernel so you may
need to modify the directory name if your Linux kernel version is different
than 2.0.36 used in this example. You also need the “Tk” interpreter and
the kernel source code installed. ) The alternatives to “make xconfig”
are: “make config”  (runs a scripts that asks you questions in the
text mode) and “make menuconfig” (runs a text-based menu-driven configuration
utility). Try: less /usr/doc/HOWTO/Kernel-HOWTO for more information.
After the configuration,  you may choose to proceed with kernel
compilation of the new kernel by issuing the following commands:

make dep

make zImage

The last command will take some time to complete (maybe 0.5 h, depending
on your hardware). It produces the file “zImage”, which is your new Linux
kernel. Next:

make modules

make modules_install

Read: /usr/doc/HOWTO/Kernel-HOWTO for information on how to install
the new kernel. You will probably also find it useful to read “man depmode”.
Configuration, compilation and installation of a new kernel is not difficult
but it CAN lead to problems if you don’t know what you are doing.

Compilation of a kernel is a good way to test your hardware, because
it involves a massive amount of computing. If your hardware is “flaky”,
you will most likely receive the “signal 11″ error (read the beatiful
/usr/doc/FAQ/txt/GCC-SIG11-FAQ).
See

this
for details on kernel upgrade.

depmod -a

(as root) Build the module dependency table for the kernel. This can,
for example, be useful after installing and booting a new kernel. Use “modprobe
-a
” to load the modules.

ldconfig

(as root) Re-create the bindings and the cache for the loader of dynamic
libraries (“ld”). You may want to run ldconfig after an installation of
new dynamically linked libraries on your system. (It is also re-run every
time you boot the computer, so if you reboot you don’t have to run it manually.)

mknod /dev/fd0 b 2 0

(=make node, as root) Create a device file. This example shows how
to create a device file associated with your first floppy drive and could
be useful if you happened to accidentally erase it. The options are: b=block
mode device (c=character mode device, p=FIFO device, u=unbuffered character
mode device). The two integers specify the major and the minor device number.

fdformat /dev/fd0H1440
mkfs -c -t ext2

(=floppy disk format, two commands, as root) Perform a low-level formatting
of a floppy in the first floppy drive (/dev/fd0), high density (1440 kB).
Then make a Linux filesystem (-t ext2), checking/marking bad blocks (-c
). Making the files system is an equivalent to the high-level format.

badblocks /dev/fd01440 1440

(as root) Check a high-density floppy for bad blocks and display the
results on the screen. The parameter “1440″ specifies that 1440 blocks
are to be checked. This command does not modify the floppy.

fsck -t ext2 /dev/hda2

(=file system check, as root) Check and repair a filesystem. The example
uses the partition hda2, filesystem type ext2.

dd if=/dev/fd0H1440 of=floppy_image

dd if=floppy_image of=/dev/fd0H1440

(two commands, dd=”data duplicator”) Create an image of a floppy to
the file called “floppy_image” in the current directory. Then copy floppy_image
(file) to another floppy disk. Works like DOS “DISKCOPY”.

Program installation

rpm -ivh filename.rpm

(=RedhatPackageManager, install, verbose, hashes displayed to show
progress, as root.) Install a content of RedHat rpm package(s) and print
info on what happened. Keep reading if you prefer a GUI installation.

rpm -qpi filename.rpm

(=RedhatPackageManager, query, package, list.) Read the info on the
content of a yet uninstalled package
filename.rpm.

rpm -qpl filename.rpm
(=RedhatPackageManager, query, package, information.) List the files
contained in a yet uninstalled package
filename.rpm.

rpm -qf filename

(=RedhatPackageManager, query, file.) Find out the name of the *.rpm
package to which the file
filename (on your hardrive) belongs.

rpm -e packagename

(=RedhatPackageManager, erase=uninstall.) Uninstall a package pagckagename.
Packagname

is the same as the beginning of the *.rpm package file but without the
dash and version number.

kpackage

gnorpm

glint

(in X terminal, as root if you want to be able to install packages)
GUI fronts to the Red Hat Package Manager (rpm). “glint” comes with RH5.2,
“gnorpm” with RH6.0, “kpackage” comes with RH6.1 or must be installed separately
but is the best of the three. Use any of them to view which software packages
are installed on your system and the what not-yet-installed packages are
available on your RedHat CD, display the info about the packages, and install
them if you want (installation must be done as root).

Accessing drives/partitions

mount

See
here

for details on mounting drives.  Examples are shown in the next commands.

mount -t auto /dev/fd0 /mnt/floppy

(as root) Mount the floppy. The directory /mnt/floppy must
exist, be empty and NOT be your current directory.

mount -t auto /dev/cdrom /mnt/cdrom

(as root) Mount the CD. You may need to create/modify the /dev/cdrom
file depending where your CDROM is. The directory /mnt/cdrom must
exist, be empty and NOT be your current directory.

mount /mnt/floppy

(as user or root) Mount a floppy as user. The file /etc/fstab
must be set up to do this. The directory
/mnt/floppy must not
be your current directory.

mount /mnt/cdrom

(as user or root) Mount a CD as user. The file /etc/fstab
must be set up to do this. The directory
/mnt/cdrom must not be
your current directory.

umount /mnt/floppy

Unmount the floppy. The directory
/mnt/floppy must not be
your (or anybody else’s) current working directory. Depending on your setup,
you might not be able to unmount a drive that you didn’t mount.

7.6 Network administration tools

netconf

(as root) A very good menu-driven setup of your network.

pingmachine_name

Check if you can contact another machine (give the machine’s name or
IP), press <Ctrl>C when done (it keeps going).

route -n

Show the kernel routing table.

nslookup
host_to_find

Query your default domain name server (DNS) for an Internet name (or
IP number) host_to_find. This way you can check if your DNS works.
You can also find out the name of the host of which you only know the IP
number.

traceroute host_to_trace

Have a look how you messages trave to host_to_trace
(which is either a host name or IP number).

ipfwadm -F -p m
(for RH5.2, seen next command for RH6.0) Set up the firewall IP forwarding
policy to masquerading. (Not very secure but simple.) Purpose: all computers
from your home network will appear to the outside world as one very busy
machine and, for example, you will be allowed to browse the Internet from
all computers at once.

echo 1 > /proc/sys/net/ipv4/ip_forward

ipfwadm-wrapper -F -p deny

ipfwadm-wrapper -F -a m -S xxx.xxx.xxx.0/24 -D 0.0.0.0/0

(three commands, RH6.0). Does the same as the previous command. Substitute
the “x”s  with digits of your class “C” IP address that you assigned
to your home network. See
here
for more details. In RH6.1, masquarading seems broken to me–I think I
will install Mandrake Linux:).

ifconfig

(as root) Display info on the network interfaces currently active
(ethernet, ppp, etc). Your first ethernet should show up as eth0, second
as eth1, etc, first ppp over modem as ppp0, second as ppp1, etc. The “lo”
is the “loopback only” interface which should be always active. Use the
options (see ifconfig --help) to configure the interfaces.

ifup interface_name

(/sbin/ifup to it run as a user) Startup a network interface.
E.g.:

ifup eth0
ifup ppp0

Users can start up or shutdown the ppp interface only when the right
permission was checked during the ppp setup (using netconf ).
To start a ppp interface (dial-up connection), I normally use kppp available
under kde menu “internet”.

ifdown
interface_name

(/sbin/ifdown to run it as a user). Shut down the network
interface. E.g.: ifdown ppp0 Also, see the previous command.

netstat | more
Displays a lot (too much?) information on the status of your network.

Music-related commands

cdplay play 1

Play the first track from a audio CD.

eject

Get a free coffee  cup holder :) )).   (Eject the CD
ROM tray).

play my_file.wav
Play a wave file.

mpg123 my_file.mp3

Play an mp3 file.

mpg123 -w my_file.wav my_file.mp3

Create a wave audio file from an mp3 audio file.

knapster

(in X terminal) Start the program to downolad mp3 files that other
users of napster have displayed for downloading. Really cool!

cdparanoia -B  "1-"

(CD ripper)  Read the contents of an audio CD and save it into
wavefiles in the current directories, one track per wavefile.  The
“1-”
means “from track 1 to the last”. -B forces putting each track into
a separate file.

playmidi my_file.mid

Play a midi file.  playmidi -r my_file.mid
will display text mode effects on the screen.

sox

(argument not given here) Convert from almost any audio file format
to another (but not mp3s).  See man sox.

Graphics-related commands

kghostview my_file.ps

Display a postscript file on screen.  I can also use the older-looking
ghostview
or gv for the same end effect.

ps2pdf my_file.ps my_file.pdf
Make a pdf (Adobe portable document format) file from a postscript
file.

gimp

(in X terminal) A humble looking but very powerful image processor.
Takes some learning to use, but it is great for artists, there is almost
nothing you can’t do with gimp. Use your mouse right button to get local
menus, and learn how to use layers. Save your file in the native gimp file
format *.xcf (to preserve layers) and only then flatten it and save as
png (or whatever).  There is a large user manual /usr/

gphoto

(in X terminal) Powerful photo editor.

giftopnm my_file.giff > my_file.pnm

pnmtopng my_file.pnm > my_file.png
Convert the propriatory giff graphics into a raw, portable pnm file.
Then convert the pnm into a png file, which is a newer and better standard
for Internet pictures  (better technically plus there is no danger
of being sued by the owner of giff patents).

Pixel in picture/canvas size

canvas
4 x 6          690×460 pixels
5 x 7         805×575 pixels
8 x 8         920×920 pixels
8 x 10       1150×920 pixels
8 x 12       1380×920 pixels
11 x 14     Enlargements  1610×1265 pixels
12 x 12     1380×1380 pixels
12 x 18     Enlargements  2070×1380 pixels
16 x 20     Posters  2300×1840 pixels
20 x 30    Posters  3450×2300 pixels
11 x 14      Collage Posters  1260×990 pixels
12 x 18      Collage Posters  1620×1080 pixels
16 x 20     Collage Posters  1800×1440 pixels
20 x 30    Collage Posters  2700×1800 pixels
Wallet Prints               374×259 pixels
Photo Gifts                   900×600 pixels
4¼x6 Postcards       900×600 pixels
Notebooks                   480×480 pixels
Notebooks with full photo cover  1350×1000 pixels
Notepads                   370×370 pixels
Stickers                      370×370 pixels

IPRange 2 CIDR in perl

#!/usr/bin/perl -w
# range2cidr.pl

use Net::CIDR;
use Net::CIDR ':all';

if (@ARGV == 0) {
  die "Usage Example: $0 192.168.0.0-192.168.255.255 \n";
}

print join("\n", Net::CIDR::range2cidr("$ARGV[0]")) . "\n";

Binary Definition

Binary describes a numbering scheme in which there are
only two possible values for each digit: 0 and 1. The term also refers to any digital encoding/decoding system in which there
are exactly two possible states.In digital data memory,
storage, processing, and communications, the 0 and 1 values are sometimes called
“low” and “high,” respectively.

Binary numbers look strange when they are written out directly.This is because
the digits’ weight increases by powers of 2, rather than by powers of 10.In a
digital numeral, the digit furthest to the right is the “ones” digit; the next
digit to the left is the “twos” digit; next comes the “fours” digit,
then the “eights” digit, then the “16s” digit, then the
“32s” digit, and so on.The decimal equivalent of a binary number can be
found by summing all the digits.For example, the binary 10101 is equivalent to the
decimal 1 + 4 + 16 = 21:

DECIMAL = 21 64 32 16 8 4 2 1
BINARY = 10101 0 0 1 0 1 0 1

The numbers from decimal 0 through 15 in decimal, binary, octal, and hexadecimal
form are listed below.

DECIMAL BINARY OCTAL HEXA-

DECIMAL

0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F

Technet TCP/IP chapter 4, subnet

Chapter 4 – Subnetting

http://technet.microsoft.com/en-us/library/bb726997.aspx

Published: December 14, 2004 | Updated: April 18, 2006

Writer: Joe Davies

Abstract

This chapter describes the details of subnetting for both IPv4 and IPv6 address prefixes. Network administrators need to thoroughly understand subnetting techniques for both types of address prefixes to efficiently allocate and administer the unicast address spaces assigned and used on private intranets. This chapter includes detailed discussions of different subnetting techniques for IPv4 and IPv6 address prefixes. By using these techniques, you can determine subnetted address prefixes and, for IPv4, the range of usable IPv4 addresses for each new subnetted address prefix.

For a version of this chapter that has been updated for Windows Vista and Windows Server 2008, click here.

On This Page


Chapter Objectives


Subnetting for IPv4


Subnetting for IPv6


Chapter Summary


Chapter Glossary

Chapter Objectives

After completing this chapter, you will be able to:

  • Determine the subnet prefix of an IPv4 address when expressed in prefix length or subnet mask notation.
  • Determine how many IPv4 host ID bits you need to create a particular number of subnets.
  • Subnet an IPv4 address prefix within an octet and across octet boundaries, enumerating the list of subnetted address prefixes and the ranges of valid IPv4 addresses for each subnetted address prefix.
  • Define variable length subnetting and how you can use it to create subnetted address prefixes that match the number of hosts on a particular subnet.
  • Subnet a global IPv6 address prefix, enumerating the list of subnetted address prefixes.

Subnetting for IPv4

Subnetting is a set of techniques that you can use to efficiently divide the address space of a unicast address prefix for allocation among the subnets of an organization network. The fixed portion of a unicast address prefix includes the bits up to and including the prefix length that have a defined value. The variable portion of a unicast address prefix includes the bits beyond the prefix length that are set to 0. Subnetting is the use of the variable portion of a unicast address prefix to create address prefixes that are more efficient (that waste fewer possible addresses) for assignment to the subnets of an organization network.

Subnetting for IPv4 was originally defined to make better use of the host bits for Class A and Class B IPv4 public address prefixes. Consider the example network in Figure 4-1.


Bb726997.subtn401(en-us,TechNet.10).gif

Figure 4-1  Network 157.60.0.0/16 before subnetting

The subnet using the class B address prefix of 157.60.0.0/16 can support up to 65,534 nodes, which is far too many nodes to have on the same subnet. You want to better use the address space of 157.60.0.0/16 through subnetting. However, subnetting 157.60.0.0/16 should not require the reconfiguration of the routers of the Internet.

In a simple example of subnetting, you can subnet 157.60.0.0/16 by using the first 8 host bits (the third octet) for the new subnetted address prefix. If you subnetted 157.60.0.0/16 as shown in Figure 4-2, you would create separate subnets with their own subnetted address prefixes (157.60.1.0/24, 157.60.2.0/24, 157.60.3.0/24), with up to 254 host IDs on each subnet. The router would become aware of the separate subnetted address prefixes and route IPv4 packets to the appropriate subnet.


Bb726997.subtn402(en-us,TechNet.10).gif

Figure 4-2  Network 157.60.0.0/16 after subnetting

The routers of the Internet would still regard all the nodes on the three subnets as being located on the address prefix 157.60.0.0/16. The Internet routers would be unaware of the subnetting being done to 157.60.0.0/16 and therefore require no reconfiguration. The subnetting of an address prefix is not visible to the routers outside the network being subnetted.

When you assign IPv4 address prefixes in the form of subnet prefixes to the subnets of your organization, you should begin with one or more public address prefixes assigned by the Internet Corporation for Assigned Names and Numbers (ICANN) or an Internet service provider (ISP), the private address space (10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16), or both. The set of starting address prefixes represent a fixed address space.

You can divide the variable portion of an IPv4 address prefix to represent additional subnets and the host IDs on each subnet. For example, the IPv4 address prefix 131.107.192.0/18 has 18 fixed bits (as the prefix length shows) and 14 variable bits (the bits in the host ID portion of the address prefix). You might determine that your organization needs up to 50 subnets. Therefore, you divide the 14 variable bits into 6 bits, which you will use to identify subnets (you can express up to 64 subnets with 6 bits) and 8 bits, which you will use to identify up to 254 host IDs on each subnet. The resulting address prefix for each subnetted address prefix has a 24-bit prefix length (the original 18 bits plus 6 bits used for subnetting).

Subnetting for IPv4 produces a set of subnetted address prefixes and their corresponding ranges of valid IPv4 addresses. By assigning subnetted address prefixes that contain an appropriate number of host IDs to the physical and logical subnets of an organization’s IPv4 network, network administrators can use the available address space in the most efficient manner possible.

Before you begin IPv4 subnetting, you must determine your organization’s current requirements and plan for future requirements. Follow these guidelines:

  • Determine how many subnets your network requires. Subnets include physical or logical subnets to which hosts connect and possibly private wide area network (WAN) links between sites.
  • Determine how many host IDs each subnet requires. Each host and router interface running IPv4 requires at least one IPv4 address.

Based on those requirements, you will define a set of subnetted address prefixes with a range of valid IPv4 addresses for each subnetted address prefix. Your subnets do not all need to have the same number of hosts; most IPv4 networks include subnets of various sizes.

Although the concept of subnetting by using host ID bits is straightforward, the actual mechanics of subnetting are a bit more complicated. Subnetting requires a three-step procedure:

  1. Determine how many host bits to use for the subnetting.
  2. Enumerate the new subnetted address prefixes.
  3. Enumerate the range of IPv4 addresses for each new subnetted address prefix.

Determining the Subnet Prefix of an IPv4 Address Configuration

Before you begin the mechanics of IPv4 subnetting, you should be able to determine the subnet prefix from an arbitrary IPv4 address configuration, which typically consists of an IPv4 address and a prefix length or an IPv4 address and a subnet mask. The following sections show you how to determine the subnet prefix for IPv4 address configurations when the prefix length is expressed in prefix length and dotted decimal (subnet mask) notation.

Prefix Length Notation

To determine the subnet prefix from an arbitrary IPv4 address using prefix length notation (w.x.y.z/n), take the values of the high-order n bits of the address and combine them with 32-n zero bits. Then convert the resulting 32-bit number to dotted decimal notation.

For example, for the IPv4 address configuration of 192.168.207.47/22, the high-order 22 bits are 11000000 10101000 110011. To obtain the subnet prefix, combine this result with the low-order 10 bits of 00 00000000. The result is 11000000 10101000 11001100 00000000, or 192.168.204.0/22.

To determine the subnet prefix of an IPv4 address configuration in prefix length notation without having to work entirely with binary numbers, use the following method:

  1. Express the number n (the prefix length) as the sum of 4 numbers by successively subtracting 8 from n. For example, 20 is 8+8+4+0.
  2. Create a table with four columns and three rows. In the first row, place the decimal octets of the IPv4 address. In the second row, place the four digits of the sum you determined in step 1.
  3. For the columns that have 8 in the second row, copy the octet from the first row to the third row. For the columns that have 0 in the second row, place a 0 in the third row.
  4. For the columns that have a number between 8 and 0 in the second row, convert the decimal number in the first row to binary, take the high-order bits for the number of bits indicated in the second row, fill the rest of the bits with zero, and then convert to a decimal number.

For example, for the IPv4 address configuration of 192.168.207.47/22, 22 is 8+8+6+0. From this, construct the following table:

192 168 207 47
8 8 6 0

For the first and second octets, copy the octets from the first row. For the last octet, place a 0 in the third row. The table becomes:

192 168 207 47
8 8 6 0
192 168 0

For the third octet, convert the number 207 to binary for the first 6 binary digits using the decimal to binary conversion method described in Chapter 3, “IP Addressing.” The decimal number 207 is 128+64+8+4+2+1, which is 11001111. Taking the first 6 digits 110011 and filling in the octet with 00 produces 11001100, or 204 in decimal. The table becomes:

192 168 207 47
8 8 6 0
192 168 204 0

Therefore, the subnet prefix for the IPv4 address configuration 192.168.207.47/22 is 192.168.204.0/22.

Subnet Mask Notation

To extract the subnet prefix from an arbitrary IPv4 address configuration using an arbitrary subnet mask, IPv4 uses a mathematical operation called a logical AND comparison. In an AND comparison, the result of two items being compared is true only when both items being compared are true; otherwise, the result is false. Table 4-1 shows the result of the AND operation for the four possible bit combinations.

Bit Combination Result
1 AND 1 1
1 AND 0 0
0 AND 0 0
0 AND 1 0

Table 4-1  Result of AND Operation

Therefore, the result of the AND operation is 1 only when both bits being ANDed are 1. Otherwise, the result is 0.

IPv4 performs a logical AND comparison with the 32-bit IPv4 address and the 32-bit subnet mask. This operation is known as a bit-wise logical AND. The result of the bit-wise logical AND of the IPv4 address and the subnet mask is the subnet prefix.

For example, to determine the subnet prefix of the IPv4 address configuration 131.107.189.41 with a subnet mask of 255.255.240.0, turn both numbers into their binary equivalents, and line them up. Then perform the AND operation on each bit, and write down the result.

IPv4 Address:    10000011 01101011 10111101 00101001

Subnet Mask:    11111111 11111111 11110000 00000000

Subnet Prefix:    10000011 01101011 10110000 00000000

The result of the bit-wise logical AND of the 32 bits of the IPv4 address and the subnet mask is the subnet prefix 131.107.176.0, 255.255.240.0. The behavior of the bit-wise logical AND operation between the IPv4 address and the subnet mask is the following:

  • For the bits in the fixed portion of the address (in which the bits in the subnet mask are set to 1), the subnet prefix bits are copied from the IPv4 address, essentially extracting the subnet prefix of the IPv4 address.
  • For the bits in the variable portion of the address (in which the bits in the subnet mask are set to 0), the subnet prefix bits are set to 0, essentially discarding the host ID portion of the IPv4 address.

To summarize, the bit-wise logical AND extracts the subnet prefix portion and discards the host ID portion of an IPv4 address. The result is the subnet prefix.

To determine the subnet prefix of an IPv4 address configuration in subnet mask notation without having to work entirely with binary numbers, use the following method:

  1. Create a table with four columns and three rows. In the first row, place the decimal octets of the IPv4 address. In the second row, place the decimal octets of the subnet mask.
  2. For the columns that have 255 in the second row, copy the octet from the first row to the third row. For the columns that have 0 in the second row, place a 0 in the third row.
  3. For the columns that have a number between 255 and 0 in the second row, AND the decimal numbers in the first two rows. You can do this by converting both numbers to binary, performing the AND comparison for all 8 bits in the octet, and then converting the result back to decimal. Alternately, you can use a calculator, such as the Windows Calculator, in scientific mode.

For example, for the IPv4 address configuration of 131.107.189.41, 255.255.240.0, construct the following table:

131 107 189 41
255 255 240 0

For the first and second octets, copy the octets from the first row. For the last octet, place a 0 in the third row. The table becomes:

131 107 189 41
255 255 240 0
131 107 0

For the third octet, compute 189 AND 240. In binary, this operation becomes:

      10111101
AND   11110000
      10110000

Converting 10110000 to decimal is 176. Alternately, use the Windows Calculator to compute 189 AND 240, which yields 176.

The table becomes:

131 107 189 41
255 255 240 0
131 107 176 0

Therefore, the subnet prefix for the IPv4 address configuration 131.107.189.41, 255.255.240.0 is 131.107.176.0, 255.255.240.0.

Defining a Prefix Length

The number of variable bits in the subnet prefix determines the maximum number of subnets and hosts on each subnet that you can have.

Before you define a new prefix length based on your subnetting scheme, you should have a good idea of the number of subnets and hosts you will have in the future. If you use more variable bits for the new prefix length than required, you will save the time and administrative difficulty of renumbering your IPv4 network later.

The more variable bits that you use, the more subnets you can have—but with fewer hosts on each subnet. If you make the prefix too long, it will allow for growth in the number of subnets, but it will limit the growth in the number of hosts on each subnet. If you make the prefix too short, it will allow for growth in the number of hosts on each subnet, but it will limit the growth in the number of subnets. Figure 4-3 shows an example of subnetting the third octet.


Bb726997.subtn403(en-us,TechNet.10).gif

Figure 4-3  Tradeoff between number of subnets and number of hosts per subnet

Follow these guidelines to determine the number of bits to use for a new prefix length when subnetting:

  1. Determine how many subnets you need now and will need in the future.
  2. Use additional bits for subnetting if:
    • You will never require as many hosts per subnet as allowed by the remaining bits.
    • The number of subnets will increase, requiring additional bits from the host ID.

Defining a new prefix length depends on how many subnets you need. Table 4-2 shows how many subnets you can create by using a particular number of variable bits (up to 16) to specify each subnet.

Number of Subnets Number of Host Bits
1-2 1
3-4 2
5-8 3
9-16 4
17-32 5
33-64 6
65-128 7
129-256 8
257-512 9
513-1,024 10
1,025-2,048 11
2,049-4,096 12
4,097-8,192 13
8,193-16,384 14
16,385-32,768 15
32,769-65,536 16

Table 4-2  Number of Required Subnets and Host Bits

The maximum prefix length for unicast IPv4 addresses is 30. With 30 bits for the subnet prefix, the two remaining bits can express up to 4 possible combinations. However, the all-zeros and all-ones host IDs are reserved. Therefore, with two host ID bits, you can express only two usable host IDs (the 01 and 10 combinations).

To determine the maximum number of hosts per subnet for any subnetting scheme:

  1. Determine m, the number of bits that remain for the host ID, by subtracting the subnetted prefix length from 32.
  2. Calculate the maximum number of hosts per subnet from 2m – 2.

Based on the address prefix you are subnetting and the number of bits that you need for subnetting, you can determine whether you are subnetting within an octet or subnetting across an octet boundary. For example, if you start with an 18-bit address prefix and then use 4 bits for subnetting, then you are subnetting within the third octet. (The subnetted prefix length is 22, which is still within the third octet.) However, if you start with a 20-bit address prefix and then use 6 bits for subnetting, then you are subnetting across the third and fourth octets. (The original prefix length is 20, which is within the third octet, and the subnetted prefix length is 26, which is within the fourth octet.)

As the following sections describe, the specific procedures for subnetting within an octet and subnetting across an octet boundary are very different.

Subnetting Within an Octet

When you subnet within an octet, the subnetting procedure has two main steps:

  • Defining the subnetted address prefixes
  • Defining the range of usable IPv4 addresses for each subnetted address prefix

The following sections describe these steps.

Defining the Subnetted Address Prefixes

You can use two methods to define the set of subnetted address prefixes:

  • Binary
  • Decimal

To create an enumerated list of subnetted address prefixes by using binary, perform the following steps:

  1. Based on n, the number of bits chosen for subnetting, create a three-column table with 2n rows. The first column contains the subnet numbers (starting with 1), the second column contains binary representations of the subnetted address prefixes, and the third column contains dotted decimal representations of the subnetted address prefixes.

    For each binary representation, the bits corresponding to the address prefix being subnetted are fixed at their original values, and all host bits are always set to 0. Only the subnet bits vary as you set them to each possible binary value.

  2. In the first row, set the subnet bits to all 0s, and convert the entire subnetted address prefix to dotted decimal notation. The result is the original address prefix with its new prefix length.
  3. In the next row, increment the value within the subnet bits.
  4. Convert the binary result to dotted decimal notation.
  5. Repeat steps 3 and 4 until you complete the table.

For example, you can perform a 3-bit subnetting of the private address prefix 192.168.0.0/16. The subnet mask for the new subnetted address prefixes is 255.255.224.0 or /19. Based on n = 3, construct a table with 8 (= 23) rows, as Table 4-3 shows. In the row for subnet 1, set all subnet bits (those in bold in the table) to 0, and increment them in each subsequent row.

Subnet Binary Representation Subnetted Address Prefix
1 11000000.10101000.00000000.00000000 192.168.0.0/19
2 11000000.10101000.00100000.00000000 192.168.32.0/19
3 11000000.10101000.01000000.00000000 192.168.64.0/19
4 11000000.10101000.01100000.00000000 192.168.96.0/19
5 11000000.10101000.10000000.00000000 192.168.128.0/19
6 11000000.10101000.10100000.00000000 192.168.160.0/19
7 11000000.10101000.11000000.00000000 192.168.192.0/19
8 11000000.10101000.11100000.00000000 192.168.224.0/19

Table 4-3  Binary Subnetting Technique for the 3-bit Subnetting of 192.168.0.0/16

Note RFCs 950 and 1122 prohibit setting the bits being used for subnetting to all 1s or all 0s (the all-ones and all-zeros subnets). However, RFC 1812 permits this practice.

To create an enumerated list of subnetted address prefixes by working with decimal numbers, perform the following steps:

  1. Based on f, the number of bits in the octet that are already fixed, and n, the number of bits you are using for subnetting, compute the subnet increment value, i, based on the following formula: i =  2(8-f-n). The result is the incrementing value for each subnet for the octet that you are subnetting.
  2. Based on n, the number of bits you are using for subnetting, create a three-column table with 2n rows. The first column contains the subnet numbers (starting with 1), the second column contains the decimal representations of the octet being subnetted, and the third column contains the dotted decimal representations of the subnetted address prefixes.
  3. In the first row, set the second column to the starting octet value in the address prefix being subnetted, and set the third column to the original address prefix with its new prefix length.
  4. In the next row, set the second column to the result of incrementing the number from the previous row with i, and set the third column to the subnetted address prefix with the subnetted octet from the second row.
  5. Repeat step 4 until you complete the table.

For example, to perform a 3-bit subnet of the private address prefix 192.168.0.0/16, compute the subnet increment from i = 2(8-f-n). In this case, f=0 and n=3. Therefore, the subnet increment is 2(8-0-3) = 2(5) = 32. The prefix length for the subnetted address prefixes is /19. Based on n = 3, construct a table with 8 (= 23) rows as Table 4-4 shows. In the row for subnet 1, place the original address prefix with the new prefix length, and complete the remaining rows by incrementing the subnetted octet by 32.

Subnet Decimal Value of the Subnetted Octet Subnetted Address Prefix
1 0 192.168.0.0/19
2 32 192.168.32.0/19
3 64 192.168.64.0/19
4 96 192.168.96.0/19
5 128 192.168.128.0/19
6 160 192.168.160.0/19
7 192 192.168.192.0/19
8 224 192.168.224.0/19

Table 4-4  Decimal Subnetting Technique for the 3-bit Subnetting of 192.168.0.0/16

Defining the Range of IPv4 Addresses for Each Subnet

You can use two methods to define the range of IPv4 addresses for each subnet:

  • Binary
  • Decimal

To define the possible host IDs within each subnet, you keep the bits in the subnetted address prefix fixed while setting the remaining bits (in the host portion of the IPv4 address) to all possible values except all 1s and all 0s. Recall from Chapter 3, “IP Addressing,” that you should use the following standard practice when defining the range of valid IPv4 unicast addresses for a given address prefix:

  • For the first IPv4 unicast address in the range, set all the host bits in the address to 0, except for the lowest-order bit, which you set to 1.
  • For the last IPv4 unicast address in the range, set all the host bits in the address to 1, except for the lowest-order bit, which you set to 0.

The result for each subnetted address prefix is a range of values that describe the possible unicast IPv4 addresses for that subnet.

To define the range of valid IPv4 addresses for a set of subnetted address prefixes using the binary method, perform the following steps:

  1. Based on n, the number of host bits chosen for subnetting, create a three-column table with 2n rows. The first column contains the subnet numbers (starting with 1), the second column contains the binary representations of the first and last IPv4 addresses for the subnetted address prefixes, and the third column contains the dotted decimal representation of the first and last IPv4 addresses of the subnetted address prefixes. Alternately, add two columns to the previous table used for enumerating the subnetted address prefixes using the binary technique.
  2. In the second column of the first row, the first IPv4 address is the address in which all the host bits are set to 0 except for the last host bit. The last IPv4 address is the address in which all the host bits are set to 1 except for the last host bit.
  3. In the third column of the first row, convert the binary representation to dotted decimal notation.
  4. Repeat steps 2 and 3 for each row until you complete the table.

For example, Table 4-5 shows the range of IPv4 addresses for the 3-bit subnetting of 192.168.0.0/16 with the host bits in bold.

Subnet Binary Representation Range of IPv4 Addresses
1 11000000.10101000.00000000.00000001 –11000000.10101000.00011111.11111110 192.168.0.1 –192.168.31.254
2 11000000.10101000.00100000.00000001 –11000000.10101000.00111111.11111110 192.168.32.1 –192.168.63.254
3 11000000.10101000.01000000.00000001 –11000000.10101000.01011111.11111110 192.168.64.1 –192.168.95.254
4 11000000.10101000.01100000.00000001 –11000000.10101000.01111111.11111110 192.168.96.1 –192.168.127.254
5 11000000.10101000.10000000.00000001 –11000000.10101000.10011111.11111110 192.168.128.1 –192.168.159.254
6 11000000.10101000.10100000.00000001 –11000000.10101000.10111111.11111110 192.168.160.1 –192.168.191.254
7 11000000.10101000.11000000.00000001 –11000000.10101000.11011111.11111110 192.168.192.1 –192.168.223.254
8 11000000.10101000.11100000.00000001 –11000000.10101000.11111111.11111110 192.168.224.1 –192.168.255.254

Table 4-5  Binary Technique for Defining the Ranges of IPv4 Addresses for the 3-bit Subnetting of 192.168.0.0/16

To define the range of valid IPv4 addresses for a set of subnetted address prefixes using the decimal method, perform the following steps:

  1. Based on n, the number of host bits chosen for subnetting, create a three-column table with 2n rows. The first column contains the subnet numbers (starting with 1), the second column contains the dotted decimal representations of the subnetted address prefixes, and the third column contains the dotted decimal representations of the first and last IPv4 addresses of the subnetted address prefix. Alternately, add a column to the previous table used for enumerating the subnetted address prefixes in decimal.
  2. For each row, calculate the first IPv4 address in the range by adding 1 to the last octet of the subnetted address prefix.
  3. For each row except the last, calculate the last IPv4 address in the range using the following formulas:
    • When you subnet within the first octet, the last value for a given subnet is [NextSubnetID - 1].255.255.254 (in which NextSubnetID is the value of the octet that is being subnetted for the next subnetted address prefix).
    • When you subnet within the second octet, the last value for a given subnet is w.[NextSubnetID - 1].255.254.
    • When you subnet within the third octet, the last value for a given subnet is w.x.[NextSubnetID - 1].254.
    • When you subnet within the fourth octet, the last value for a given subnet is w.x.y.[NextSubnetID - 2].
  4. For the last row, calculate the last IPv4 address in the range using the following formulas:
    • When you subnet within the first octet, the last value is [SubnetID + i - 1].255.255.254 (in which SubnetID is the value of the octet that is being subnetted for the current subnetted address prefix and i is the increment value derived when determining the subnetted address prefixes).
    • When you subnet within the second octet, the last value is w.[SubnetID + i - 1].255.254.
    • When you subnet within the third octet, the last value is w.x.[SubnetID + i - 1].254.
    • When you subnet within the fourth octet, the last value is w.x.y.[SubnetID + i - 2].

For example, Table 4-6 shows the range of IPv4 addresses for the 3-bit subnetting of 192.168.0.0/16.

Subnet Subnetted Address Prefix Range of IPv4 Addresses
1 192.168.0.0/19 192.168.0.1 –192.168.31.254
2 192.168.32.0/19 192.168.32.1 –192.168.63.254
3 192.168.64.0/19 192.168.64.1 –192.168.95.254
4 192.168.96.0/19 192.168.96.1 –192.168.127.254
5 192.168.128.0/19 192.168.128.1 –192.168.159.254
6 192.168.160.0/19 192.168.160.1 –192.168.191.254
7 192.168.192.0/19 192.168.192.1 –192.168.223.254
8 192.168.224.0/19 192.168.224.1 –192.168.255.254

Table 4-6  Decimal Technique for Defining the Ranges of IPv4 Addresses for the 3-bit Subnetting of 192.168.0.0/16

Subnetting Across an Octet Boundary

Like the procedure for subnetting within an octet, the procedure for subnetting across an octet boundary has two steps:

  • Defining the subnetted address prefixes
  • Defining the range of usable IPv4 addresses for each subnetted address prefix

The following sections describe these steps.

Defining the Subnetted Address Prefixes

To subnet across an octet boundary, do the following:

  1. Based on n, the number of host bits you are using for subnetting, create a three-column table with 2n rows. The first column contains the subnet numbers (starting with 1), the second column contains representations of the 32-bit subnetted address prefixes as single decimal numbers, and the third column contains the dotted decimal representations of the subnetted address prefixes.
  2. Convert the address prefix (w.x.y.z) being subnetted from dotted decimal notation to N, a decimal representation of the 32-bit address prefix, using the following formula:

    N = w x 16777216 + x x 65536 + y x 256 + z

  3. Compute the increment value I using I = 2h where h is the number of host bits remaining.
  4. In the first row, place N, the decimal representation of the subnetted address prefix, in the second column, and place the subnetted address prefix w.x.y.z with its new prefix length in the third column.
  5. In the next row, add I to the previous row’s decimal representation, and place the result in the second column.
  6. Convert the decimal representation of the subnetted address prefix to dotted decimal notation (W.X.Y.Z) using the following formula (where s is the decimal representation of the subnetted address prefix):

    W = int(s/16777216)

    X = int((s mod(16777216))/65536)

    Y = int((s mod(65536))/256)

    Z = s mod(256)

    int( ) denotes integer division, and mod( ) denotes the modulus (the remainder upon division).

  7. Repeat steps 5 and 6 until you complete the table.

For example, to perform a 4-bit subnetting of the address prefix 192.168.180.0/22, construct a table with 16 (24) rows, as Table 4-7 shows. N, the decimal representation of 192.168.180.0, is 3232281600, which is the result of 192 x 16777216 + 168 x 65536 + 180 x 256. Because 6 host bits remain, the increment I is 26 = 64. Additional rows in the table are successive increments of 64.

Subnet Decimal Representation Subnetted Address Prefix
1 3232281600 192.168.180.0/26
2 3232281664 192.168.180.64/26
3 3232281728 192.168.180.128/26
4 3232281792 192.168.180.192/26
5 3232281856 192.168.181.0/26
6 3232281920 192.168.181.64/26
7 3232281984 192.168.181.128/26
8 3232282048 192.168.181.192/26
9 3232282112 192.168.182.0/26
10 3232282176 192.168.182.64/26
11 3232282240 192.168.182.128/26
12 3232282304 192.168.182.192/26
13 3232282368 192.168.183.0/26
14 3232282432 192.168.183.64/26
15 3232282496 192.168.183.128/26
16 3232282560 192.168.183.192/26

Table 4-7  Decimal Subnetting Technique for the 4-bit Subnetting of 192.168.180.0/22

This method is a completely general technique for subnetting, and you can also use it within an octet and across multiple octets.

Defining the Range of IPv4 Addresses for Each Subnet

To determine the range of usable host IDs for each subnetted address prefix, perform the following steps:

  1. Based on n, the number of host bits you are using for subnetting, create a three-column table with 2n rows. The first column contains the subnet numbers (starting with 1), the second column contains the decimal representation of the first and last IPv4 addresses for the subnetted address prefixes, and the third column contains the dotted decimal representation of the first and last IPv4 addresses of the subnetted address prefixes. Alternately, add two columns to the previous table used for enumerating the subnetted address prefixes using the decimal subnetting technique.
  2. Compute the increment value J based on h, the number of host bits remaining:

    J = 2h – 2

  3. The first IPv4 address is N + 1, in which N is the decimal representation of the subnetted address prefix. The last IPv4 address is N + J.
  4. Convert the decimal representation of the first and last IPv4 addresses to dotted decimal notation (W.X.Y.Z) using the following formula (where s is the decimal representation of the first or last IPv4 address):

    W = int(s/16777216)

    X = int((s mod(16777216))/65536)

    Y = int((s mod(65536))/256)

    Z = s mod(256)

    int( ) denotes integer division, and mod( ) denotes the modulus (the remainder upon division).

  5. Repeat steps 3 and 4 for each row of the table.

For example, Table 4-8 shows the range of IPv4 addresses for the 4-bit subnetting of 192.168.180.0/22. The increment J is 26 – 2 = 62.

Subnet Decimal Representation Range of IPv4 Addresses
1 3232281601-3232281662 192.168.180.1-192.168.180.62
2 3232281665-3232281726 192.168.180.65-192.168.180.126
3 3232281729-3232281790 192.168.180.129-192.168.180.190
4 3232281793-3232281854 192.168.180.193-192.168.180.254
5 3232281857-3232281918 192.168.181.1-192.168.181.62
6 3232281921-3232281982 192.168.181.65-192.168.181.126
7 3232281985-3232282046 192.168.181.129-192.168.181.190
8 3232282049-3232282110 192.168.181.193-192.168.181.254
9 3232282113-3232282174 192.168.182.1-192.168.182.62
10 3232282177-3232282238 192.168.182.65-192.168.182.126
11 3232282241-3232282302 192.168.182.129-192.168.182.190
12 3232282305-3232282366 192.168.182.193-192.168.182.254
13 3232282369-3232282430 192.168.183.1-192.168.183.62
14 3232282433-3232282494 192.168.183.65-192.168.183.126
15 3232282497-3232282558 192.168.183.129-192.168.183.190
16 3232282561-3232282622 192.168.183.193-192.168.183.254

Table 4-8  Decimal Enumeration of the Ranges of IPv4 Addresses for the 4-bit Subnetting of 192.168.180.0/22

Variable Length Subnetting

One of the original uses for subnetting was to subdivide a class-based address prefix into a series of equal-sized subnets. For example, a 4-bit subnetting of a class B address prefix produces 16 equal-sized subnets. However, subnetting is a general method of using host bits to express subnets and does not require equal-sized subnets.

Subnets of different sizes can exist within a class-based or classless address prefix. This practice is well suited to real-world environments, where networks of an organization contain different numbers of hosts, and you need different-sized subnets to avoid wasting IPv4 addresses. The practice of creating and deploying various-sized subnets from an IPv4 address prefix is known as variable length subnetting, and this technique uses variable prefix lengths, also known as variable length subnet masks (VLSMs).

Variable length subnetting is a technique of allocating subnetted address prefixes that use prefix lengths of different sizes. However, all subnetted address prefixes are unique, and you can distinguish them from each other by their corresponding prefix length.

Variable length subnetting essentially performs subnetting on a previously subnetted address prefix. When you subnet, you keep the fixed address prefix and choose a certain number of host bits to express subnets. With variable length subnetting, the address prefix being subnetted has already been subnetted.

Variable Length Subnetting Example

For example, given the address prefix of 157.54.0.0/16, the required configuration is to reserve half the addresses for future use, have 15 address prefixes for sites of the organization with up to 2,000 hosts, and create eight subnets with up to 250 hosts.

To achieve the requirement of reserving half the address space for future use, subnet 1 bit of the class-based address prefix of 157.54.0.0. This subnetting produces 2 subnets, 157.54.0.0/17 and 157.54.128.0/17, dividing the address space in half. You can fulfill the requirement by choosing 157.54.0.0/17 as the address prefix for the reserved portion of the address space.

Table 4-9 shows the reservation of half the address space.

Subnet Number Address Prefix (Dotted Decimal) Address Prefix (Prefix Length)
1 157.54.0.0, 255.255.128.0 157.54.0.0/17

Table 4-9  Reserving Half the Address Space

To fulfill the requirement of 15 address prefixes with approximately 2,000 hosts per prefix, subnet 4 bits of the subnetted address prefix of 157.54.128.0/17. This subnetting produces 16 address prefixes (157.54.128.0/21, 157.54.136.0/21…157.54.240.0/21, 157.54.248.0/21), allowing up to 2,046 hosts per address prefix. You can fulfill the requirement by choosing the first 15 subnetted address prefixes (157.54.128.0/21 to 157.54.240.0/21) as the address prefixes for other sites.

Table 4-10 illustrates 15 address prefixes with up to 2,046 hosts per subnet.

Subnet Number Address Prefix (Dotted Decimal) Address Prefix (Prefix Length)
1 157.54.128.0, 255.255.248.0 157.54.128.0/21
2 157.54.136.0, 255.255.248.0 157.54.136.0/21
3 157.54.144.0, 255.255.248.0 157.54.144.0/21
4 157.54.152.0, 255.255.248.0 157.54.152.0/21
5 157.54.160.0, 255.255.248.0 157.54.160.0/21
6 157.54.168.0, 255.255.248.0 157.54.168.0/21
7 157.54.176.0, 255.255.248.0 157.54.176.0/21
8 157.54.184.0, 255.255.248.0 157.54.184.0/21
9 157.54.192.0, 255.255.248.0 157.54.192.0/21
10 157.54.200.0, 255.255.248.0 157.54.200.0/21
11 157.54.208.0, 255.255.248.0 157.54.208.0/21
12 157.54.216.0, 255.255.248.0 157.54.216.0/21
13 157.54.224.0, 255.255.248.0 157.54.224.0/21
14 157.54.232.0, 255.255.248.0 157.54.232.0/21
15 157.54.240.0, 255.255.248.0 157.54.240.0/21

Table 4-10  Fifteen Address Prefixes with up to 2,046 Hosts

To achieve the requirement of eight subnets with up to 250 hosts, subnet 3 bits of the subnetted address prefix of 157.54.248.0/21. This subnetting produces eight subnets (157.54.248.0/24, 157.54.249.0/24…157.54.254.0/24, 157.54.255.0/24) and allows up to 254 hosts per subnet. You can fulfill the requirement by choosing all eight subnetted address prefixes (157.54.248.0/24 through 157.54.255.0/24) as the address prefixes to assign to individual subnets.

Table 4-11 illustrates eight subnets with 254 hosts per subnet.

Subnet Number Address Prefix (Dotted Decimal) Address Prefix (Prefix Length)
1 157.54.248.0, 255.255.255.0 157.54.248.0/24
2 157.54.249.0, 255.255.255.0 157.54.249.0/24
3 157.54.250.0, 255.255.255.0 157.54.250.0/24
4 157.54.251.0, 255.255.255.0 157.54.251.0/24
5 157.54.252.0, 255.255.255.0 157.54.252.0/24
6 157.54.253.0, 255.255.255.0 157.54.253.0/24
7 157.54.254.0, 255.255.255.0 157.54.254.0/24
8 157.54.255.0, 255.255.255.0 157.54.255.0/24

Table 4-11  Eight Subnets with up to 254 Hosts

Figure 4-4 shows the variable length subnetting of 157.54.0.0/16.


Bb726997.subtn404(en-us,TechNet.10).gif

Figure 4-4  Variable length subnetting of 157.54.0.0/16
Variable Length Subnetting and Routing

In dynamic routing environments, you can deploy variable length subnetting only where the prefix length is advertised along with the address prefix. Routing Information Protocol (RIP) for IP version 1 does not support variable length subnetting, but RIP for IP version 2, Open Shortest Path First (OSPF), and Border Gateway Protocol version 4 (BGPv4) do. For more information about these routing protocols, see Chapter 5, “IP Routing.”

Subnetting for IPv6

To subnet the IPv6 address space, you use subnetting techniques to divide the 16-bit Subnet ID field for a 48-bit global or unique local address prefix in a manner that allows for route summarization and delegation of the remaining address space to different portions of an IPv6 intranet.

You need not subnet in any specific fashion. The subnetting technique described here assumes that you subnet by dividing the variable portions of the address space of the Subnet ID field using its high-order bits. Although this method promotes hierarchical addressing and routing, it is not required. For example, in a small organization with a small number of subnets, you can also easily create a flat addressing space for global addresses by numbering the subnets starting from 0.

Subnetting a Global Address Prefix

For global addresses, Internet Assigned Numbers Authority (IANA) or an ISP assigns an IPv6 address prefix in which the first 48 bits are fixed. Subnetting the Subnet ID field for a 48-bit global address prefix requires a two-step procedure:

  1. Determine the number of bits to be used for the subnetting.
  2. Enumerate the new subnetted address prefixes.
Determining the Number of Subnetting Bits

The number of bits that you use for subnetting determines the possible number of new subnetted address prefixes that you can allocate to portions of your network based on geographical or departmental divisions. In a hierarchical routing infrastructure, you must determine how many address prefixes, and therefore how many bits, you need at each level in the hierarchy. The more bits you choose for the various levels of the hierarchy, the fewer bits you have to enumerate individual subnets in the last level of the hierarchy.

For example, you could decide to implement a two-level hierarchy reflecting a geographical/departmental structure and use 4 bits for the geographical level and 6 bits for the departmental level. This scheme allows for 16 geographical regions, and each department in each region has only 6 bits of subnetting space left (16 – 6 – 4), or only 64 (=26) subnets per department.

On any given level in the hierarchy, a number of bits are already fixed by the previous level in the hierarchy (f), a number of bits are used for subnetting at the current level in the hierarchy (s), and a number of bits remain for the next level down in the hierarchy (r). At all times, f+s+r = 16. Figure 4-5 shows this relationship.


Bb726997.subtn405(en-us,TechNet.10).gif

Figure 4-5  Subnetting the Subnet ID field of a global IPv6 address
Enumerating Subnetted Address Prefixes

Based on the number of bits used for subnetting, you must list the new subnetted address prefixes, and you can use either of two main approaches:

  • Enumerate the new subnetted address prefixes by using hexadecimal representations of the subnet ID and increment.
  • Enumerate the new subnetted address prefixes by using decimal representations of the subnet ID and increment.

Both methods produce the same result: an enumerated list of subnetted address prefixes.

To create the enumerated list of subnetted address prefixes using the hexadecimal method, perform the following steps:

  1. Based on s, the number of bits chosen for subnetting, and m, the prefix length of the address prefix being subnetted, calculate the following:

    f = m – 48

    f is the number of bits within the subnet ID that are already fixed.

    n = 2s

    n is the number of address prefixes that you will obtain.

    i = 216-(f+s)

    i is the incremental value between each successive subnet ID expressed in hexadecimal.

    P = m+s

    P is the prefix length of the new subnetted address prefixes.

  2. Create a two-column table with n rows. The first column contains the address prefix numbers (starting with 1), and the second column contains the new subnetted address prefixes.
  3. In the first row, place the original address prefix with the new prefix length in the second column. For example, based on F, the hexadecimal value of the subnet ID being subnetted, the subnetted address prefix is [48-bit prefix]:F::/P.
  4. In the next row, increment the value within the subnet ID portion of the site-local or global address by i, and place the result in the second column. For example, in the second row, the subnetted prefix is [48-bit prefix]:F+i::/P.
  5. Repeat step 4 until you complete the table.

For example, to perform a 3-bit subnetting of the global address prefix 2001:DB8:0:C000::/51, first calculate the values of the number of prefixes, the increment, and the new prefix length. Your starting values are F=0xC000, s=3, m=51, and therefore f=51-48=3. The number of prefixes is 8 (n=23). The increment is 0×400 (i=216-(3+3)=1024=0×400). The new prefix length is 54 (P=51+3).

Next, you construct a table with eight rows, as shown in Table 4-12. In the row for the address prefix 1, place 2001:DB8:0:C000::/54 in the second column, and complete the remaining rows by incrementing the Subnet ID portion of the address prefix by 0×400.

Address Prefix Subnetted Address Prefix
1 2001:DB8:0:C000::/54
2 2001:DB8:0:C400::/54
3 2001:DB8:0:C800::/54
4 2001:DB8:0:CC00::/54
5 2001:DB8:0:D000::/54
6 2001:DB8:0:D400::/54
7 2001:DB8:0:D800::/54
8 2001:DB8:0:DC00::/54

Table 4-12   Hexadecimal Technique for the 3-bit Subnetting of 2001:DB8:0:C000::/51

To create the enumerated list of subnetted address prefixes using the decimal method, do the following:

  1. Based on s, the number of bits you are using for subnetting, m, the prefix length of the address prefix being subnetted, and F, the hexadecimal value of the subnet ID being subnetted, calculate the following:

    f = m – 48

    f is the number of bits within the Subnet ID that are already fixed.

    n = 2s

    n is the number of address prefixes that you will obtain.

    i = 216-(f+s)

    i is the incremental value between each successive subnet ID.

    P = m+s

    P is the prefix length of the new subnetted address prefixes.

    D = decimal representation of F

  2. Create a three-column table with n rows. The first column contains the address prefix numbers (starting with 1), the second column contains the decimal representations of the Subnet ID portions of the new subnetted address prefixes, and the third column contains the new subnetted address prefixes.
  3. In the first row, place the decimal representation of the subnet ID (D) in the first column, and place the subnetted prefix, [48-bit prefix]:F::/P, in the second column.
  4. In the next row, increase the value of the decimal representation of the subnet ID by i, and place the result in the second column. For example, in the second row, the decimal representation of the subnet ID is D+i.
  5. In the third column, convert the decimal representation of the subnet ID to hexadecimal, and construct the prefix from [48-bit prefix]:[SubnetID]::/P. For example, in the second row, the subnetted address prefix is [48-bit prefix]:[D+i (converted to hexadecimal)]::/P.
  6. Repeat steps 4 and 5 until you complete the table.

For example, to perform a 3-bit subnetting of the site-local address prefix 2001:DB8:0:C000::/51, first calculate the values of the number of prefixes, the increment, the new prefix length, and the decimal representation of the starting subnet ID. Our starting values are F=0xC000, s=3, m=51, and therefore f=51-48=3. The number of prefixes is 8 (n=23). The increment is 1024 (i=216-(3+3)). The new prefix length is 54 (P=51+3). The decimal representation of the starting subnet ID is 49152 (D=0xC000=49152).

Next, construct a table with 8 rows as Table 4-13 shows. In the row for the address prefix 1, place 49152 in the first column and 2001:DB8:0:C000::/54 in the second column. In the remaining rows, increment the subnet ID portion of the address prefix (the fourth hexadecimal block) by 1024 and convert to hexadecimal.

Address Prefix Decimal Representation of Subnet ID Subnetted Address Prefix
1 49152 2001:DB8:0:C000::/54
2 50176 2001:DB8:0:C400::/54
3 51200 2001:DB8:0:C800::/54
4 52224 2001:DB8:0:CC00::/54
5 53248 2001:DB8:0:D000::/54
6 54272 2001:DB8:0:D400::/54
7 55296 2001:DB8:0:D800::/54
8 56320 2001:DB8:0:DC00::/54

Table 4-13  Decimal Technique for the 3-bit Subnetting of 2001:DB8:0:C000::/51

Variable Length Subnetting

Just as in IPv4, you can subnet IPv6 address prefixes recursively, up to the 64 bits that define the address prefix for an individual subnet, to provide route summarization at various levels of an organization intranet. Unlike IPv4, you cannot use variable-length subnetting to create different sized subnets because all IPv6 subnets use a 64-bit subnet prefix and a 64-bit interface ID.

Chapter Summary

The key information in this chapter is the following:

  • Subnetting is a set of techniques that you can use to efficiently allocate the address space of one or more unicast address prefixes among the subnets of an organization network.
  • To determine the subnet prefix of an IPv4 address configuration in prefix length notation (w.x.y.z/n), retain the n high-order bits, set all the remaining bits to 0, and then convert the result to dotted decimal notation. To determine the subnet prefix of an IPv4 address configuration in subnet mask notation, perform a bit-wise logical AND between the IPv4 address and its subnet mask.
  • When determining the number of host ID bits in an IPv4 address prefix to use for subnetting, choose more subnets over more hosts per subnet if you have more possible host IDs than are practical to use on a given subnet.
  • To subnet an IPv4 address prefix, use either binary or decimal methods as described in this chapter to enumerate the subnetted address prefixes and the ranges of usable IPv4 addresses for each subnet.
  • Variable length subnetting is a technique of creating subnetted IPv4 address prefixes that use prefix lengths of different sizes.
  • To subnet an IPv6 global address prefix, use either hexadecimal or decimal methods as described in this chapter to enumerate the subnetted address prefixes.

Chapter Glossary

subnetting – The act of subdividing the address space of an IPv4 or IPv6 address prefix.

subnetted address prefix – Either a new IPv4 address prefix that is the result of subnetting an IPv4 address prefix or a new IPv6 address prefix that is the result of subnetting an IPv6 address prefix.

variable length subnet masks (VLSMs) – The use of different subnet masks to produce subnets of different sizes.

variable length subnetting – The practice of using variable length subnet masks.

quick awk man

Why awk?

The Awk text-processing programming language and is a useful tool for manipulating text.

  • Awk recognizes the concepts of “file”, “record”, and “field”.
  • A file consists of records, which by default are the lines of the file. One line becomes one record.
  • Awk operates on one record at a time.
  • A record consists of fields, which by default are separated by any number of spaces or tabs.
  • Field number 1 is accessed with $1, field 2 with $2, and so forth. $0 refers to the whole record.
    [awkuser@p3nlh096 ~]$ awk -help
    Usage: awk [POSIX or GNU style options] -f progfile [--] file ...
    Usage: awk [POSIX or GNU style options] [--] 'program' file ...
    POSIX options:          GNU long options:
            -f progfile             --file=progfile
            -F fs                   --field-separator=fs
            -v var=val              --assign=var=val
            -m[fr] val
            -W compat               --compat
            -W copyleft             --copyleft
            -W copyright            --copyright
            -W dump-variables[=file]        --dump-variables[=file]
            -W exec=file            --exec=file
            -W gen-po               --gen-po
            -W help                 --help
            -W lint[=fatal]         --lint[=fatal]
            -W lint-old             --lint-old
            -W non-decimal-data     --non-decimal-data
            -W profile[=file]       --profile[=file]
            -W posix                --posix
            -W re-interval          --re-interval
            -W source=program-text  --source=program-text
            -W traditional          --traditional
            -W usage                --usage
            -W version              --version
    
    To report bugs, see node `Bugs' in `gawk.info', which is
    section `Reporting Problems and Bugs' in the printed version.
    
    gawk is a pattern scanning and processing language.
    By default it reads standard input and writes standard output.
    
    Examples:
            gawk '{ sum += $1 }; END { print sum }' file
            gawk -F: '{ print $1 }' /etc/passwd
    

    Now, for an explanation of the { print } code block. In awk, curly braces are used to group blocks of code together, similar to C. Inside our block of code, we have a single print command. In awk, when a print command appears by itself, the full contents of the current line are printed.

    $ awk '{ print $0 }' /etc/passwd
    
    output
    -------
    root:x:0:0:root:/root:/bin/bash
    daemon:x:1:1:daemon:/usr/sbin:/bin/sh
    bin:x:2:2:bin:/bin:/bin/sh
    sys:x:3:3:sys:/dev:/bin/sh
    sync:x:4:65534:sync:/bin:/bin/sync
    ...
    

    In awk, the $0 variable represents the entire current line, so print and print $0 do exactly the same thing.

    $ awk '{ print "" }' /etc/passwd
    
    $ awk '{ print "hello" }' /etc/passwd
    

    Running this script will fill your screen with hello’s.

    AWK Variables

    awk variables are initialized to either zero or the empty string the first time they are used.

    Variables

  • Variable declaration is not required
  • May contain any type of data, their data type may change over the life of the program
  • Must begin with a letter and continuing with letters, digits and underscores
  • Are case senstive
  • Some of the commonly used built-in variables are:
    • NR — The current line’s sequential number
    • NF — The number of fields in the current line
    • FS — The input field separator; defaults to whitespace and is reset by the -F command line parameter
    /test$ cat calc
    3 56
    567 89
    /test$ awk '{d=($2-($1-4));s=($2+$1);print d/sqrt(s),d*d/s }' calc
    7.42077 55.0678
    -18.5066 342.494
    /test$
    

    in above example we have a file calc with two rows and two columns.
    Note that the final statement, a “print” in this case, does not need a semicolon. It doesn’t hurt to put it in, though.

    Integer variables can be used to refer to fields. If one field contains information about which other field is important, this script will print only the important field:

    $ awk '{imp=$1; print $imp }' calc
    

    The special variable NF tells you how many fields are in this record. This script prints the first and last field from each record, regardless of how many fields there are:

    if now calc file is

    3 56 abd
    567 89 xyz
    
    $ awk '{print $1,$NF }' calc
    3 abd
    567 xyz
    

    Begin and End

    Any action associated with the BEGIN pattern will happen before any line-by-line processing is done.
    Actions with the END pattern will happen after all lines are processed.

    1.One is to just mash them together, like so:
    >
    
    awk 'BEGIN{print"fee"} $1=="foo"{print"fi"}
         END{print"fo fum"}' filename
    

    AWK Arrays

    awk has arrays, but they are only indexed by strings. This can be very useful, but it can also be annoying. For example, we can count the frequency of words in a document (ignoring the icky part about printing them out):

    $ awk '{for(i=1;i <=NF;i++) freq[$i]++ }' filename
    

    The array will hold an integer value for each word that occurred in the file. Unfortunately, this treats “foo”, “Foo”, and “foo,” as different words. Oh well. How do we print out these frequencies? awk has a special “for” construct that loops over the values in an array. This script is longer than most command lines, so it will be expressed as an executable script:

    #!/usr/bin/awk -f
    {for(i=1;i <=NF;i++) freq[$i]++ }
    END{for(word in freq) print word, freq[word]
    }
    

    AWK Regular expressions and blocks

    awk '/pattern_to_match/ {actions}' input_file
    
    awk '/foo/ { print }' abc.txt
    
    cat abc.txt|awk '/[0-9]+.[0-9]*/ { print }'
    

    Expressions and blocks

    fredprint

    $1 == “fred” { print $3 }

    root

    $5 ~ /root/ { print $3 }

    AWK Conditional statements

    awk '{
       if ( $1 ~ /root/ )
      {
       print $1
      }
    }' /etc/passwd
    

    Both scripts function identically. In the first example, the boolean expression is placed outside the block, while in the second example, the block is executed for every input line, and we selectively perform the print command by using an if statement. Both methods are available, and you can choose the one that best meshes with the other parts of your script.

    if
    {
    	if ( $1 == "foo" ) {
    		if ( $2 == "foo" ) {
    			print "uno"
    		} else {
    			print "one"
    		}
    	} else if ($1 == "bar" ) {
    		print "two"
    	} else {
    		print "three"
    	}
    }
    
    if
    ! /matchme/ { print $1 $3 $4 }
    {
    	if ( $0 !~ /matchme/ ) {
    		print $1 $3 $4
    	}
    }
    

    Both scripts will output only those lines that don’t contain a matchme character sequence. Again, you can choose the method that works best for your code. They both do the same thing.

    ( $1 == “foo” ) && ( $2 == “bar” ) { print }

    This example will print only those lines where field one equals foo and field two equals bar.

  • Examples


    Print every line after erasing the 2nd field

    awk '{$2 = ""; print}' file
    

    Print hi 48 times

    yes | head -48 | awk '{ print "hi" }'
    

    Print hi.0010 to hi.0099

    yes | head -90 | awk '{printf("hi00%2.0f n", NR+9)}'
    

    print when column 3 is < 1900 (in myfile.txt). If a value is not numeric, it doesn’t complain

    cat myfile.txt| awk '{if ($3 < 1900) print $3, " ",$5,$7,$8}'
    

    Count number of lines where col 3 > col 1

    awk '$3 > $1 {print i + "1"; i++}' file

    print only lines of less than 65 characters

    awk 'length < 64'
     
    

    certmatrics support

    In order to research your missing scores we will need you to submit a complete copy (all pages) of the missing exam score report in question, along with a legal I.D. (drivers license or passport).

    You can either scan or fax this information to us. Please subject your submittal: ATTENTION: Skills Certification – Missing Exam.  If you want to scan your document please use the Submit a Ticket feature and attach your scanned score report of the missing exam (all pages) to the ticket. If you wish to fax your score report please fax your score report (all pages) to: 1-630-268-9071.  Please include a daytime phone and email address.

    The Skills Certification Data Department will investigate your submission. Please allow a minimum of 7 business days for review. Based on our findings, your record will be updated and/or corrected to reflect the determination. You will be notified via email when the investigation has been completed.

    metricsthatmatter.com

    2969685 – cnguyen

    Old DC Bookmark

    DC Info & Tools

    Dell’s Microsoft Internal Website
    EEMS Portal.NET reboot tool
    Extranet Security Document Center
    Home – GTS Client Engagement Site
    Home – GTS Morning Ops Call
    Home – Service Support Group
    Home – TK MCSS
    http–eismetrics-MSInsight-default.asp
    HW Stds Procesess
    Infopaq
    IPAK Scheduler
    IT Resource Center – warranty check
    ITG Service Pack for Windows
    ITLabs
    MAC or IP Hunt Tool
    Microsoft Application Portfolio System (MS Apps Home)
    MITVIPNET
    MS OnTARGET
    Network Switch Impact Tool
    OurBrook Configuration Manager
    Port Shut Results
    Post Core Hotfixes and Security Fixes
    Puget Sound Migration Project
    Rainier – Home
    Security Patch Status OTG GTS Manageability Services
    Switch Port Info
    warranty lookup – HP Business Support Center

    Links

    .. AM 620 KPOJ — Progressive Talk ..
    AM 1090 Progressive Talk Seattle
    Big-Boys.com – Funny Pics, Hot Chicks, and Cool Flicks
    Customize Links
    Forum Fun – ebaumsworld.com
    Free Hotmail
    Home – Center for American Progress
    Home – First Tech Credit Union
    Jubak’s Journal — Jubak’s 50 best stocks in the world – MSN Money
    Listen Live Air America Radio
    Microsoft Company Store
    Mini Putt-Putt Golf
    MSN Money – Personal finance, money, online banking, retirement planning, taxes, message boards
    MSN.com
    Panda Pang – Jeux flash
    Radio Station Guide
    Ring of Fire with Robert F. Kennedy Jr. and Mike Papantonio
    Talk City 1240 AM
    The MIC 92.1
    TomPaine.com – Home
    Welcome to Scottrade
    Windows Marketplace
    Windows Media
    Windows
    WSDOT Puget Sound Area Traffic Cameras

    Longhorn

    Web Feeds

    Community Articles
    IE Add-ons
    IE Team Blog
    Home – Drivers 911
    Home – Drivers
    IE Add-on site
    Microsoft Windows Vista Developer Center
    Microsoft Windows Vista
    MSDN IE
    MSPKD
    See what’s new in IE7
    TechNet IE
    Windows Update

    SKUs & Exceptions

    CSE Hardware Technology
    Home – GTS Client Engagement Site
    Home – IPAKX
    HW Stds Procesess – EOL
    IT Utilities Services Engineering – Hardware

    techinfo

    Bugcheck
    CodeTranslator Free Code Translation From VB.NET – C#
    Debugger Team
    Enterprise Servers, Workstations and Systems Hardware
    Enterprise Storage Solutions
    Home – Windows Diagnostic Portal
    HPQ Enterprise Servers, Workstations and Systems Hardware
    Hyper-Threading Technology
    Infopaq
    Intel® Hyper-Threading Technology (HT Technology) Demo for Servers
    Microsoft Knowledge Express 2.0
    MS-IT Utility Services Engineering – Data Storage
    Performance Monitoring for Windows Server 2003 and 2000
    T10 Technical Committee
    TechNet Discussion Groups Home
    Using HSRP for Fault-Tolerant IP Routing
    Visual KB 2.0
    Welcome to Script Center
    Windows Clustering Technologies Web Site
    Windows Network Load Balancing Configuration – Best Practices
    Windows Server 2003 Microsoft Internet Protocol Version 6 (IPv6)
    Windows Server 2003 Technical Overviews
    Windows Server 2003 Technology Centers
    Windows Server System Reference Architecture
    WMI Scripting Primer Part 1
    WMIC A New Approach to Managing Windows Infrastructure from a Command Line

    training

    BLDWEB Training HOME Page
    Debugging
    EDG Training Course Registration
    Employee Coach
    For HP Certified Professionals
    Free MCP Exam FAQ
    Global Learning Services
    Home – MCSS Training
    Home – SAN Training Page
    Microsoft Training & Certification
    Programming a SQL Server 2000 DB
    Scripting Guys’ Webcasts
    SNIA – Storage Networking Industry Association Certification
    SQL Server 2000 Administration
    The Learning Portal
    TMS Registration 1.6
    Compaq Insight Manager 7 Login
    Home – ASDDT Escalation Tools
    Home – ASDDT
    Home – GTS Morning Ops Call
    IT Utilities Services Engineering – Hardware
    ITChange
    ITConfig
    Microsoft Company Store
    Microsoft Service Enterprise – Backup
    Microsoft Service Enterprise
    Microsoft Solution – CSP Set Up Instructions
    MSE
    OWA Redmond (RED)
    Rainier – Home

    Search Provider XML

    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
        <ShortName>AOL Search</ShortName>
        <Description>Search the Web with AOL</Description>
        <Url type=”text/html” template=”http://search.aol.com/aolcom/search?query={searchTerms}&amp;invocationType=msie70a” />
    </OpenSearchDescription>
    _____________________________________________________________________________________________________
    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
        <ShortName>Ask.com</ShortName>
        <Description>Better search tools for better results </Description>
        <Url type=”text/html” template=”http://www.ask.com/web?q={searchTerms}&amp;qsrc=0&amp;o=0&amp;l=dir ” />
    </OpenSearchDescription>

    _____________________________________________________________________________________________________
    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
        <ShortName>Bing</ShortName>
        <Tags>Bing</Tags>
        <Description>Bing. Search by Microsoft.</Description>
        <Contact>msosa@microsoft.com</Contact>
        <InputEncoding>UTF-8</InputEncoding>
        <SyndicationRight>limited</SyndicationRight>
        <Image width=”16″ height=”16″ type=”image/x-icon”>http://www.bing.com/favicon.ico</Image>
        <Url type=”text/html” template=”http://www.bing.com/search?q={searchTerms}&amp;form=IE8SRC&amp;src=IE-SearchBox” />
        <Url type=”application/x-suggestions+xml” template=”http://api.bing.com/qsml.aspx?query={searchTerms}&amp;market={Language}&amp;form=IE8SSC&amp;maxwidth={ie:maxWidth}&amp;rowheight={ie:rowHeight}&amp;sectionHeight={ie:sectionHeight}” />
    </OpenSearchDescription>

    _____________________________________________________________________________________________________
    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
        <ShortName>Google</ShortName>
        <Description>Google Web Search</Description>
        <Url type=”text/html” template=”http://www.google.com/search?q={searchTerms}&amp;rls=com.microsoft:{language}&amp;ie={inputEncoding}&amp;oe={outputEncoding}&amp;startIndex={startIndex?}&amp;startPage={startPage}” />
     <Url type=”application/x-suggestions+json” template=”http://suggestqueries.google.com/complete/search?output=firefox&amp;client=IE8&amp;qu={searchTerms}” />
     <Url type=”application/x-suggestions+xml” template=”http://clients5.google.com/complete/search?hl={language}&amp;q={searchTerms}&amp;client=ie8&amp;inputencoding={inputEncoding}&amp;outputencoding={outputEncoding}” />
        <Image height=”16″ width=”16″ type=”image/icon”>http://www.google.com/favicon.ico</Image>
    </OpenSearchDescription>
    _____________________________________________________________________________________________________
    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
      <ShortName>Lycos</ShortName>
      <Description>Use Lycos.com to search the Web.</Description>
      <Tags>lycos search</Tags>
      <Url type=”text/html” template=”http://search.lycos.com/setup.php?src=ie&amp;query={searchTerms}”/>
    </OpenSearchDescription>

    _____________________________________________________________________________________________________
    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
        <ShortName>Yahoo! Search</ShortName>
        <Description>Yahoo! Web Search</Description>
        <Url type=”text/html” template=”http://search.yahoo.com/search?p={searchTerms}&amp;ei=utf-8&amp;fr=b2ie7” />
     <Url type=”application/x-suggestions+xml” template=”http://ie.search.yahoo.com/os?command={SearchTerms}”/>
       <Image height=”16″ width=”16″ type=”image/icon”>http://search.yahoo.com/favicon.ico</Image>
     </OpenSearchDescription>
    _____________________________________________________________________________________________________
    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
        <ShortName>About.com</ShortName>
        <Description>Search for information at About.com</Description>
        <Url type=”text/html” template=”http://search.about.com/fullsearch.htm?terms={searchTerms}” />
     <Image height=”16″ width=”16″ type=”image/vnd.microsoft.icon”>http://www.about.com/favicon.ico</Image>
    </OpenSearchDescription>
    _____________________________________________________________________________________________________
    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
        <ShortName>Amazon.com</ShortName>
        <Description>Search Amazon’s online stores</Description>
        <Url type=”text/html” template=”http://www.amazon.com/gp/search?ie=UTF8&amp;tag=ie8search-20&amp;index=blended&amp;linkCode=qs&amp;camp=1789&amp;creative=9325&amp;keywords={searchTerms}” />
     <Url type=”application/x-suggestions+xml” template=”http://xml-us.amznxslt.com/onca/xml?Service=AWSECommerceService&amp;Version=2008-06-26&amp;Operation=ItemSearch&amp;AWSAccessKeyId=15HRV3AZSMPK0GXTY102&amp;AssociateTag=ie8suggestion-20&amp;ResponseGroup=ItemAttributes,OfferListings,Reviews,Images&amp;MerchantId=FeaturedBuyBoxMerchant&amp;SearchIndex=All&amp;Keywords={searchTerms}&amp;Style=http%3A%2F%2Fg-ecx.images-amazon.com%2Fimages%2FG%2F01%2FAssociates%2FApps%2FIE8Search%2FOpenSearchDescription.xml”/>

    </OpenSearchDescription><?xml version=”1.0″ encoding=”UTF-8″?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
                <ShortName>BestBuy.com</ShortName>
                <Description>BestBuy.com provider</Description>

                <Url type=”text/html”
                       template=”http://www.bestbuy.com/site/olspage.jsp?_dyncharset=ISO-8859-1&amp;id=pcat17071&amp;type=page&amp;st={searchTerms}&amp;sc=Global&amp;cp=1&amp;nrp=15&amp;sp=&amp;qp=&amp;list=n&amp;iht=y&amp;usc=All+Categories”/
    </OpenSearchDescription>

    _____________________________________________________________________________________________________
    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
        <ShortName>cnet</ShortName>
        <Description>Search tech news, reviews &amp; downloads</Description>
        <Url type=”text/html” template=”http://cnet.search.com/search?chkpt=astg.cnet.fd.search.cnet&amp;q={searchTerms}&amp;tag=srch” />
        <Image height=”16″ width=”16″ type=”image/vnd.microsoft.icon”>http://www.cnet.com/favicon.ico</Image>
    </OpenSearchDescription>
    _____________________________________________________________________________________________________
    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
        <ShortName>eBay</ShortName>
        <Description>Search Online Auctions</Description>
        <Url type=”text/html” template=”http://rover.ebay.com/rover/1/711-43047-14818-1/4?satitle={searchTerms}” />
     <Url type=”application/x-suggestions+xml” template=”http://ie8.ebay.com/open-search/output-xml.php?q={searchTerms}&amp;c=0″/>
    </OpenSearchDescription>
    _____________________________________________________________________________________________________
    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
        <ShortName>ESPN</ShortName>
        <Description>Search ESPN</Description>
        <Url type=”text/html” template=”http://search.espn.go.com/keyword/search?searchString={searchTerms}” />
    <Image height=”16″ width=”16″ type=”image/vnd.microsoft.icon”>http://espn.go.com/favicon.ico</Image>
    </OpenSearchDescription><?xml version=”1.0″ encoding=”UTF-8″?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
      <ShortName>Expedia Search</ShortName>
      <Description>Search Expedia.com for travel.</Description>
      <SyndicationRight>limited</SyndicationRight>
      <Tags>expedia travel hotels flights cruises cars</Tags>
      <Query role=”example” searchTerms=”lax to nyc” />
      <Url type=”text/html” template=”http://www.expedia.com/daily/exl/search.asp?q={searchTerms}&amp;source=ie7″/>
    </OpenSearchDescription><?xml version=”1.0″ encoding=”utf-8″?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/
                           xmlns:moz=”http://www.mozilla.org/2006/browser/search/“>
      <ShortName>Facebook</ShortName>
      <Description>Search Facebook</Description>
      <InputEncoding>UTF-8</InputEncoding>
      <Image height=”16″ width=”16″ type=”image/x-icon”>http://www.facebook.com/favicon.ico</Image>
      <Url type=”text/html” method=”get” template=”http://www.facebook.com/search/?src=os&amp;q={searchTerms}”/>
      <Url type=”application/x-suggestions+xml” template=”http://www.facebook.com/search/opensearch_typeahead.php?format=xml&amp;q={searchTerms}”/>
      <Url type=”application/opensearchdescription+xml” rel=”self” template=”http://www.facebook.com/opensearch_desc.xml”/>
      <moz:SearchForm>http://www.facebook.com/search/</moz:SearchForm>
    </OpenSearchDescription>

    _____________________________________________________________________________________________________
    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
        <ShortName>Microsoft.com Search</ShortName>
        <Description>Search Microsoft.com</Description>
        <Url type=”text/html” template=”http://search.microsoft.com/results.aspx?mkt=en-US&amp;setlang=en-US&amp;q={searchTerms}” />
    </OpenSearchDescription>
    _____________________________________________________________________________________________________
    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
        <ShortName>Monster</ShortName>
        <Description>Search for jobs online</Description>
        <Url type=”text/html” template=”http://jobsearch.monster.com/jobsearch.asp?q={searchTerms}&amp;fn=&amp;lid=&amp;re=104&amp;cy=us&amp;x=52&amp;y=10” />
    </OpenSearchDescription>
    _____________________________________________________________________________________________________
    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
        <ShortName>MTV.com</ShortName>
        <Description>Search Music, Videos and TV Shows</Description>
        <Tags>Amazon.com Search</Tags>     
        <Url type=”text/html” template=”http://www.mtv.com/search/index.jhtml?searchterm={searchTerms}&amp;searchtype=all” />
    </OpenSearchDescription>
    _____________________________________________________________________________________________________
    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
    <ShortName>MySpace</ShortName>
    <Description>Search for friends, bands, video and more. </Description>
    <Image width=”16″ height=”16″>http://www.myspace.com/favicon.ico</Image>
    <InputEncoding>UTF-8</InputEncoding>
    <Url type=”text/html” template=”http://sads.myspace.com/Modules/Search/Pages/Search.aspx?fuseaction=advancedFind.results&amp;searchtarget=tms&amp;searchtype=myspace&amp;t=tms&amp;get=1&amp;websearch=1&amp;searchBoxID=HeaderWebResults&amp;searchString={searchTerms}&amp;q={searchTerms}” />
    </OpenSearchDescription><!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd“>
    <html xmlns=”http://www.w3.org/1999/xhtml“>
    <head>
    <meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″/>
    <title>404 – File or directory not found.</title>
    <style type=”text/css”>
    <!–
    body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
    fieldset{padding:0 15px 10px 15px;}
    h1{font-size:2.4em;margin:0;color:#FFF;}
    h2{font-size:1.7em;margin:0;color:#CC0000;}
    h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
    #header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:”trebuchet MS”, Verdana, sans-serif;color:#FFF;
    background-color:#555555;}
    #content{margin:0 0 0 2%;position:relative;}
    .content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
    –>
    </style>
    </head>
    <body>
    <div id=”header”><h1>Server Error</h1></div>
    <div id=”content”>
     <div><fieldset>
      <h2>404 – File or directory not found.</h2>
      <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>
     </fieldset></div>
    </div>
    </body>
    </html>

    _____________________________________________________________________________________________________
    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
        <ShortName>Shopzilla</ShortName>
        <Description>Search for products at the right price</Description>
        <Url type=”text/html” template=”http://www.shopzilla.com/buy/superfind.xpml?search_box=1&amp;sfsk=0&amp;cat_id=1&amp;keyword={searchTerms}” />
    </OpenSearchDescription>
    _____________________________________________________________________________________________________
    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
        <ShortName>SuperPages.com</ShortName>
        <Description>Search for U.S. Businesses in Verizon’s Online Yellow Pages </Description>
        <Url type=”text/html” template=”http://yellowpages.superpages.com/searchbar/search?SRC=spbar-msn&amp;C={searchTerms}” />
    </OpenSearchDescription>
    _____________________________________________________________________________________________________
    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
        <ShortName>Target</ShortName>
        <Description>Search and shop Target.com</Description>
        <Url type=”text/html” template=”http://www.target.com/gp/search.html?field-keywords={searchTerms}” />
    </OpenSearchDescription>
    _____________________________________________________________________________________________________
    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
        <ShortName>USATODAY.com</ShortName>
        <Description>Search news online</Description>
        <Url type=”text/html” template=”http://asp.usatoday.com/search/yahoo/search.aspx?qt=both&amp;nr=5&amp;kw={searchTerms}” />
    </OpenSearchDescription>
    _____________________________________________________________________________________________________
    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
        <ShortName>Walmart</ShortName>
        <Description>Search Walmart’s Always Low Prices</Description>
        <Url type=”text/html” template=”http://www.walmart.com/catalog/search-ng.gsp?search_constraint=0&amp;search_query={searchTerms}” />
    </OpenSearchDescription>
    _____________________________________________________________________________________________________
    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/“>
        <ShortName>Weather Channel</ShortName>
        <Description>Search for weather information</Description>
        <Url type=”text/html” template=”http://www.weather.com/search/enhanced?where={searchTerms}” />
    </OpenSearchDescription>

    Follow

    Get every new post delivered to your Inbox.