Cisco device static routing configuration

1. Basic knowledge of static routing

The main function of a router is to forward IP data packets so that the data packets reach the correct destination host. It can be imagined that a data packet arriving at a router is like a car driving to a crossroad, and the routing table is like a road sign, listing possible destinations and which road should be chosen to reach the destination.

A router must have a corresponding IP route in order to send or route packets. IP routing refers to the method or process of selecting one or several optimal paths from a source address to a destination address in an IP network, and sometimes refers to the path itself. IP routing configuration is to perform certain operations on the router so that it can complete the work of selecting paths in the network.

There are three ways to configure routing, namely static routing configuration, dynamic routing configuration and default routing configuration.

Simply put, a static route is a route added to a router with configuration commands. Specifically, the information including the destination subnet number, subnet mask, output interface or next-hop router is added to the IP routing table as a new item. After adding, the router can route the data packets whose destination address matches this static route.

By configuring static routing, network engineers can artificially specify the path to be passed when accessing a certain network. Under normal circumstances, static routes are not configured for all routers in the network, however static routes are useful in certain situations, such as:

  • The network is small and changes little or has no redundant links.

  • An enterprise network has many small branches and only one path to the rest of the network.

  • Businesses want to send packets to hosts on the Internet, not hosts on the corporate network.

The router broadcasts and receives routing information on the Internet according to the specified routing protocol, and dynamically updates and determines the routing table entries through the routing information exchanged between routers. This method of obtaining the target path is called dynamic routing.

To further simplify the routing table, or when the destination network address is unknown, a default route can be configured. Configuring a default route on a router is to inform the data packets arriving on the router where the next destination should go. The default route is also a special kind of static route because it must be configured manually.

2. Static routing configuration common commands

1. Set static routing

ip route <目的子网地址><子网掩码><相邻路由器相邻接口或本地物理接口>

For example: command Router2 (config) #ip route 192.168.2.0 255.255.255.0 192.168.0.18, that is to configure a static route for the router.

2. Set the default route

ip route 你要到达的相邻网络号区域 子网掩码 要经过的最近IP地址  [Distance metric]

By default, the value of Distance metric is 0. The larger the value, the lower the priority of this route. 0.0.0.0 means any address.

3. Display IP routing table

show ip route

Router IP address configuration code

//进入配置模式
Router>
Router>enable
Router>configure terminal //可以简写成conf t
Router(config)#
#端口ip配置
Router(config)#interface 接口
Router(config)#ip address IP地址

3. Topology

4. Related parameters

router

subnet mask

IP address

Router0

255.255.255.0

Gig0/0:192.168.10.1

Gig0/1:192.168.20.1

Router1

255.255.255.0

Gig0/0:192.168.20.2

Gig0/0:192.168.30.1

Router2

255.255.255.0

Gig0/0:192.168.30.2

Gig0/0:192.168.40.1

the host

IP address

gateway

PC0

192.168.10.10

192.168.10.1

PC1

192.168.40.10

192.168.40.1

5. Static routing configuration

1. Router configuration

Graphical input (to give an example, not to configure one by one)
characterize input

R0

Router>enable
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#int g0/0
Router(config)#ip add 192.168.10.1 255.255.255.0
Router(config)#no sh
Router(config)#int g0/1
Router(config)#ip add 192.168.20.1 255.255.255.0
Router(config)#no sh
Router(config)#exit

R1

Router>enable
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#int g0/0
Router(config)#ip add 192.168.20.2 255.255.255.0
Router(config)#no sh
Router(config)#int g0/1
Router(config)#ip add 192.168.30.1 255.255.255.0
Router(config)#no sh
Router(config)#exit

R2

Router>enable
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#int g0/0
Router(config)#ip add 192.168.30.2 255.255.255.0
Router(config)#no sh
Router(config)#int g0/1
Router(config)#ip add 192.168.40.1 255.255.255.0
Router(config)#no sh
Router(config)#exit

2. Host settings

The configuration of the host here is the same, so take PC1 as an example

3. Forwarding routing settings

The configuration of forwarding routing and IP address can be combined together

R0:

Router>enable
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#ip route 192.168.40.0 255.255.255.0 192.168.20.2
Router(config)#end
Router#

R1:

Router>enable
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#ip route 192.168.10.0 255.255.255.0 192.168.20.1
Router(config)#ip route 192.168.40.0 255.255.255.0 192.168.30.2
Router(config)#end
Router#

R3:

Router>enable
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#ip route 192.168.10.0 255.255.255.0 192.168.30.1
Router(config)#end
Router#

6. Connection

Use the ping command to test connectivity

If it is found that the ping fails, there are generally two situations

1. IP address configuration error solution: reconfigure

1. IP route configuration error solution: use no ip route to delete.

If it still doesn’t work, you can ping the address one by one, start from the nearest IP address, and ping to the end point one by one; find out the wrong node and then conduct further inspection

Summarize

The focus of this article is to master the three elements of static routing, that is, the destination address to be reached; the IP address of the next hop, that is, the address of the adjacent interface of the adjacent router, or the name of the interface that the router connects to the next hop of the adjacent router ;Administrative distance, default value is 1.

Guess you like

Origin blog.csdn.net/qq_55869380/article/details/128540946