Static routing principle and configuration

1. Static routing

Static routing is a fixed routing manually configured by the user administrator in the router. Because it is manually configured, when the topology of the network or the state of the link changes, we need to manually modify the relevant information in the routing table.

1.1 Features of static routing:

( 1) The static route fixes the forwarding of the path, so the routing selection of the router is controlled, which saves network bandwidth and reduces additional expenses ; (3) Static routing is inflexible, and manual configuration modification is required when network transmission changes.

1.2 Common commands for configuring static routing

Configure the routing interface IP and mask: ip address IP address subnet mask
such as: ip address 192.168.1.1 255.255.255.0

静态路由切记:有来有回
 静态路由语法规则:明细:
ip route + 目的网络地址 +目的网络地址对应子网掩码 
+ 本地出接口/下一跳转发设备的IP地址 +{
    
    +管理距离}
ip route       192.168.20.0     255.255.255.0  12.1.1.2
              -------------  ---------------  --------
                目的网络地址      对应掩码   下一跳(与出接口直接相连的接口地址)
路由表:
 S     192.168.20.0/24   [1/0] via     12.1.1.2
 --         ------------------   ---------          --------
静态     目的网络地址       管理距离         下一跳

1.3 Advantages

Another advantage of using static routing is that the network security is highly confidential . Dynamic routing requires routers to exchange their routing tables frequently , and the analysis of routing tables can reveal information such as network topology and network addresses. Therefore, the network can also use static routing for security reasons. Does not consume network bandwidth because static routes do not generate update traffic.

1.4 Disadvantages

Static routing is generally not suitable for large and complex network environments . On the one hand, it is difficult for network administrators to fully understand the topology of the entire network; on the other hand, when the topology and link status of the network change, the static routing information in the router needs to be adjusted on a large scale. and a very high level of complexity . When the network changes or the network fails, the route cannot be reselected, which may cause the route to fail.

1.5 Direct routing

The router interface configures the address and opens the port to form a direct route with the directly connected network segment.

(As shown in the figure below) The router is directly connected to the 1.0 and 2.0 network segments to form a direct route. At this time, there are two direct routes in the routing table of R6.
insert image description here

1.6 Indirect Routing

For R6, the network segments that can be directly connected are 1.0 and 2.0, but the 3.0 network segment is separated by a router, so it is not directly connected to other network segments that are not directly connected to the router for R6. It needs to be configured statically or dynamically. Obtain.
insert image description here

  • Router(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2

2 Experimental topology

insert image description here

2.1 Related equipment

Terminal equipment:
PC0: 192.168.10.0/24
PC1: 192.168.40.0/24
Router: R2/R3/R4
Technology involved:
static routing

2.2 Experiment ideas:

2. Configure IPs of different network segments for each interface of the router, and static routing configuration
3. Test and verify to achieve intercommunication

2.3 Experimental steps

1. Configure PC IP address
2. Configure each router port IP address
3. Add static route

2.3.1 Configure pc ip address and gateway

PC1
insert image description here
PC2
insert image description here

2.3.2 Router configuration

R2

R2
Router>en
Router#conf t   //进入全局配置模式
Router(config)#int f0/0  // 进入f0/0端口
Router(config-if)#ip add 192.168.10.254 255.255.255.0 //(为其接口配置IP地址及子网掩码)
Router(config-if)#no sh  //(开启该端口)
Router(config-if)#int f0/1
Router(config-if)#ip add 192.168.20.1 255.255.255.0
Router(config-if)#no sh

insert image description here
R3

Router>en
Router#conf t
Router(config)#int f0/0 //进入f0/0端口
Router(config-if)#ip add 192.168.20.1 255.255.255.0 // 配置IP地址
Router(config-if)#no sh  //激活端口
Router(config-if)#int f0/1
Router(config-if)#ip add 192.168.30.1 255.255.255.0
Router(config-if)#no sh

insert image description here
R4

R4
Router>en
Router#conf t
Router(config)#int f0/0
Router(config-if)#ip add 192.168.30.2 255.255.255.0
Router(config-if)#no sh
Router(config-if)#int f0/1
Router(config-if)#ip add 192.168.40.254 255.255.255.0
Router(config-if)#no sh

insert image description here

2.3.3 Static routing part

R2

Idea: Because R2 already has directly connected network segments of 192.168.10.0 and 192.168.20.0, it is necessary to manually add the static network segments reaching 30.0 and 40.0

Router(config)#ip route 192.168.30.0 255.255.255.0 192.168.20.2    // 配置前往30.0网段的静态路由
Router(config)#ip route 192.168.40.0 255.255.255.0 192.168.30.2    // 配置前往40.0网段的静态路由

R3

Idea: Because static routes are unidirectional, R3 also needs to configure static routes to 10.0 and 40.0

Router(config)#ip route 192.168.10.0 255.255.255.0 192.168.20.1  配置前往10.0网段的静态路由
Router(config)#ip route 192.168.40.0 255.255.255.0 192.168.30.2 配置前往20.0网段的静态路由

R4
idea:
Because the routing table of R4 already has network segments 30.0 and 40.0, it is necessary to manually add static routes to 20.0 and 10.0

Router(config)#ip route 192.168.20.0 255.255.255.0 192.168.30.1
Router(config)#ip route 192.168.10.0 255.255.255.0 192.168.20.1

Test Results

insert image description here
insert image description here

Note: If the ping is successful, it means that the two PCs are successfully connected. If the ping is not successful, it may be because the router responds slowly. Wait a while and try again. If it still fails, please check whether the command line IP address is entered correctly and whether the port is set correctly.

Guess you like

Origin blog.csdn.net/2201_75288693/article/details/129343247