laitimes

Practical sharing: Advanced configuration of Cisco routers helps enterprise networks run efficiently

Hello everyone, this is G-LAB IT. Today, I will lead you to learn the advanced configuration of Cisco routers, you can like and collect!

  • Basic routing configuration
  • Configure static routes
  • RIP dynamic routing
  • OSPF Dynamic Routing
  • Practice: Configure a RIP enterprise environment

Router (Router), is connected to the Internet in the local area network, wide area network equipment, it will automatically select and set the route according to the situation of the channel, with the best path, in order to send signals, the router works in the network layer, used to communicate across network segments, the router has the function of judging the network address and selecting the IP path, it can establish a flexible connection in the multi-network interconnection environment, and can connect various subnets with completely different data grouping and media access methods, The router only accepts the information of the origin server or other routers, and is an interconnection device at the network layer, so the router is one of the indispensable network devices in the Internet.

Router, its most important function is routing, routing refers to the router receives the data when choosing the best path to transmit the data through the network to the destination address behavior, each router is responsible for its own local data routing or forwarding, through a plurality of routers in turn relay the data will finally be delivered to the target host, the routing workflow includes routing selection and routing forwarding two aspects.

Basic routing configuration

The router is different from the switch, the switch does not need to be configured to work normally, but the router must be configured before it can be used normally, the login mode of the router is basically the same as the switch, the following will use an instance to implement the basic configuration of the router, including configuring the hostname, password, console port, WAN interface and LAN interface of the router, etc., to achieve a basic routing structure.

First of all, we prepare two routers (1841 model), it should be noted that the type of line selected for the connection between the devices, generally the router and the PC use a crossover line, and the two routers are connected to use a serial line, which can be configured into the following topology:

Practical sharing: Advanced configuration of Cisco routers helps enterprise networks run efficiently

But when actually connecting the two routers, we found that there is no Serial interface, this is because the router of this model does not provide a serial port by default, we can select the WIC-2T module on the Cisco emulator and drag it into the empty slot, restart the switch to complete the configuration.

Practical sharing: Advanced configuration of Cisco routers helps enterprise networks run efficiently

Next, let's take a look at the specific configuration parameters of each device in the network topology, including type, IP address, default gateway and other information.

[设备名称]   [设备接口]         [IP地址]           [默认网关]

   PC1         ---          192.168.1.2/24      192.168.1.1

   PC2         ---          192.168.2.2/24      192.168.2.1




 Router0      Fa0/0         192.168.1.1/24         ---

              Serial0/0/0   10.10.10.10/24         ---




 Router1      Fa0/0         192.168.2.1/24         ---

              Serial0/0/0   10.10.10.20/24         ---

           

Enable Routing Remote Login: Here we will enable the remote login function of the Router1 router and set a login password to lyshark.

Router# enable

Router# configure terminal




Router(config)# hostname Router0             // 配置主机名为Router0

Router0(config)# enable secret lyshark       // 配置特权模式密码为lyshark




Router0(config)# line console 0              // 启用控制台

Router0(config-line)# password lyshark       // 设置控制台登录密码

Router0(config-line)# login                  // 允许用户登录

Router0(config-line)# exit




Router0(config)# line vty 0 2                // 配置序号为0-2的3个虚拟登陆终端

Router0(config-line)# password lyshark       // 配置终端登录密码

Router0(config-line)# login                  // 启用登陆终端

           

Configure WAN interface: The router connects to the Internet through the WAN interface, and the common WAN interface is represented by Serial, first you can use the show controller command to determine whether Serial0/0/0 is the DCE side, and then decide whether to configure it.

Router0> show controller Serial0/0/0




Interface Serial0/0/0

Hardware is PowerQUICC MPC860

DCE V.35, clock rate 2000000       // 此处判断是DEC端

           

According to the above annotations, Srial0/0/0 is a DCE port, and the clock frequency needs to be configured for the two routers respectively.

#----在Router0上操作-------------------------

Router0> enable

Router0# configure terminal

Router0(config)# interface Serial0/0/0                    // 选择串行接口Srial0/0/0

