There are a few fundamental ideas about TCP/IP networks that people seem to get confused about. This article might help.
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:
10.1.1.80
192.168.6.200
172.16.21.7
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 be:
Machines Maskup to 254 255.255.255.0up to 64,516 255.255.0.0up 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:
10.0.0.0/8
172.16.0.0/12
192.168.0.0/16
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 11.1.1.34. 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 10.1.4.30 either.
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:
10.1.1.98
10.1.1.15
10.1.1.223
but all of these are "bad" (that is, they are on a different subnet):
10.1.2.98
10.3.1.15
172.16.1.223
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:
10.1.32.98
10.1.15.15
10.1.223.223
but not:
10.2.32.98
172.16.15.15
192.168.223.223
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 192.168.15.
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 default route.
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
or even:
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 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".
Advanced TCP/IP
I mentioned earlier that certain network numbers are "special", and that they would be bad choices. You may also realize (or need to know) that if the machines you are assigning numbers to are connected directly to the Internet, without going through a firewall or router that is translating or otherwise proxying network addresses, the choice of numbers isn't up to you at all. That's because the IP addresses used on the Internet are specifically asigned to the people who own them: you can't just grab any arbitrary number out of a hat and use it. You have to get your own assigned IP addressees.
|
In many companies, IP addresses are assigned automatically by a DHCP (Dynamic Host Configuration Protocol) server. Still, somebody has to tell that server what addresses to hand out. |
However, most small business networks either are not connected at all, or will be connected through a NAT (Network Address Translation) router or through a proxy firewall. It's a little too early to discuss either of these subjects, so let's just move along with you happily assigning your own IP addresses.
First, you can't use 127 as the first number. This is because the address 127.0.0.1 is reserved as a "loopback" address; an address that always refers to the machine at hand. In other words, every machine on your network can telnet to 127.0.0.1 and they will always end up at themselves, and not anywhere else. What's the point? Actually, it's useful. Consider the case of a client-server application where you want to run the client on the same machine as the server. Or consider a programmer who wants to test a network program, but doesn't want to go out on the real network just yet.
You also may have had support people ask you to "ping 127.0.0.1" to test your TCP/IP configuration. What's being tested there is strictly TCP/IP, with the network card not in the loop, and no interference or confusion from the rest of the network. It's strictly local, strictly a loopback. It needs to be there: don't ever delete this address from /etc/hosts.
The next addresses you shouldn't use are anything beginning with 224 or above. These are the Class D and Class E addresses (that's old terminolgy, but people still use it, so will I), reserved for special use. One use being made of them now is for Multicast addresses, where one computer sends data but many other computers receive it.
Just about anything else is available to you, following the rules that none of the four numbers can be 0 (really, some of them could be zero, but it's less confusing right now if we pretend that they cannot) and none of them can be 255. Keep in mind that the rules about 127 and 224 and up only apply to the first number of the four: you shouldn't use 225.10.1.8, but 10.225.1.8 is fine.
By the way, these four numbers are usually referred to as "octets", simply because they hold numbers that can be expressed in 8 bits. If it makes your head hurt to talk about bits, this might be a good time to bail out, because we're going to be getting into that pretty heavily from this point on. On the other hand, I'm going to try to make it painless, so you might consider hanging in there.
Don't panic, but we're going to talk bits!
An eight bit number can be anything from 0 to 255. This is because of the value of the bits. The 0 bit (computer geeks number things starting with 0, not to annoy you, but because it's easier when working with low-level computer registers) is worth 1 if set (and 0 if not), the 1 bit is worth 2 (again, if set, and zero if it isn't), the 2 bit is 4, and so on. Usually that's illustrated something like this: