Uccn1003 -may10_-_lect04a_-_intro_to_routing_rules


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Uccn1003 -may10_-_lect04a_-_intro_to_routing_rules

  1. 1. UCCN 1003 (May 2010)Data Communications & Networks (Lecture 04a) Introduction to IP Routing Rules
  2. 2. Overview of Routing
  3. 3. Introduction to Routing• Routing is the process of “traversing” or “directing” data from one IP interface on a network to another IP interface on another network.• Routing works with IP address – does NOT work with port number or MAC address• Routing needs two things: – Data containing IP address (especially destination IP) – Routing Table in Routers.• Routing has to function on scalable network. – Scalable means the network is constantly growing or contracting.
  4. 4. Visualization of Routing • Router direct the data to travel to the next router. • Packet travel from router to router forming a “route” visually. – For example, PC0 travels to PC12, traversing Router0, Router4 and Router6.
  5. 5. Routing Process in Router• A router must perform the following steps while making routing decision: – The router receive data (with IP address, both source IP and destination IP) from an interface. – The router then checks destination IP of the data to see if the destination network address exists in its routing table. • If Yes: From the routing table, the router determines which interface to use to forward the packet. • If no, the router will discard the packet and send an ICMP destination network unreachable message to the source of the packet. – The packet continues this process until it reaches its destination.
  6. 6. An example of Cisco Routing Table• Destination IP address of data will look at this routing table as a “road sign for direction”. OutboundDestination network Exit this gateway if data wants interface to go the destination network
  7. 7. Again, Steps of Routing in Router• Receive a IP packet from an interface/port – e.g. fa0/0, serial0/1, eth1/0• Analysis the IP packet (especially the destination IP) – Check for source, and destination addresses• Check the routing table – Compare the destination IP against the routing table – Find the matching destination network. – Get the gateway IP and output interface/port• Forward it to the interface of the exit gateway IP – Place it on the buffer of the output or outbound interface/port• Frame it and send to another gateway (or hop). – Send the data to the interface of another router, which has the gateway IP.
  8. 8. Comments on Forwarding• A router MUST have the capability to forward a packet.• Definition of Forwarding: – Placing a packet from a inbound interface to a outbound interface. Data being forwarded, Data comes will travel to the gateway in through (interface of another router) this port. Router “forwards” the data to the outbound port
  9. 9. Comments on Gateway IP• Gateway IP is a interface of “another” router.• A network can have more than 1 gateway.• A network must have at least 1 gateway to travel to other networks.• Default gateway is the last exit of a network if a packet has no where else to exit. Example: In order for Router0 to direct the data from to, the gateway IP is
  10. 10. Quick Quiz• Data from reaches Router3, what should be the gateway IP from Router3 if the data wants to travel to
  11. 11. Answer• Gateway = (to subnet – Always remember that gateway IP is an IP of another router, NOT your “starting router”. So don’t say is the gateway IP to in this question. – In this network, every router (other than Router1) will have the gateway IP =, if the router want to channel to data to
  12. 12. IP Routing Rule #1
  13. 13. IP Routing Rule #1• If there are 2 or more routers in a network, you need to configure routes in the routers. – You don’t need to set routes if there is only ONE router in the closed network.
  14. 14. Checking Routing Table in Cisco• The command to check routing table in cisco – #show ip route or #sh ip ro
  15. 15. IP Routing Rule #2
  16. 16. IP Routing Rule #2• Routes can be set using static routes or dynamic routes.• Static routes are set manually, by you.• Dynamic routes are set by software, routing protocol software.• Just like IP, you have static IP (set manually), or dynamic IP (set by software, DHCP service)
  17. 17. Setting Static Routes - 1 • To begin, every IP has been set correctly in the following network. • PC0 can ping – –
  18. 18. Setting Static Routes - 2 • However, PC0 can’t ping – – • Why?
  19. 19. Setting Static Routes - 3• The routing table of Router0 – Router0 only knows the two neighboring subnets that are connected to it. • and – Router0 does not know the existence of network – We need to set a route in Router0 to point to C = connected
  20. 20. Setting Static Routes - 4
  21. 21. Setting Static Routes - 5 Destination network gateway Router0#conf t Router0(config)#ip route Router0(config)#Syntax of static routeRouter(config)#ip route destination_network subnet_mask gateway_IP
  22. 22. Setting Static Routes - 6• After the “ip route” command, Router0 knows the existence of via gateway IP
  23. 23. Setting Static Routes - 7 • But wait….after setting static route on Router0, PC0 still can’t ping • Why? (Take note that ping is a to-and- fro travel.) • Question: Does Router1 know the existence of subnet
  24. 24. Setting Static Routes - 8• It appears that Router1 still doesn’t know the existence of – Check the routing table of Router1• If we only set a route in Router0, but not in Router1 – Data from only knows how to go to – Data does not know how to return to from
  25. 25. Setting Static Routes - 9 gateway Destination networkRouter1#conf tRouter1(config)#ip route
  26. 26. Setting Static Routes - 10• After the ip route command, Router1 knows the existence of via gateway IP
  27. 27. Setting Static Routes - 11 • Now, all the PCs don’t have problem pinging each other.
  28. 28. Setting Dynamic Routes - 1 • Same as the previous example, we begin with every IP has been set correctly in the network. But no routes have been set. • So, PC0 can’t ping – –
  29. 29. Setting Dynamic Routes - 2 • Setting dynamic routes with RIP (routing information protocol). Router1(config)#router rip Router1(config-router)#network Router1(config-router)#network Router1(config-router)#exit Router1(config)#Router0(config)#router ripRouter0(config-router)#network
  30. 30. Setting Dynamic Routes - 3 • Routing tables of two routes with dynamic routes. is subnetted, 1 subnetsC is directly connected, FastEthernet0/0C is directly connected, FastEthernet0/1R [120/1] via, 00:00:25, FastEthernet0/0 is subnetted, 1 subnets C is directly connected, FastEthernet0/0 R [120/1] via, 00:00:04, FastEthernet0/0 C is directly connected, FastEthernet0/1
  31. 31. IP Routing Rule #3
  32. 32. IP Routing Rule #3• In the routing table, the “connected” networks are shown when we configure the IP address for the router interfaces. There are supposedly 4 subnets connected to Router0. Why the routing table only shows 3 subnets? Router#show ip route … is subnetted, 1 subnets C is directly connected, FastEthernet0/1 C is directly connected, FastEthernet0/0 C is directly connected, FastEthernet1/1
  33. 33. Commands for the previous exampleRouter(config)#int fa0/0Router(config-if)#ip addr • Fa1/0 is NOT set withRouter(config-if)#no shut an IP, thus the routing table does not showRouter(config-if)#int fa0/1 the subnet attached toRouter(config-if)#ip addr it as “connected”Router(config-if)#no shut – Though the interface is turn “on” with “noRouter(config-if)#int fa1/0Router(config-if)#no shut shut”Router(config-if)#int fa1/1Router(config-if)#ip addr shutRouter#show ip int brInterface IP-Address OK? Method Status ProtocolFastEthernet0/0 YES manual up upFastEthernet0/1 YES manual up upFastEthernet1/0 unassigned YES unset up upFastEthernet1/1 YES manual up up
  34. 34. IP Routing rule #4
  35. 35. IP Routing Rule #4: Default Route• Default route is the gateway of last resort. If destination IP can’t find a matching destination network in the routing table, the data will go the way of default route• Default route is a special static route. – It is similar in concept to default gateway.• Command in Cisco router: Router(config)#ip route gateway_IP• The application of default routes is more “arts” than science. – Apply default route smartly, you can save a lot of work.
  36. 36. Example of Applying Default Route - 1• Question: – How do we set static routes in Router4 for this network? (What “ip routes” commands should we put)
  37. 37. Example of Applying Default Route - 2Router4(config)#ip route route route route route route Router4#show ip route ……… Gateway of last resort is not set is subnetted, 1 subnets S [1/0] via S [1/0] via S [1/0] via C is directly connected, FastEthernet0/0 S [1/0] via S [1/0] via S [1/0] via C is directly connected, FastEthernet0/1
  38. 38. Example of Applying Default Route - 3• In the network, we face problems with Internet, if we don’t have default route.• We need to program all the subnets in the world in the router.• However, if we use default route, the “ip route” commands in Router4 can be simplified to:Router4(config)#ip route route route route
  39. 39. Example of Applying Default Route - 4• All destination IP of subnet will go to gateway, except the following subnets: – 190.1.1.x – 193.200.30.x – 195.10.10.x Router4#show ip route ………… Gateway of last resort is to network All other is subnetted, 1 subnets destination IP S [1/0] via will go here. S [1/0] via S [1/0] via C is directly connected, FastEthernet0/0 C is directly connected, FastEthernet0/1 S* [1/0] via
  40. 40. Default route in Dynamic Routing - 1• Routing table of Router4, with dynamic routes by RIP. – No default route is present, so we can’t cater for the “rest” of the destination IP other than the ones shown in the routing table. Router4#show ip route …… Gateway of last resort is not set R [120/1] via, 00:00:13, FastEthernet0/0 R [120/1] via, 00:00:08, FastEthernet0/0 R [120/1] via, 00:00:14, FastEthernet0/0 C is directly connected, FastEthernet0/0 R [120/2] via, 00:00:06, FastEthernet0/0 R [120/2] via, 00:00:06, FastEthernet0/0 R [120/1] via, 00:00:06, FastEthernet0/0 C is directly connected, FastEthernet0/1
  41. 41. Default route in Dynamic Routing - 2• Adding in the default route will ensure all other destination IP to Internet to go to the gateway (in the case of Router4) Router4#show ip route ………. Gateway of last resort is to network R [120/1] via, 00:00:15, FastEthernet0/0 R [120/1] via, 00:00:00, FastEthernet0/0 R [120/1] via, 00:00:13, FastEthernet0/0 C is directly connected, FastEthernet0/0 R [120/2] via, 00:00:23, FastEthernet0/0 R [120/2] via, 00:00:23, FastEthernet0/0 R [120/1] via, 00:00:23, FastEthernet0/0 C is directly connected, FastEthernet0/1 S* [1/0] via
  42. 42. Quick Quiz: Stub Network• A stub network is a network (or part of an internetwork), with no knowledge of other networks, that will typically send much or all of its non-local traffic out via a single path.• Question: What should be our configuration for the interface Serial0/1/0 which hold a public IP and have a point-to-point connection with a TMnet router (the only way out to the Internet).
  43. 43. Answer Router(config)#int se0/1/0 Router(config-if)#ip addr Router(config-if)#exit Router(config)#ip route• Stub network edge router is best configured with a default route to the “outside world” since it only has 1 way in/out to the outside world.• Why the public IP = – Please figure this yourself.
  44. 44. Ring Network• Ring network can have routing set by setting default routes either in: – Counter-clockwise – Clock wise Counter-clockwise routes Router0(config)#ip route Router1(config)#ip route Router2(config)#ip route Router3(config)#ip route Router4(config)#ip route Router5(config)#ip route
  45. 45. IP Routing Rule #5
  46. 46. IP Routing Rule #5• Complex Network is best configured with dynamic routing. – Dynamic routing is a process in which the routing tables are populated by routing protocol (automatically done by software)• Typical dynamic routing configuration comes in two parts: – Selecting the routing protocol (there are a few popular routing protocols) • RIP (version 1 and 2) • EIGRP • OSPF – Advertising the networks attached to routers.• We need to provide a default route for dynamic routes too. – Set manually (have gone through this a few slides back) – By routing protocols (not taught in this class)
  47. 47. Advantage of Dynamic Routing• Advantages of dynamic routing: – A routing protocol will discover all the possible routes to one destination, implement its predefined rules, and come up with the best route to the destination. – When a portion of the route to the destination has been closed, the routing protocol will automatically find an alternate route to the destination. – Most important, it does not require “human” to key in all the routes, especially in the complex networks.
  48. 48. Problems with Static Routes• Complex networks includes many network elements especially routers (and a lot of subnets). – Hence, the network needs a lot of routes.• Static routes is they do not scale well (or linearly). For example: – A network with two routers would require two static routes. (To and fro) – A network with three routers would require six static routes.• A network with 100 routers would require 9,900 static routes.• The generic equation is the same one used to determine the number of full-mesh links in WAN networking: – n represents the total number of routers in the internetwork.
  49. 49. Advertising the Network• After selecting the routing protocol (e.g. RIP), the router needs to “advertise” all the subnets attached it.• For example, in the above networks:• Router3 has 4 subnets attached it – network, network, network, network• Router2 has 3 subnets attached it. – network, network, network• Router1 has 2 subnets attached it. – Network, network
  50. 50. IP Routing Rule #6
  51. 51. IP Routing Rule #6• If there is a new subnet in the network, all the routers need to have the routes that point to that subnets.• If a subnet is being taken out of the network, all the routers need to erase destination network in the routing table that points to that subnet.• If the network is not EXPLICITLY informed on the addition of subnets, there is no way the routers of the network will have routes pointing to the new subnet.
  52. 52. Example of IP Routing Rule #6• In dynamic routing if Router2 has not EXPLICITLY advertise the network of, Router1 will not no way to know the existence of the new subnet which is attached to Router2. Router1#show ip route … Gateway of last resort is not set C is directly connected, FastEthernet0/1 R [120/1] via, 00:00:07, FastEthernet0/0 C is directly connected, FastEthernet0/0
  53. 53. Example of IP Routing Rule #6 Router(config)#router rip Router(config-router)#network• Router2 just need to advertise (new subnets), since it has advertised the two older subnets to the network. Router1#show ip route … Gateway of last resort is not set C is directly connected, FastEthernet0/1new R [120/1] via, 00:00:07, FastEthernet0/0entry C is directly connected, FastEthernet0/0 R [120/1] via, 00:00:27, FastEthernet0/0
  54. 54. IP Routing Rule #7
  55. 55. IP Routing Rules #7• Router must have a routing table with entries made of unique destination network address. – Data must refer to routing table in order to know where to go.• A route: – is the “road” from source to destination• Routing table is: – A road map and the road direction board of the data. – The mechanism to guide data travel from 1 LAN to another LAN• Routing table should have: – The destination networks addresses – The destination network subnet mask – The next hop (or gateway) for a particular destination network. – The outbound interface for a particular destination network. – A network metric – Last resort gateway or default gateway
  56. 56. Cisco Routing Table Example Gateway IP (or Next Hop)Unique destination network
  57. 57. Cisco Routing Table Explained (Top half)• The Codes section at the very top tells you how the router get the route – There are few ways a route can be obtained • C = connected (you set it) • S = Static (you set it too) • R, I, D, O = (from routing software, you need to configure this too)• Note “the line Gateway of last resort is not set”. – The gateway of last resort, also known as a default route, is where your router will send IP packets if there isn’t a match in the routing table.• After that, are the “routing table entries”
  58. 58. Routing Table Entry Explained - 1• R – A code indicating how the route entry was learned on this router. In this case, the R stands for RIP (a form of dynamic routing).• – The network address and prefix length (number of bits set to 1 in the subnet mask) of the destination network.• [120 – The administrative distance of the route.• /1] – The metric of the route specific to the routing protocol used to determine the route. – RIP uses hops as its metric. In this example, there is one router between this router and the destination. – Different routing protocols have different set of metrics
  59. 59. Routing Table Entry Explained - 2• via – The next-hop address (gateway) for the route. – This is the IP address that the packet will exit from the LAN in order for the packet to reach its destination.• 00:00:18 – The length of time since the route has been updated in the routing table. In this example, the route was updated 18 seconds ago.• Serial0 – The interface the route was learned through. – This is also the interface the packet will be switched to in order for the packet to be forwarded toward its destination.
  60. 60. Windows XP Routing Table ExampleC:>route print===========================================================================Interface List0x1 ........................... MS TCP Loopback interface0x2 ...00 20 ed 78 85 31 ...... Realtek RTL8139 Family PCI Fast Ethernet NIC -Packet Scheduler Miniport======================================================================================================================================================Active Routes:Network Destination Netmask Gateway Interface Metric 30 1 30 30 30 30 30 1Default Gateway:
  61. 61. XP Routing Table Explained - 1• Windows XP routing table is displayed with the command “route print”• The Network Address and Netmask columns – show the values the are used to determine if the destination matches the routing table entry.• The Gateway Address and Interface columns – tell where the packet should be forward and then sent• Metric – shows how "expensive" it is to send the packet.
  62. 62. Windows XP Routing Table - 2===========================================================================Active Routes:Network Destination Netmask Gateway Interface Metric 30 1 30 30• The first line of this routing table is the default route.• The second line is the loopback route.• The third line defines the range of addresses on the local network segment. – This shows that any address in the Class C network should be found on the network segment connected to the interface with the address• The fourth line defines the destination addresses of a remote network that should not be sent to the default gateway. – This shows that any address in the Class C network should be sent to the gateway
  63. 63. Windows XP Routing Table - 3 30 30 30 1Default Gateway:• The fifth line is how a Microsoft routing table defines that is an address for the local host. – The netmask identifies that this route applies to only to packets addressed to the single address – The Gateway and Interface addresses pass all packets for this address to the local host.• The sixed entry lists the announce address for the local network. – This is another entry that is automatically added when an interface on a Windows TCP/IP system is assigned an IP address.• The seven line is the multi-cast address.• The eight line is the broadcast IP address used in protocols such as dhcp.
  64. 64. Linux Routing Table - 1Destination Gateway Genmask Flags Metric Ref Use Iface192.168.2.1 * UH 0 0 0 eth0192.168.1.2 * UH 0 0 0 eth1192.168.2.0 UG 0 0 0 eth0192.168.2.0 * U 0 0 0 eth0192.168.1.0 UG 0 0 0 eth1192.168.1.0 * U 0 0 0 eth1127.0.0.0 * U 0 0 0 lo0.0.0.0 UG 0 0 0 eth0• Displayed by commands either “route –e” or “netstat –nr”• Destination – The destination network or destination host.• Gateway – The gateway address or * if none set.• Genmask – The netmask for the destination net; for a host destination and for the default route.
  65. 65. Linux Routing Table - 2• Flags – U (route is up) – H (target is a host) – G (use gateway) – R (reinstate route for dynamic routing) – D (dynamically installed by daemon or redirect) – M (modified from routing daemon or redirect) – A (installed by addrconf) – C (cache entry) – ! (reject route)
  66. 66. Linux Routing Table - 3• Metrics – Same as Windows, indicating how “expensive” the route is.• Use – How many times that the routing entry has been used• IFace – The ethernet interface
  67. 67. Setting Static Routesin Windows XP and LinuxSome commands to set static routesin Windows XP, Linux, and Cisco
  68. 68. Adding Static Routes in Windows XP• Normally not necessary, since XP hosts reside in stub networks with 1 gateway.• Windows XP doesn’t have forwarding capabilities, hence it can’t be router.• Only required to “add” a static route where there are more than 1 gateways in the network with the Windows XP PC having 1 NIC.• If Windows XP has 2 NICs, it just indicates that it can access two networks.
  69. 69. XP Commands for Static Route> route ADD MASK METRIC 3 IF 2 destination^ ^mask ^gateway metric^ ^ Interface^> route CHANGE MASK METRIC 2 IF 2 CHANGE is used to modify gateway and/or metric only.> route PRINT> route DELETE• Adding static route in XP platform is more on exiting a particular gateway. – especially on a stub network that’s more than 1 gateway.
  70. 70. Static Route example in Linux• Access individual computer host specified via network interface card eth1: – route add -host eth1• Access ISP network identified by the network address and netmask using network interface card eth0: – route add -net netmask gw eth0• Conversely, meaning deleting a route: – route del -net netmask gw eth0• Specify default gateway to use to access remote network via network interface card eth0: – route add default gw eth0• Specify two gateways for two network destinations: (i.e. one external, one internal private network. Two routers/gateways will be specified.) – route add default gw eth0 – route add -net netmask gw eth0
  71. 71. Making a Linux PC Router• Steps on turning a Linux PC to a router: – Again, 2 NIC cards (at least) to turn a Linux PC into a router. – Enable the forwarding flag in the Linux • This is important… – Fill in the routing table • Using static route command – Routing software • You can use routing software instead of manually set the routes. • E.g. zebra, gated, etc…
  72. 72. Enable Forwarding• Remember to enable forwarding in the Linux routers. – This is not done automatically in Linux• Turn on IP forwarding to allow Linux computer to place a packet from 1 input to another output.• Command – echo 1 > /proc/sys/net/ipv4/ip_forward• You can check this forwarding flag with the following command. – # cat /proc/sys/net/ipv4/ip_forward