Router0(config-if)# ip address 10.10.10.10 255.255.255.0  // 配置外网IP地址

Router0(config-if)# clock rate 64000                      // 配置始终频率为6400

Router0(config-if)# no shutdown                           // 开启端口




#----在Router1上操作-------------------------

Router1> enable

Router1# configure terminal

Router1(config)# interface Serial0/0/0

Router1(config-if)# ip address 10.10.10.20 255.255.255.0

Router1(config-if)# clock rate 64000

Router1(config-if)# no shutdown

           

Configure LAN interface: The LAN interface is used to specify the address of the internal network communication, and then configure the two routers separately.

#----在Router0上操作-------------------------

Router0> enable

Router0# configure terminal

Router0(config)# interface fa0/0                        // 选择以太网接口fa0/0

Router0(config)# ip address 192.168.1.1 255.255.255.0

Router0(config)# no shutdown




#----在Router1上操作-------------------------

Router1> enable

Router1# configure terminal

Router1(config)# interface fa0/0

Router1(config)# ip address 192.168.2.1 255.255.255.0

Router1(config)# no shutdown

           

Check the configuration information: Finally, you can use the show ip route command to check the router's routing information and determine whether the network is connected correctly.

Router0# show ip route

Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP

       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

       * - candidate default, U - per-user static route, o - ODR

       P - periodic downloaded static route




Gateway of last resort is not set




     10.0.0.0/24 is subnetted, 1 subnets

C    10.10.10.0 is directly connected, Serial0/0/0            // 外网地址

C    192.168.1.0/24 is directly connected, FastEthernet0/0    // 内网地址

           

Check the interface information: You can also use the show ip interface brief command to view the interface information of the router.

Router0# show ip interface brief




Interface              IP-Address      OK? Method Status                Protocol 

FastEthernet0/0        192.168.1.1     YES manual up                    up

Serial0/0/0            10.10.10.10     YES manual up                    up

Serial0/0/1            unassigned      YES unset  administratively down down

Vlan1                  unassigned      YES unset  administratively down down

           

Finally, the communication is tested: Route1 can be pinged on Router Route0, and each host can also ping the router on its own network segment.

Router0# ping 10.10.10.20




Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 10.10.10.20, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/6 ms

           

The above small experiment is successfully configured here, but there is a question left here, that is, PC0PingPC1 cannot communicate, which involves the problem that the router does not have the corresponding route entry, and these problems will be explained in the later small experiment.

Configure static routes

Static routes need to be manually configured by the administrator according to the actual needs, the router will not automatically generate the required static routes, the static routes include the IP address of the destination node or the target network, and can also include the next hop IP address, as well as the packet outbound interface when the static route is used on the router, etc., but the manual configuration of static routes requires the administrator to understand the topology of the network very well to complete the configuration, and it also takes a lot of experience and time to maintain when the network is large. Therefore, not all networks are suitable for static routing.

In general, static routes can be used in the following situations:

1. The topology of the network is relatively simple, for example, in the case of a router and switch, static routes can be used.

2. The network confidentiality requirements are high, and the network administrator needs to control the link or control the routing table, then the static route can be used.

3. The network only connects to the Internet through a single ISP, then the ISP is the only exit of the network, so there is no need to configure static routes.

4. The routing resources are limited and the routing protocol cannot be run, in this case, the route entries need to be manually configured to update the routing table data.

Next, an example is used to introduce the configuration process of static routes, select two 1841 routers in the Cisco simulator, build a network according to the following network topology, and then configure static routes for each router to achieve data exchange between different networks.

Practical sharing: Advanced configuration of Cisco routers helps enterprise networks run efficiently

Configure the client host: First of all, we configure the IP address, gateway and other data according to the configuration requirements in the above figure, and the following parameters are the specific address planning.

[设备名称]   [设备接口]         [IP地址]           [默认网关]

   PC0         ---          192.168.1.2/24      192.168.1.1

   PC1         ---          192.168.1.3/24      192.168.1.1




   PC2         ---          192.168.2.2/24      192.168.2.1

   PC3         ---          192.168.2.3/24      192.168.2.1




 Router0      Fa0/0         192.168.1.1/24         ---

              Serial0/0/0   10.10.10.10/24         ---




 Router1      Fa0/0         192.168.2.1/24         ---

              Serial0/0/0   10.10.10.20/24         ---

           

