Most of this article is applicable to any Unix or Linux, but
some examples of "route" commands are not.
There are a few fundamental ideas about TCP/IP networks that
people seem to get confused about. This article might help.
See also Routing and
Advanced TCP .
First, let's pretend that you are setting up a few machines, but
they will not be connected to the Internet. They are all yours,
under your control. In this situation, you can use any IP addresses
you want; the addresses just have to meet certain rules:
IP addresses look like this:
Each of the numbers between the dots must be between 1 and 254
(except sometimes some of the numbers can be zero's, but for now we
won't use those). For reasons we'll go into later, a good choice
would be to use some number beginning with 10, but you can choose
something else if you insist. The very worst choice you could make
would be 127 (for the very first number only; it's OK elsewhere),
so stay away from that one for now (it's special).
You'll also need a "subnet mask". Your choice for that depends
on how many machines will be on this network. Your choices would
up to 254 255.255.255.0
up to 64,516 255.255.0.0
up to 16,387,064 255.0.0.0
It is possible that you may have been assigned a number or range
of numbers and a mask by someone else. If so, just go with the flow
for now and pretend that isn't true. If it is true, the
number(s) you have may be a little strange because they are
"supernetted", or assigned out of a specific block of numbers. This
will be covered in another article (November 1998, I hope), but for
now just accept that you have something different and this "basics"
article doesn't cover that.
If you don't have an assigned number, then you should use one in
the following ranges:
- 10.0.0.1 throuugh 10.254.254.254
- 172.16.0.1 through 172.31.254.254
- 192.168.0.1 through 192.168.254.254
Nowadays, those ranges would usually be referred to with
their CIDR notation:
Every machine needs a unique number. So, if I were setting up
the very first machine, I might assign it 10.1.1.30, and then the
next 10.1.1.31, and so on. What I can't do is decide that machine
number 4 will be 220.127.116.11. instead of 10.1.1.34 And, if I used the
subnet mask of 255.255.255.0, I can't assign the next machine
The reason for that has to do with that mysterious subnet mask,
and this is where it gets confusing. Really, it's simple: it's just
one of those silly things that seem confusing at first.
Think of the "255"'s as markers that determine how many of the
numbers in your network addresses cannot be changed (that is, if
they were changed, the address would be on a different subnet). If
your network mask is 255.255.255.0 and you started numbering
machines as 10.1.1.30 , then you cannot change the 10.1.1 part in
any address. So all of these numbers are good:
but all of these are "bad" (that is, they are on a different
Why does it matter if they are on a different subnet? Because
you can't talk (telnet, ftp, ping) to machines on a different
subnet without a route. There are good reasons why you might
actually want this (such as having too many machines for one
subnet, or for security, or for performance reasons), but we'll
talk about those in another article.
If you had used 255.255.0.0 as your mask, then only the 10.1
part would be frozen, and you could use:
Remember the 10.1.1.30 was just one choice we could have made.
Instead we might have chosen 172.16.35.40 as the address for our
first machine. If our mask again were 255.255.255.0 , then the
172.16.35 would be the "fixed" part of our addresses.
Why would you choose one network mask over another? Good
question. If you think about it, one answer might be because your
choice affects how many hosts (machines) you can have in the one
subnet. If the mask is 255.255.255.0, then the first three octets
(geek talk for the first three numbers; "octet" because they are 8
bit numbers) are fixed; you can't change them without changing the
subnet. That would leave only 0 to 255 for hosts, and you can't (I
haven't told you why yet, so just accept it for now) use 0 or 255
here, so that's only 253 machines, which might not be enough even
if you aren't General Motors Corp. So you might need to use
255.255.0.0 to get more hosts.
That "fixed" part is actually the "network" address. I said
earlier that you can't change any of those fixed numbers. If you
do, you are creating another network, and if machines on one
network (say 10.1.1) need to talk to machines having a different
network address (all beginning with 172.16.76, for example), they
need to do so through a "router", which can be a machine with two
(or more) network cards in it, or a specialized piece of equipment.
Whatever it is, the router will always have addresses on every
network it is connected to.
So, a router might have 10.1.1.1 on one port, and 192.168.15.1
on another. Visualize a bunch of machines to the left of this box
all having addresses beginning with 10.1.1, and another bunch of
machines to the right of it all with addresses beginning
If a machine on the left wants to talk to a machine on the
right, it cannot unless it has a route to that other
machine. In many cases, those are the only other machines that the
machine on the left can talk to, so the route becomes the
In every case, when setting a route, the route must be to a
machine on the same network (with the same "fixed" numbers) as the
machine you are setting it on. So, if you are setting a route on
machine 10.1.1.40, the address on the router must be the 10.1.1
address. It cannot be the 192.168.15 address or any other address
on the router. This is because ordinary machines (machines that are
not routers) can ONLY talk to machines on their very own
network. So, if you were working on machine 10.1.30 in this
imaginary network, and you wanted to set a route to the 192.168.15
network, you might say:
route add 192.168.15.0 10.1.1.1
route add default 10.1.1.1
What you'd be saying in the second case is "send anything that
isn't on my network to 10.1.1.1, and (I hope) that machine will get
it to where it needs to go".
To make that route permanent, you need to do more. For SCO, see
Routing. For NT, a /P adds
the route to the registry. Linux has a slightly different format
for the command; you need a "gw" keyword after default, and to make
it permanent you'd usually use "linuxconf".
Changing an ip address after you've assigned it can be more work
than you might think. For SCO, see Jeff Liebermann's SCO Page See also:
Publish your articles, comments, book
reviews or opinions here!
Got something to add? Send me email.
Increase ad revenue 50-250% with Ezoic
More Articles by Tony Lawrence
Find me on Google+
© 2012-07-14 Tony Lawrence