0020_Cisco: Routing

Extract from lectures on routing CCNA level.

Dynamic Routing

#WILDCARD MASK
#EX1: 10.0.12.0/30, then do 32-30=2, count two bits (2+1=3)
#	The network mask will be: 255.255.255.(255-3=252)
#	The wildcard mask will be: 0.0.0.3

#EX2: 10.0.12.0/28, then do 32-28=4, count four bits (8+4+2+1=15)
#	The network mask will be: 255.255.255.(255-15=240)
#	The wildcard mask will be: 0.0.0.15

#Default route
#Network route
#HOST route
#Floating static

#adjacencies = neighbor relationships
#lower Metric = superior

#DYNAMIC ROUTING PROTOCOLS
#	IGP - Interior Gateway Protocol 
#		Works in a single AS
#			Distance Vector Protocol = ie RIP, EIGRP
#			Link State Protocol		 = ie OSPF, Is-Is

#	EGP - Exterior Gateway Protocol
#		Works between different AS
			Path vector Protocol	=ie BGP
###ECMP = Equal Cost Multi Path (balancing)####

#network	[XXX/Y]
#			  |  |
#			  |	 metric of the route 
#			  Administative Distance (AD)

#---------------------------------------------------------------------------------------|
#Route protocol 		|  AD	|				Metric based on #						|
#---------------------------------------------------------------------------------------|
#Directly connected		|	0	|	Total cost (1+1+.)									|
#---------------------------------------------------------------------------------------|
#Static					|	1	|	Always 0											|
#---------------------------------------------------------------------------------------|
#External BGP			|	20	|	Path attributes, ie AS_PATH							|
#---------------------------------------------------------------------------------------|
#EIGRP					|	90	|	Based on bandwidth, delay (and + 3 unused metrics)	|
#---------------------------------------------------------------------------------------|
#IGRP					|	100	|	Based on bandwidth, delay (and + 3 unused metrics)	|
#---------------------------------------------------------------------------------------|
#OSPF					|	110	|	Cost based on bandwidth								|
#---------------------------------------------------------------------------------------|
#IS-IS					|	115	|	Cost total metric each link							|
#---------------------------------------------------------------------------------------|
#RIP					|	120	|	Hop count											|
#---------------------------------------------------------------------------------------|
#EIGRP (external)		|	170	|	Based on bandwidth, delay (and + 3 unused metrics)
#---------------------------------------------------------------------------------------|
#Internal BGP			|	200	|	Path attributes, ie AS_PATH							|
#---------------------------------------------------------------------------------------|
#Unusable route			|	253	|														|
#---------------------------------------------------------------------------------------|

#RIP
#Max hop count = 15. One router = 1 hop.
#RIP v1, v2 used for IP v4, 
#RIP(ng) - next generation used for IP v6
#Two message types: REQUEST=RESPONSE / 30 seconds

#v1 - advertises classful addresses (Classs A,B,C)
#	- doesn`t support VLSM, CIDR
#	- doesn`t include subnet mask information
#	Ex: 10.1.1.0/24 -->10.0.0.0 Class A, so assumed to be /8
#	Ex: 172.16.192.0/18 will become 172.16.0.0, Class B, so assumed to be /16
#Messages are broadcast to 255.255.255.255

#v2 - supports CIDR, VLSM
#	- includes subnet mask information in advertisement
#	- messages are multicast 224.0.0.9

enable
	configure terminal
		router rip									#to activate RIP protocol
			version 2								#to set OSPF version
			no auto summary							#to disable auto summary (shows all route entries) 
			network 10.0.12.0						#to advertise all interfaces covered by 10.0.0.0/8
			passive interface <interface name>		#to deny get advertisements from other routers behind this interface
			default-information originate			#to share default route to other routers
			distance <0-255>						#to change the Administative Distance
			maximum-paths <1-16>					#route entries with equal AD will show in routes list (balancing)
			ip route 0.0.0.0 0.0.0.0 192.168.1.1	#to set default route
	show ip protocols
	

#EIGRP - Enhanced Interior Gateway Routing Protocol
#works faster  than RIP
#doesn`t have limit of hops
#by default EIGPR metric uses bandwidth + delay
#bandwidth ot the slowest link + the delay of all links
#sends messages using muticast address 224.0.0.10
#can performs unequal-cost load-balancing (by default ECMP load-balancing over 4 paths like RIP)