Configure the router: Then we configure the address parameters for the router respectively, here the fa0/0 port is the private IP address, and the serial0/0/0 port is the external IP address.

#----在Router0上操作-------------------------

Router0> enable

Router0# configure terminal




Router0(config)# interface fa0/0                          // 配置内网地址

Router0(config-if)# ip address 192.168.1.1 255.255.255.0

Router0(config-if)# no shutdown




Router0(config)# interface serial0/0/0                    // 配置外网地址

Router0(config-if)# clock rate 64000

Router0(config-if)# ip address 10.10.10.10 255.255.255.0

Router0(config-if)# no shutdown




#----在Router1上操作-------------------------

Router0> enable

Router0# configure terminal




Router1(config)# interface fa0/0                          // 配置内网地址

Router1(config-if)# ip address 192.168.2.1 255.255.255.0

Router1(config-if)# no shutdown




Router1(config)# interface serial0/0/0                    // 配置外网地址

Router1(config-if)# clock rate 64000

Router1(config-if)# ip address 10.10.10.20 255.255.255.0

Router1(config-if)# no shutdown

           

Detect route configuration: After the above steps are configured, PC0 and PC1 can communicate, Route0 and Route1 can also communicate, but PC0 cannot communicate with PC3, the reason is because the router does not configure a static route, this step we only need to ensure that the same network segment can communicate.

#----在PC0上操作-------------------------

PC0> ping 192.168.1.1

PC0> ping 192.168.1.2

PC0> ping 192.168.1.3

Pinging 192.168.1.3 with 32 bytes of data:

Reply from 192.168.1.3: bytes=32 time=0ms TTL=128




#----在Route0上操作----------------------

Router0#ping 10.10.10.20




Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 10.10.10.20, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/7/12 ms

           

Configure static routes: Next, we need to configure route entries on the two routers separately, use the ip route command to configure, if you want to delete the route, you can use the no ip route command to delete the specified route entry.

#----在Router0上操作-------------------------

Router0> enable

Router0# configure terminal




                           [目的网络]    [目的掩码]         [下一跳地址]

Router0(config)# ip route 192.168.2.0  255.255.255.0      10.10.10.20




#----在Router1上操作-------------------------

Router1> enable

Router1# configure terminal

Router1(config)# ip route 192.168.1.0 255.255.255.0 10.10.10.10        // 指定返回时的路由




#----检查配置参数情况-------------------------

Router0# show ip interface brief          // 显示端口ip

Router0# show ip route                    // 检查路由参数

Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP

       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

       * - candidate default, U - per-user static route, o - ODR

       P - periodic downloaded static route




Gateway of last resort is not set

     10.0.0.0/24 is subnetted, 1 subnets

C    10.10.10.0 is directly connected, Serial0/0/0

C    192.168.1.0/24 is directly connected,FastEthernet0/0

S    192.168.2.0/24 [1/0] via 10.10.10.20

           

Final test: When the route entry is configured, we Ping on the PC0 host to check the connectivity of PC3, and we will find that the two network segments that could not be connected can now communicate normally, which means that our route configuration has taken effect.

PC0> ping 192.168.2.2




Pinging 192.168.2.2 with 32 bytes of data:




Reply from 192.168.2.2: bytes=32 time=12ms TTL=126




Ping statistics for 192.168.2.2:

    Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

    Minimum = 12ms, Maximum = 12ms, Average = 12ms
以上的路由配置方法,适用于小型网络环境,在大型网络环境中这种静态路由的配置方式很不适合维护,一旦设备过多,则可能自己都搞不清头绪,所以在生产环境中,我们会使用动态路由的方式来实现路由器的配置,接下来继续学习动态路由的配置方式吧.
           

RIP dynamic routing

