Routing (Networks and Netmasks) ----------------------------------------------------------------------------- Reserved Private Network Allocations (RFC1597): Class Netmask Address - Range - CIDR A 255.0.0.0 10.0.0.0 - 10.255.255.255 - "/8" B 255.255.0.0 172.16.0.0 - 172.31.255.255 - "/16" C 255.255.255.0 192.168.0.0 - 192.168.254.255 - "/24" ----------------------------------------------------------------------------- A network address is the lowest number of the network segment or subnet. The network address of a subnet is reserved and cannot be used by any node on the network. To spefify a network address, you must also include a netmask. Network Address: 192.168.1.0 The broadcast address is the subnet's highest range. It is reserved an cannot be used by any node on a network. Broadcast Address: 192.168.1.255 ----------------------------------------------------------------------------- If a computer is connected to two seperate networks, it must either have two seperate ethernet cards or have a router on the network do all the routing. Network A - 192.168.1.0 - netmask 255.255.255.0 Network B - 192.168.2.0 - netmask 255.255.255.0 The netmask specifies that the numbers relating to network A as a whole are 192.168.1 all numbers following the next period "." are node addresses. The node address range is 1-254. The reason it is not 0-255 is because 0 and 255 are reserved for the network and broadcast addresses. A gateway or default gateway is setup in the routing table to handle all addresses that do not fall under the addresses setup in the routing table. A gateway is most always a router, whether it is another computer's routing table, or a physical router device. The router is setup to understand what to do with the information addressed to a location that a computer cannot deliver itself. When a PPP connection is established, there are two IP addresses involved, the IP address assigned to the computer and the IP address assigned to the remote end of the connection. The remote IP address is a router that will route the data to its proper location. When a PPP connection is established, the remote IP address is setup as the default gateway. If a computer with a PPP connection cannot find the address in it's own routing table, it will default to the gateway, which should know how to route the data. ----------------------------------------------------------------------------- Imagine you have 3 floors in a building. Each floor has it's own network with computers attached. We will call the networks HIGH, MIDDLE, and LOW. This could be synonymous with 3 corporate departments such as accounting, research, and marketing. You have a computer that is connected to each network with 3 seperate physical wires and NICs. The LOW network is 192.168.1.0, the MIDDLE network is 192.168.2.0, and the HIGH network is 192.168.3.0; each network has a netmask of 255.255.255.0. Each NIC has a physical wire coming into it at the back of the computer which all come from a hub on each network. The internal routing table has an network address assigned to each NIC according to the network in which the NIC is connected. When your computer request data from a machine at 192.168.1.12, it looks at its internal routing table to see which NIC it should send the data through. In this example, the routing table would route it to the LOW NIC. The LOW NIC, which is actually connected to the 192.168.1.0 network via a physical wire, would then request the data and all nodes on the LOW network would "hear" the request, only the machine at 192.168.1.12 would answer. It would then send the data on the 192.168.1.0 network and all other nodes on the LOW network would "hear" the reply, but only your network card would answer because the information in the request would be addressed to your network card, and thus your computer since the card is attached to it. If, you are also dialed into the internet, the remote end of the PPP connection would be your default gateway. If you requested data from a machine at 206.124.64.253, since you do not have any NICs assigned to the network address 206.124.64.0, the routing table will send the data to the default gateway, which is the modem and remote end of the PPP connection. The remote end of the PPP connection (the ISP) will then route the data to it's intended address. The ISP will most likely route the data to another router unless the address is inside their network. ----------------------------------------------------------------------------- To see the routing table on a Windows machine, from an MS-DOS prompt, type "route print". On a Linux machine, type "route". On a BSD machine, type "netstat -rn" ----------------------------------------------------------------------------- Subnets, Routers, Hubs, and Switches When a computer request information from a network which it is connected to, it will send the request along the wire which is most likely connected to a hub, the hub will then send the information along every wire it is connected to (which usually links the entire network). All nodes on the network will hear the request but only the intended recipient (NIC or device) will listen to the data and return a request. All other nodes on the network ignore the data. Since many computers on a network may be using network resources, the entire network will be full of data that is only intended for one node. With all of this data flowing around every wire on the network, the network speed will tend to slow because only one data packet can be transmitted at any time. By creating subnets (smaller networks), the data flowing around the networks can be reduced. This is especially true if computers on the smaller subnets are using resources from other nodes on the same subnet. To interconnect smaller networks together so that a computer can request resources from other nodes on other networks, the networks must be brought together with routers. Routers are setup as the default gateway, therefore, when your computer knows that the resouce is not located on its own network (by examining the routing table), it will default to its default gateway which will be setup as the router. The router will know how to get the data to the proper network (by examining it's own routing table). The other network could either be another subnet inside the building or an unknown network, in which case, the router will default to it's default gateway which will most likely be the internet. The router itself may be setup with a default gateway which is somewhere on another subnet or, it may be setup to connect to the internet itself (usually a dial on demand ISDN connection). The above scenario explains how subnets can reduce the amount of data being send over a large network by dividing it into subnets which may not need to cross over to other sides of the network. Image a network with 300 workstations all requesting data at the same time. 100 computers are located in the accounting division, 100 computers located in the research division, and 100 computers in the marketing division. Each division of workstations are using data on servers setup primarily for their department. If 3 subnets were created by moving each server to it's department and corresponding subnet, at most any given time, only 100 computers would be requesting data on any given network, as compared to 300. If a workstation needed information from another server, which was not on it's subnet, it would not find an entry in it's routing table and would therefore have to send the data to the gateway, which would be router which interconnects all 3 networks. The router would then route the data over to the other network and return the data in the same path. At that given moment, 101 workstations may be using that specific subnet, which is better than 300. Remember, only one packet of data can be traveling over the wires at any given moment. There are times where two machines or multiple machines may try to send data over a network. When this happens, an event known as a "data collision" occurs and the data must be resent. This actually occurs all the time but the devices re-transmit the failed attempt so fast that unless there is a large amount of data collision (a packet storm), it is not noticable. All of the above scenario was a description of a network interconnected with a device known as a hub. There exist an alternative to the hub, it is called a switch. A switch is another answer to the above scenario. A hub is similar to splicing wires together to form a single circuit. All data hitting a hub is transmitted to all wires plugged into it, which leads to other hubs which lead to other hubs and so forth, forming a web of wires all interconnected. A switch in contrast to a hub, is intelligent (so to speak) in that it knows where each wire goes. It examines all packets flowing through the wires and only transmits data down the wire that leads to the destination of the packet, thus alleving all other circuits of data that does not need to traverse them. ----------------------------------------------------------------------------- route add -net 192.168.1.0 netmask 255.255.255.0 eth0 route add -net 192.168.2.0 netmask 255.255.255.0 eth1 route add -net 192.168.3.0 netmask 255.255.255.0 eth2