#[XXX/YYY]
#XXX = Feasible Distance - router`s metric value to the route`s destination. (full distance)
#YYY = Reported Distance from neighbor router to the last touter (aka Advertized Distance) 
#Successor - the router with the lowest metric ti the destination (the best route)
#Feasible Successor - an alternative route to the destination (not the best route) which meeets the feasiblity condition
#Feasibility condition - a route is considered a feasible successor it it`s reported distance  (RD or AD) is lower than the
#the successor route`s feasible distance (FD)

#Ex:   FD
#	[28672 / 28416 ]
#	[30976 / 28416 ]
#			RD / AD
		
#Balancing	/ variance <number>
#Ex for variance 2
#	[28672 / 28416 ] - FD=28672, 28672*2=57344 / if variance=3, then 28672*3 etc
#	[30976 / 28416 ] - compare 57344 with 30976, so 30976 is less than 57344, so the route via 30976 can now be used for LB	

#1. Write the ip address in binary format
#2. Write the network address in binary format
#3. Compare bitwise. If equal then 0, if not then 1
#Ex: Interface IP address 172.16.1.14, Advertisement network 172.16.1.0 - the IP interface address will be add to EIGPR
#						  172.16.1.15, Advertisement network 172.16.1.0 - the IP interface address will be add to EIGPR
#						  172.16.1.7,  Advertisement network 172.16.1.0 - the IP interface address will be NOT add to EIGPR
#
#
		route eigrp <number>						#to activate EIGRP protocol. Number must be the same on all routers
			no auto summary							#to disable auto summary (shows all route entries)
			network <network> <wildcard mask>		#to advertise the network
			network 10.0.0.0						#can be advertise this way too
			passive-interface						#to deny get advertisements from other routers behind this interface
			variance 2								#Feasible Successor routes with an FD up to 2x successor route`s FD	

	show ip eigrp topology							#to show everything about eigrp on the router
	show ip route eigrp								#to show only eigrp enteries on the route table 
	show ip protocols
	
#OSPF - Open Short Path First
#Stands for:
#v1 - not in use anymore
#v2 - used for IP v4
#v3 - used for IP v6
#LSA - Link State Advertisement
#LSDB - Link State Database
#Every router builds a map
#Routers will flood LSAs until all routers in the OSPF Area develop the same map of the network (LSDB)
#LSA`s age time is 30 minutes
#Backbone = Area 0
#OSPF areas should be contiguous 

#Router ID order of priority
#1-Manual Configuration
#2-Highest IP address on a loopback interface
#3-Highest IP address on a physical interface

#ASBR - Autonomous System Boundary Router (on the edge between AS) - goes outside ie Internet
#Max path by default is 4
#ABR - between Areas
#COST - default reference bandwidth is 100 mbit/s
#	reference cost for 10 mbit/s interface is: 100mbit/s:10mbit/s=10
#				   for 100 mbit/s interface is: 100mbit/s:100mbit/s=1
#					but!
#				   for 1000 mbit/s interface is: 100mbit/s:1000mbit/s=1 too, not good! Then do ...
#	auto-cost reference-bandwidth 100000	- it must be applied on all routers
#	reference cost for 10 mbit/s interface is: 100000mbit/s:10mbit/s=10000
#				   for 100 mbit/s interface is:100000mbit/s:100mbit/s=1000
#				   for 1 Gbit/s interface is: 100000mbit/s:1000mbit/s=100
#				   for 10Gbit/s interface is: 100000mbit/s:100000mbit/s=10
#					
		router ospf 1
			network <network> wildcard mask area <area number>	#add the network to the OSPF
			passive interface	<interface name>				#to deny get advertisements from other routers behind this interface
			default-information originate						#to share default route to other routers
			router-ID <ID>										#to set router ID
			maximum-paths <1-32>								#
			distance <number>									#to change distance
			auto-cost reference-bandwidth 100000				#must be applied on all routers
		ip route 0.0.0.0 0.0.0.0 <IP add>						#to set default route. The router becomes ASBR
		interface <interface>
			ip ospf cost <1-65535>								#to set cost manually on the interface
			bandwidth <kbit/s>									#to set bandwidth on the interface
	show ip protocols
	clear ip ospf proccess										#ie restart OSPF proccess
	show ip ospf interface brief								#
	show ip ospf neighbor										#
	show ip ospf interface <interface>							# 
	show ip ospf database
	