Dynamic routing is based on a certain protocol, and the common routing protocols include Inner Gateway Protocol (IGP) and Border Gateway Protocol (BGP), which are divided into Routing Information Protocol (RIP) and Open Shortest Path First Protocol (OSPF) protocol.

RIP uses hops to measure the distance to the destination address, which refers to the number of routers that data passes from the source address to the destination address. The number of hops from the router to the network connected directly is defined as 1, and the value increases by 1 for each router, and the maximum number of hops allowed by RIP is 15 hops, and the network beyond 15 hops will not be reachable, so RIP is suitable for small network environments.

By default, the RIP protocol will broadcast its own routing table with other connected networks every 30 seconds, and the router that receives the broadcast will compare the received information with its own routing table to determine whether to add the route entries to its own routing table, at present, RIP has 3 versions, RIPv1, RIPv2, RIPng, where RIPng is used in IPv6 network environment, RIPv1 is a class-based routing protocol, and RIPv2 is a classless routing protocol.

Practical sharing: Advanced configuration of Cisco routers helps enterprise networks run efficiently

Introduction to configuration parameters: First of all, we configure various basic parameters of the router according to the configuration requirements in the above figure, and the following parameters are specific address planning.

[设备名称]     [设备接口]        [IP地址]          [默认网关]




 Router1     Serial0/0/0    192.168.10.1/24         ---




 Router2     Serial0/0/0    192.168.10.2/24         ---

             Serial0/0/1    192.168.20.1/24         ---




 Router3     Serial0/0/0    192.168.20.2/24         ---

             Serial0/0/1    192.168.30.1/24         ---




 Router4     Serial0/0/0    192.168.30.2/24         ---

           

Configure the router: Configure the various parameters of the router according to the structure in the above table, and mainly configure the interface IP address of the router.

Router>enable

Router#configure terminal




#----在Router1上操作-------------------------

Router1(config)# interface Serial0/0/0

Router1(config-if)# ip address 192.168.10.1 255.255.255.0

Router1(config-if)# no shutdown




#----在Router2上操作-------------------------

Router2(config)# interface Serial0/0/0

Router2(config-if)# ip address 192.168.10.2 255.255.255.0

Router1(config-if)# no shutdown

Router2(config)# interface Serial0/0/1

Router2(config-if)# ip address 192.168.20.1 255.255.255.0

Router1(config-if)# no shutdown




#----在Router3上操作-------------------------

Router3(config)# interface Serial0/0/0

Router3(config-if)# ip address 192.168.20.2 255.255.255.0

Router1(config-if)# no shutdown

Router3(config)# interface Serial0/0/1

Router3(config-if)# ip address 192.168.30.1 255.255.255.0

Router1(config-if)# no shutdown




#----在Router4上操作-------------------------

Router4(config)#interface Serial0/0/0

Router4(config-if)#ip address 192.168.30.2 255.255.255.0

Router1(config-if)# no shutdown

           

Configure and enable RIP routing: Enable and configure RIP dynamic routing on each router.

Router>enable

Router#configure terminal

#----在Router1上启用RIP路由协议并配置-------------------

Router1(config)# router rip                   // 启用RIP路由

Router1(config-router)# version 2             // 指定使用RIP版本为RIPv2

Router1(config-router)# network 192.168.10.0  // 声明与Router1直连的网络号

Router1(config-router)# exit




#----在Router2上启用RIP路由协议并配置-------------------

Router2(config)# router rip

Router2(config-router)# version 2

Router2(config-router)# network 192.168.10.0  // 声明与Router2直连的网络号

Router2(config-router)# network 192.168.20.0  // 声明与Router3直连的网络号

Router2(config-router)# exit




#----在Router3上启用RIP路由协议并配置-------------------

Router3(config)# router rip

Router3(config-router)# version 2

Router3(config-router)# network 192.168.20.0  // 声明与Router3直连的网络号

Router3(config-router)# network 192.168.30.0  // 声明与Router4直连的网络号

Router3(config-router)# exit




#----在Router4上启用RIP路由协议并配置-------------------

Router4(config)# router rip

Router4(config-router)# version 2

Router4(config-router)# network 192.168.30.0  // 声明与Router4直连的网络号

