Configuration Guide
Basic Routing Configuration Guide
14 min
introduction introduction route is the most fundamental element in a data communication network routing information is the path information that guides the sending of packets, and the process of routing is the process of packet forwarding route table route table the rib (routing information base) is a centralized database of routing information, including routing table information and routing peripheral information (routing iteration information, routing sharing information and routing extension information) the router will send the preferred route to the fib (forwarding information base) table by optimizing the routing table and guiding the forwarding of packets through the fib table each forwarding entry in the fib table specifies the physical interface of the router through which a packet to reach a subnet or a host should be sent , so that it can reach the next router in the path or be delivered to the destination host in the directly connected network without going through another router route categories route categories the routing table holds the routes discovered by various routing protocols, and there are several common rules for dividing routes depending on the source, they are usually divided into the following three categories directly connected route routes discovered by link layer protocols, also known as interface routes static route routing configured manually by the network administrator, easy to configure, low system requirements, suitable for small networks with a simple and stable topology the disadvantage is that it does not automatically adapt to changes in the network topology and requires manual intervention dynamic route routes discovered by routing protocols has its own routing algorithm, can automatically adapt to changes in the network topology, and is suitable for networks with a certain number of layer 3 devices the disadvantage is that the configuration is more demanding on the user, the system requirements are higher than for static routes and will take up a certain amount of network and system resources depending on the destination of the route, the routes can be divided into segment route destination is a network segment with an ipv4 address subnet prefix length of less than 32 bits or an ipv6 address prefix length of less than 128 bits host route destination is a host with an ipv4 address subnet prefix length of 32 bits or an ipv6 address prefix length of 128 bits depending on whether the destination is directly connected to that router, the routes can be further divided into directly connected route the network where the destination is located is directly connected to the router indirect route the network where the destination is located is not directly connected to the router route management and configuration route management and configuration static route is a special type of route that requires manual configuration by an administrator compared to dynamic route, static route is simple to configure, highly controllable, use less bandwidth and do not use cpu resources to calculate and analyze route updates however, when the network fails or the topology changes, static route is not automatically updated and must be reconfigured manually therefore, static route is not suitable for large and complex network environments on the one hand, it is difficult for network administrators to gain a comprehensive understanding of the entire network topology; on the other hand, static route information in routers needs to be adjusted on a large scale when the network topology or link state changes, which is a very difficult and complex task static route has different purposes in different network environments when the network structure is relatively simple, only static route need to be configured for the network to work properly in complex network environments, configuring static route can improve the performance of the network and guarantee bandwidth for critical applications static route can be used in vrfs (vpn instances) and are mainly used for the management of vpn routes configuration parameters configuration parameters static route has five main parameters destination address and prefix, egress interface and next hop address, and priority destination address and prefix the ipv4 destination address is in dotted decimal format, and the prefix can be expressed either in dotted decimal or as a prefix length (i e the number of consecutive '1' bits in the prefix) when both the destination address and the prefix are zero, this indicates a static default route, as described in\[6 2 2 2] egress interface and next hop address when configuring static route, specify the egress interface and next hop address depending on the egress interface type for point to point type interfaces, only the egress interface needs to be specified since specifying the sending interface implicitly specifies the next hop address, the address of the peer interface connected to this interface is then considered to be the next hop address of the route for nbma (non broadcast multiple access) type interfaces (e g atm interfaces), configure the next hop ip address because these types of interfaces support point to multipoint networks, in addition to configuring static routes, a mapping of ip addresses to link layer addresses needs to be established at the link layer, in which case it is not necessary to specify the egress interface for broadcast type interfaces (e g ethernet interfaces) and vt (virtual template) interfaces, you must specify the next hop address for sending packets through the interface since ethernet interfaces are broadcast type interfaces and multiple virtual access interfaces can be associated under vt interfaces, this can result in multiple next hops and the next hop cannot be uniquely determined static route priority for different static routes, different priorities can be configured for them, with the smaller the priority number the higher the priority configuring multiple static routes to the same destination allows for load sharing if the same priority is specified, or route backup if different priorities are specified default route default route default route is a special type of route with an all 0 destination segment and an all 0 prefix simply put, the default route is a route that is used when no matching routing table entry is found in the routing table if the destination address of a packet does not match any destination address in the routing table, then the packet will be forwarded with the default route if there is no default route and the destination address of the packet is not in the routing table, then the packet is discarded and an icmp (internet control packet protocol) packet is returned to the source reporting that the destination address or network is unreachable configure ipv4 static route configure ipv4 static route pre requisites configure the link layer protocol and ip address of the interface so that the next hop is reachable table 1 configure static route table 1 configure static route purpose commands description enter global configuration view configure terminal (optional) enter vrf configuration view vrf vrf name add ipv4 static route ip route a b c d/m a b c d \[ description description ] \[ track track id ] \[ bfd ] \[ nexthop vrf vrf name ] a b c d/m destination ip address for routea b c d the ip address of the next hop for route display and maintenance display and maintenance table 2 route table display and maintenance table 2 route table display and maintenance purpose commands description show ipv4 routing table show ip route \[ summary | connected | static | bgp | ospf | isis | a b c d/m | a b c d ] summary displays a summary of the route connected displays directly connected routes static displays static routes bgp displays bgp routes ospf displays ospf routes isis displays isis routes a b c d/m specifies the ip prefix a b c d specifies network display ipv4 protocol information show ip protocol typical configuration example typical configuration example configure ipv4 static route configure ipv4 static route networking requirements hosts on different network segments are connected via three switches and require static routes to be configured so that any two hosts in the diagram can interoperate topology procedure \#configure the vlan to which each interface belongs and the ip address of the vlan interface \#configure device a as an example, device b and c are similarly configured sonic# configure terminal sonic(config)# vlan 10 sonic(config vlan 10)# ex sonic(config)# vlan 30 sonic(config vlan 30)# ex sonic(config)# interface ethernet 0/0 sonic(config if 0/0)# switchport trunk vlan 10 sonic(config if 0/0)# ex sonic(config)# interface ethernet 0/1 sonic(config if 0/1)# switchport trunk vlan 30 sonic(config if 0/1)# ex sonic(config)# interface vlan 10 sonic(config vlanif 10)# ip address 10 0 4 1/30 sonic(config vlanif 10)# ex sonic(config)# interface vlan 30 sonic(config vlanif 30)# ip address 10 0 1 1/24 sonic(config vlanif 30)# ex \#configure an ip default route at device a sonic(config)# ip route 0 0 0 0/0 10 0 4 2 \#configure two ip static routes at device b sonic(config)# ip route 10 0 1 0/24 10 0 4 1 sonic(config)# ip route 10 0 3 0/24 10 0 4 6 \#configure an ip default route at device c sonic(config)# ip route 0 0 0 0/0 10 0 4 5 host configuration \#configure the default gateway to 10 0 1 1 for host pc1, 10 0 2 1 for host pc2 and 10 0 3 1 for host pc3 check switch routing table show ip route each pc pings the other to verify connectivity