#There is another way to change cost. Use Bandwidth on the interface. This bandwidth is not the same as D-Link.
#Cisco uses bandwidth to set counting for OSPF cost, EIGPR metric etc
 	
#OSPF Neighbors
#Hello timers by default is 10 seconds, sends by routers to 224.0.0.5 - Multicast IP Addr for OSPF routers
#Dead Timer by default is 40 seconds and its counts down. Then 0 and no Hello packets, the neighbor will removed
#Dead Timer by default For Non Broadcast network is 120 seconds, Hello - 30 seconds
#IP header in the protocol`s header is 89

#Stages of the port on the router. There are 7 stages
# Down
# Init - sends the Hello packet
# 2-way - it means that router recieved the Hello packet from other router. Now they know each other
#===now routers become to DR (Designated Router) or BDR (Backup Designated Router)
# Exstart - the router with higher RID become Master and initiate the exchange
#		  - the router with the lower RID will become Slave
#		  - they will exchange DBD (Database Description) packets
# Exchange - compare its DBD and request only new LSA, than it hasn`t
# Loadind - loading proccess
#	=loading states=
#	LSR - Link State Request
#	LSU - Link State Update
#	LSAck - Link State Acknoledge
#	Share LSAs to synchronize LSDB
# Full - All done.

#The other way to add the interface to the OSPF proccess
		interface <interface>
			ip ospf <proccess number> area <aren number>
			
#It is possible to make all interfaces passive and then add the interface manually
		router ospf <ospf number>
			passive-interface default
			no passive-interface <interface>
			
#OSPF Network Types
# Broadcast 		- Ethernet and FDDI (DR+BDR)
# Point to Point 	- PPP and HDLC (no DR and no BDR) 
# Non-Broadcast		- Frame Relay and X.25

#DR and BDR must be elected on each subnet (Only DR if there is no OSPF neighbors)
#Routers are not the DR or BDR become a DROther


#DR and BDR election ordered of priority
# Highest OSPF interface priority (by default they are the same = 1)
# Highest OSPF Router ID/ First place becomes DR for the subnet, second place becomes BDR
# If OSPF interface priority set to 0, then it will not become DR or BDR for the interface subnet
# If OSPF interface priority set to 255 it makes this router DR
# To apply changes use command clear ip ospf proccess
# Each router can exchange LSA only with DR or BDR. DRother routers don`t exchange LSA at all.

#PPP Network Type
#The default encapsulation is HDLC
		int S1 	#Serial
			encapsulation ppp
			clock rate <bits per second>
	show controllers <interface ID>

#To change P2P to Broadcast
		interface <interface>
			no ip ospf network point-to-point

#OSPF Neighbor Requirements
# 1.Area number must match
# 2.Interfaces must be in the same subnet
# 3.OSPF proccess must not be shutdown
# 4.OSPF routers ID must be unique
# 5.Hello and Dead timers must match (no ip ospf hello-interval , no ip ospf dead-interval)
# 6.Authentication settings must match (to enable use ip ospf authentication)
# 7.IP MTU settings must match. If not you can`t reach Full State. (ip mtu <bits>)
# 8. OSPF network type must match. (You can see Full State, check the routing table)

#LSA TYPES
#The OSPF LSDB is mase up of LSAs. There are 11 types of LSA, but only 3 should be aware of the CCNA
# Type 1 - Router LSA
# Type 2 - Network LSA
# Type 5 - AS External LSA

#Type 1
#Every OSPF router generates this type of LSA
#It identifies the router using its router-ID
#It also lists networks attached ti the router`s OSPF activated interfaces

#Type 2
#Generated by the DR of each "multi-access" network (ie the broadcast network type)
#List all routers which are attached to the "multi-access" network

#Type 5
#Generated by ASBR to describe routes to destination outside the AS (OSPF Domain)