Router4(config-router)# exit

           

Check the configuration information: After the configuration is complete, run the show ip route command on Router1 to check the RIP configuration result, as follows:

Router1#show ip route

Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP

       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

       * - candidate default, U - per-user static route, o - ODR

       P - periodic downloaded static route




Gateway of last resort is not set




C    192.168.10.0/24 is directly connected, Serial0/0/0

R    192.168.20.0/24 [120/1] via 192.168.10.2, 00:00:01, Serial0/0/0   // R表示当前是RIP路由

R    192.168.30.0/24 [120/2] via 192.168.10.2, 00:00:01, Serial0/0/0   // 路由条目是RIP自动生成的

           

Test connectivity: At this time, we ping the router Router4 on the Router1 router to communicate, which means that the configuration is successful.

Router1#ping 192.168.30.2




Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.30.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 3/15/27 ms

           

OSPF Dynamic Routing

In the above configuration test, we completed the data communication between a router by using the RIP protocol, but the RIP protocol only supports a maximum of 15 routing nodes, although these nodes are enough in small and medium-sized networks, but in some large enterprises often need more hops, it is because of this demand that our OSPF protocol was born.

OSPF (Open Shortest Path First), this protocol is a protocol specification based on the link state, so it can also be called the link state protocol, the same as the RIP protocol, the OSPF protocol also uses hops to measure the path overhead, but unlike RIP, the OSPF protocol is not limited by the physical hop number, and its path overhead is related to the link overhead in the network.

The OSPF protocol uses the FPS algorithm to calculate the number of shortest paths, the SPF algorithm uses each route as the root to calculate the distance between its packets to each destination router, and each router calculates the topology of the routing domain according to a unified database LSDB, which is very much like a tree, so it is called the shortest path tree.

Advantages of the OSPF protocol:

1. OSPF adopts SPF algorithm, which can well avoid the generation of router loops.

2. Although the OSPF protocol also uses hop count as the unit of measurement, it is not limited by the physical hop number.

3. When the network link status changes, OSPF can quickly capture and apply, with fast convergence and small routing information traffic.

4. OSPF routing protocol supports routing authentication system, and can also define different authentication methods, which improves network security.

5. The OSPF protocol provides better load balancing, and its data update is more intelligent, which reduces the bandwidth of network traffic.

In the following configuration experiment, you will see a network number such as 0.0.0.255, which is called the wildcard mask, usually the wildcard mask can be obtained by subtracting the current 255.255.255.255.0 (subnet mask) from the current 255.255.255.255.0 (subnet mask).

Next, let's get down to business, we still use the same topology of RIP routing and the configuration of IP addresses, but here when configuring dynamic routing, we use OSPF to configure, the process is as follows:

Configure the router: First of all, configure the various parameters of the router according to the structure of the above table.

Router>enable

Router#configure terminal




#----在Router1上操作-------------------------

Router1(config)# interface Serial0/0/0

Router1(config-if)# ip address 192.168.10.1 255.255.255.0

Router1(config-if)# no shutdown




#----在Router2上操作-------------------------

Router2(config)# interface Serial0/0/0

Router2(config-if)# ip address 192.168.10.2 255.255.255.0

Router1(config-if)# no shutdown

Router2(config)# interface Serial0/0/1

Router2(config-if)# ip address 192.168.20.1 255.255.255.0

Router1(config-if)# no shutdown




#----在Router3上操作-------------------------

Router3(config)# interface Serial0/0/0

Router3(config-if)# ip address 192.168.20.2 255.255.255.0

Router1(config-if)# no shutdown

Router3(config)# interface Serial0/0/1

Router3(config-if)# ip address 192.168.30.1 255.255.255.0

Router1(config-if)# no shutdown




#----在Router4上操作-------------------------

Router4(config)# interface Serial0/0/0

Router4(config-if)# ip address 192.168.30.2 255.255.255.0

Router1(config-if)# no shutdown

           

Configure and enable OSPF routing: Enable and configure OSPF dynamic routing on each router.

Router>enable

Router#configure terminal




#----在Router1上启用OSPF路由协议并配置-------------------

Router1(config)# router ospf 1                                 // 启用OSPF路由,并设置进程号为1

Router1(config-router)# router-id 1.1.1.1                      // 为Router1配置RID编号

Router1(config-router)# network 192.168.10.0 0.0.0.255 area 0  // 配置路由记录

Router1(config-router)# exit




#----在Router2上启用OSPF路由协议并配置-------------------

Router2(config)# router ospf 1                                 // 启用OSPF路由,并设置进程号为1

Router2(config-router)# router-id 2.2.2.2                      // 为Router2配置RID编号

Router2(config-router)# network 192.168.10.0 0.0.0.255 area 0  // 配置路由记录

Router2(config-router)# network 192.168.20.0 0.0.0.255 area 0

Router2(config-router)# exit




#----在Router3上启用OSPF路由协议并配置-------------------

Router3(config)# router ospf 1                                 // 启用OSPF路由,并设置进程号为1

Router3(config-router)# router-id 3.3.3.3                      // 为Router3配置RID编号

Router3(config-router)# network 192.168.20.0 0.0.0.255 area 0

Router3(config-router)# network 192.168.30.0 0.0.0.255 area 0

Router3(config-router)# exit




#----在Router4上启用OSPF路由协议并配置-------------------

Router3(config)# router ospf 1                                 // 启用OSPF路由,并设置进程号为1

Router3(config-router)# router-id 4.4.4.4                      // 为Router4配置RID编号

Router3(config-router)# network 192.168.30.0 0.0.0.255 area 0

Router3(config-router)# exit

           

Check the configuration information: After the configuration is complete, run the show ip route command on Router1 to check the OSPF configuration result, as follows:

Router#show ip route

Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP

       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

       * - candidate default, U - per-user static route, o - ODR

       P - periodic downloaded static route




Gateway of last resort is not set




C    192.168.10.0/24 is directly connected, Serial0/0/0                    // C表示是本机默认路由

O    192.168.20.0/24 [110/128] via 192.168.10.2, 00:02:25, Serial0/0/0     // O表示当前是OSPF路由

O    192.168.30.0/24 [110/192] via 192.168.10.2, 00:01:55, Serial0/0/0     // 路由条目是OSPF自动生成的

           

Test connectivity: At this time, we ping the router Router4 on the Router1 router to communicate, which means that the configuration is successful.

Router1#ping 192.168.30.2




Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.30.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 3/15/27 ms

           

Practice: Configure a RIP enterprise environment

Next, we use a Layer 3 switch to cooperate with a router to implement a cross-network segment communication case, the configuration process is to first configure a Layer 3 switch and divide the VLAN level, then configure Router0 without configuring a VLAN, because the Layer 3 switch shares a VLAN with Router0, and finally configure the Router1 router with the external network port, and its topology is shown in the following figure:

Practical sharing: Advanced configuration of Cisco routers helps enterprise networks run efficiently

Configure Layer 3 switching: First, configure the Layer 3 switch, create three VLANs, and divide them into three VLANs.

Switch> enable

Switch# configure terminal




#----配置三层交换的VLAN10并把端口fa0/1加入到VLAN-------------------

Switch(config)# vlan 10                              // 创建VLAN10

Switch(config-vlan)# interface fa0/1                 // 将Fa1俩端口加入到VLAN10

Switch(config-if-range)# switchport mode access

Switch(config-if-range)# switchport access vlan 10   // 把端口加入到VLAN10

Switch(config-if-range)# no shutdown                 // 启用端口

Switch(config-if-range)# exit




#----配置三层交换的VLAN20并把端口fa0/2加入到VLAN-------------------

Switch(config)# vlan 20

Switch(config-vlan)# interface fa0/2

Switch(config-if-range)# switchport mode access

Switch(config-if-range)# switchport access vlan 20

Switch(config-if-range)# no shutdown

Switch(config-if-range)# exit




#----配置三层交换的VLAN30并把端口fa0/3加入到VLAN-------------------

Switch(config)# vlan 30

Switch(config-vlan)# interface fa0/3

Switch(config-if)# switchport mode access

Switch(config-if)# switchport access vlan 30

Switch(config-if)# no shutdown

Switch(config-if)# exit

           

Configure Layer 3 Switched IP Addresses: Give the above three VLANs a virtual LAN IP address, and specify them as their respective gateway addresses.

Switch> enable

Switch# configure terminal




#----给三层交换的VLAN10内的主机添加网关-------------------

Switch(config)# interface vlan 10                            // 选择vlan10接口

Switch(config-if)# ip address 192.168.1.1 255.255.255.0      // 配置网关地址

Switch(config-if)# no shutdown                               // 开启端口

Switch(config-if)# exit




#----给三层交换的VLAN20内的主机添加网关-------------------

Switch(config)# interface vlan 20                            // 选择vlan20接口

Switch(config-if)# ip address 192.168.2.1 255.255.255.0      // 配置网关地址

Switch(config-if)# no shutdown                               // 开启端口

Switch(config-if)# exit




#----给三层交换的VLAN30内的主机添加网关-------------------

Switch(config)# interface vlan 30                            // 选择vlan30接口

Switch(config-if)# ip address 192.168.3.1 255.255.255.0      // 配置网关地址

Switch(config-if)# no shutdown                               // 开启端口

Switch(config-if)# exit

           

Configure Router Router0: After configuring the gateway, then configure Router Router0 and configure the IP address of the interface.

Router> enable

Router# configure terminal




#----配置路由fa0/0端口的IP地址-------------------

Router0(config)# interface fa0/0

Router0(config-if)# ip address 192.168.3.2 255.255.255.0

Router0(config-if)# no shutdown

Router0(config-if)# exit




#----配置路由fa0/1端口的IP地址-------------------

Router0(config)# interface fa0/1

Router0(config-if)# ip address 192.168.4.1 255.255.255.0

Router0(config-if)# no shutdown

Router0(config-if)# exit




#----配置路由se0/0/0连接外网端口IP----------------

Router0(config)# interface se0/0/0

Router0(config-if)# ip address 1.1.1.1 255.0.0.0

Router0(config-if)# no shutdown

Router0(config-if)# exit

           

Configure Router 1: Finally, configure Router1, the connecting router between the external network and the private network, and configure the IP address of the external network port and the internal network port address.

Router> enable

Router# configure terminal




#----配置路由器1的内网口地址-------------------

Router1(config)# interface se0/0/0

Router1(config-if)# ip address 1.1.1.2 255.0.0.0

Router1(config-if)# no shutdown

Router1(config-if)# exit




#----配置路由器1的外网口地址-------------------

Router1(config)# interface fa0/0

Router1(config-if)# ip address 10.10.10.10 255.0.0.0

Router1(config-if)# no shutdown

           

Enable Layer 3 Switch Routing: Enable the Layer 3 switch routing function and configure RIP dynamic routing to indicate the CIDR block address of each router.

Switch(config)# ip routing
Switch(config)# router rip
Switch(config-router)# network 192.168.1.0
Switch(config-router)# network 192.168.2.0
Switch(config-router)# network 192.168.3.0
Switch(config-router)# network 192.168.4.0           

Configure RIP for Layer 2 routers: Finally, you need to configure two routers separately and enable their routing features

#----配置路由器Router0-------------------

Router0(config)# router rip

Router0(config-router)# network 192.168.3.0

Router0(config-router)# network 192.168.4.0




#----配置路由器Router1-------------------

Router1(config)# route rip

Router1(config-router)# network 192.168.3.0

Router1(config-router)# network 192.168.4.0

Router1(config-router)# network 192.168.4.0

Router1(config-router)# network 1.1.1.1

           

The above configuration process is all the experimental configuration process, after the configuration is completed, we first use the ping command to test whether the internal host can be ping, and the final experimental result is that the internal network host can achieve communication, and the external network host cannot communicate with the internal network host.

Pay attention to the best of the industry: IT operation and maintenance base camp, and get 60 G of "Network Engineering System Gift Package" + 1000 pages of Linux learning notes

Read on